Commit 30d2d9a5 authored by Jerome Glisse's avatar Jerome Glisse Committed by Dave Airlie

drm/radeon/kms: Fix r600 blit cleanup path

r600 blit cleanup path need to check if a bo was allocated before
trying to free or unpin it. This patch add this check and avoid
oops when the initialization on r6xx or r7xx hw fails.
Signed-off-by: default avatarJerome Glisse <jglisse@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 6398d424
...@@ -1961,11 +1961,13 @@ int r600_suspend(struct radeon_device *rdev) ...@@ -1961,11 +1961,13 @@ int r600_suspend(struct radeon_device *rdev)
r600_wb_disable(rdev); r600_wb_disable(rdev);
r600_pcie_gart_disable(rdev); r600_pcie_gart_disable(rdev);
/* unpin shaders bo */ /* unpin shaders bo */
r = radeon_bo_reserve(rdev->r600_blit.shader_obj, false); if (rdev->r600_blit.shader_obj) {
if (unlikely(r != 0)) r = radeon_bo_reserve(rdev->r600_blit.shader_obj, false);
return r; if (!r) {
radeon_bo_unpin(rdev->r600_blit.shader_obj); radeon_bo_unpin(rdev->r600_blit.shader_obj);
radeon_bo_unreserve(rdev->r600_blit.shader_obj); radeon_bo_unreserve(rdev->r600_blit.shader_obj);
}
}
return 0; return 0;
} }
......
...@@ -512,14 +512,16 @@ void r600_blit_fini(struct radeon_device *rdev) ...@@ -512,14 +512,16 @@ void r600_blit_fini(struct radeon_device *rdev)
{ {
int r; int r;
if (rdev->r600_blit.shader_obj == NULL)
return;
/* If we can't reserve the bo, unref should be enough to destroy
* it when it becomes idle.
*/
r = radeon_bo_reserve(rdev->r600_blit.shader_obj, false); r = radeon_bo_reserve(rdev->r600_blit.shader_obj, false);
if (unlikely(r != 0)) { if (!r) {
dev_err(rdev->dev, "(%d) can't finish r600 blit\n", r); radeon_bo_unpin(rdev->r600_blit.shader_obj);
goto out_unref; radeon_bo_unreserve(rdev->r600_blit.shader_obj);
} }
radeon_bo_unpin(rdev->r600_blit.shader_obj);
radeon_bo_unreserve(rdev->r600_blit.shader_obj);
out_unref:
radeon_bo_unref(&rdev->r600_blit.shader_obj); radeon_bo_unref(&rdev->r600_blit.shader_obj);
} }
......
...@@ -975,10 +975,12 @@ int rv770_suspend(struct radeon_device *rdev) ...@@ -975,10 +975,12 @@ int rv770_suspend(struct radeon_device *rdev)
r600_wb_disable(rdev); r600_wb_disable(rdev);
rv770_pcie_gart_disable(rdev); rv770_pcie_gart_disable(rdev);
/* unpin shaders bo */ /* unpin shaders bo */
r = radeon_bo_reserve(rdev->r600_blit.shader_obj, false); if (rdev->r600_blit.shader_obj) {
if (likely(r == 0)) { r = radeon_bo_reserve(rdev->r600_blit.shader_obj, false);
radeon_bo_unpin(rdev->r600_blit.shader_obj); if (likely(r == 0)) {
radeon_bo_unreserve(rdev->r600_blit.shader_obj); radeon_bo_unpin(rdev->r600_blit.shader_obj);
radeon_bo_unreserve(rdev->r600_blit.shader_obj);
}
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment