Commit 977c38d5 authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Dave Airlie

drm/radeon: get rid of ttm_bo_is_reserved usage

Try to use lockdep_assert_held or other alternatives where possible.
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: default avatarJerome Glisse <jglisse@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 009a9dad
...@@ -400,7 +400,7 @@ int radeon_bo_get_surface_reg(struct radeon_bo *bo) ...@@ -400,7 +400,7 @@ int radeon_bo_get_surface_reg(struct radeon_bo *bo)
int steal; int steal;
int i; int i;
BUG_ON(!radeon_bo_is_reserved(bo)); lockdep_assert_held(&bo->tbo.resv->lock.base);
if (!bo->tiling_flags) if (!bo->tiling_flags)
return 0; return 0;
...@@ -526,7 +526,8 @@ void radeon_bo_get_tiling_flags(struct radeon_bo *bo, ...@@ -526,7 +526,8 @@ void radeon_bo_get_tiling_flags(struct radeon_bo *bo,
uint32_t *tiling_flags, uint32_t *tiling_flags,
uint32_t *pitch) uint32_t *pitch)
{ {
BUG_ON(!radeon_bo_is_reserved(bo)); lockdep_assert_held(&bo->tbo.resv->lock.base);
if (tiling_flags) if (tiling_flags)
*tiling_flags = bo->tiling_flags; *tiling_flags = bo->tiling_flags;
if (pitch) if (pitch)
...@@ -536,7 +537,8 @@ void radeon_bo_get_tiling_flags(struct radeon_bo *bo, ...@@ -536,7 +537,8 @@ void radeon_bo_get_tiling_flags(struct radeon_bo *bo,
int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved, int radeon_bo_check_tiling(struct radeon_bo *bo, bool has_moved,
bool force_drop) bool force_drop)
{ {
BUG_ON(!radeon_bo_is_reserved(bo) && !force_drop); if (!force_drop)
lockdep_assert_held(&bo->tbo.resv->lock.base);
if (!(bo->tiling_flags & RADEON_TILING_SURFACE)) if (!(bo->tiling_flags & RADEON_TILING_SURFACE))
return 0; return 0;
......
...@@ -98,11 +98,6 @@ static inline unsigned long radeon_bo_size(struct radeon_bo *bo) ...@@ -98,11 +98,6 @@ static inline unsigned long radeon_bo_size(struct radeon_bo *bo)
return bo->tbo.num_pages << PAGE_SHIFT; return bo->tbo.num_pages << PAGE_SHIFT;
} }
static inline bool radeon_bo_is_reserved(struct radeon_bo *bo)
{
return ttm_bo_is_reserved(&bo->tbo);
}
static inline unsigned radeon_bo_ngpu_pages(struct radeon_bo *bo) static inline unsigned radeon_bo_ngpu_pages(struct radeon_bo *bo)
{ {
return (bo->tbo.num_pages << PAGE_SHIFT) / RADEON_GPU_PAGE_SIZE; return (bo->tbo.num_pages << PAGE_SHIFT) / RADEON_GPU_PAGE_SIZE;
......
...@@ -35,7 +35,6 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag) ...@@ -35,7 +35,6 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)
{ {
struct radeon_bo *vram_obj = NULL; struct radeon_bo *vram_obj = NULL;
struct radeon_bo **gtt_obj = NULL; struct radeon_bo **gtt_obj = NULL;
struct radeon_fence *fence = NULL;
uint64_t gtt_addr, vram_addr; uint64_t gtt_addr, vram_addr;
unsigned i, n, size; unsigned i, n, size;
int r, ring; int r, ring;
...@@ -81,37 +80,38 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag) ...@@ -81,37 +80,38 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)
} }
r = radeon_bo_reserve(vram_obj, false); r = radeon_bo_reserve(vram_obj, false);
if (unlikely(r != 0)) if (unlikely(r != 0))
goto out_cleanup; goto out_unref;
r = radeon_bo_pin(vram_obj, RADEON_GEM_DOMAIN_VRAM, &vram_addr); r = radeon_bo_pin(vram_obj, RADEON_GEM_DOMAIN_VRAM, &vram_addr);
if (r) { if (r) {
DRM_ERROR("Failed to pin VRAM object\n"); DRM_ERROR("Failed to pin VRAM object\n");
goto out_cleanup; goto out_unres;
} }
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
void *gtt_map, *vram_map; void *gtt_map, *vram_map;
void **gtt_start, **gtt_end; void **gtt_start, **gtt_end;
void **vram_start, **vram_end; void **vram_start, **vram_end;
struct radeon_fence *fence = NULL;
r = radeon_bo_create(rdev, size, PAGE_SIZE, true, r = radeon_bo_create(rdev, size, PAGE_SIZE, true,
RADEON_GEM_DOMAIN_GTT, NULL, gtt_obj + i); RADEON_GEM_DOMAIN_GTT, NULL, gtt_obj + i);
if (r) { if (r) {
DRM_ERROR("Failed to create GTT object %d\n", i); DRM_ERROR("Failed to create GTT object %d\n", i);
goto out_cleanup; goto out_lclean;
} }
r = radeon_bo_reserve(gtt_obj[i], false); r = radeon_bo_reserve(gtt_obj[i], false);
if (unlikely(r != 0)) if (unlikely(r != 0))
goto out_cleanup; goto out_lclean_unref;
r = radeon_bo_pin(gtt_obj[i], RADEON_GEM_DOMAIN_GTT, &gtt_addr); r = radeon_bo_pin(gtt_obj[i], RADEON_GEM_DOMAIN_GTT, &gtt_addr);
if (r) { if (r) {
DRM_ERROR("Failed to pin GTT object %d\n", i); DRM_ERROR("Failed to pin GTT object %d\n", i);
goto out_cleanup; goto out_lclean_unres;
} }
r = radeon_bo_kmap(gtt_obj[i], &gtt_map); r = radeon_bo_kmap(gtt_obj[i], &gtt_map);
if (r) { if (r) {
DRM_ERROR("Failed to map GTT object %d\n", i); DRM_ERROR("Failed to map GTT object %d\n", i);
goto out_cleanup; goto out_lclean_unpin;
} }
for (gtt_start = gtt_map, gtt_end = gtt_map + size; for (gtt_start = gtt_map, gtt_end = gtt_map + size;
...@@ -127,13 +127,13 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag) ...@@ -127,13 +127,13 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)
r = radeon_copy_blit(rdev, gtt_addr, vram_addr, size / RADEON_GPU_PAGE_SIZE, &fence); r = radeon_copy_blit(rdev, gtt_addr, vram_addr, size / RADEON_GPU_PAGE_SIZE, &fence);
if (r) { if (r) {
DRM_ERROR("Failed GTT->VRAM copy %d\n", i); DRM_ERROR("Failed GTT->VRAM copy %d\n", i);
goto out_cleanup; goto out_lclean_unpin;
} }
r = radeon_fence_wait(fence, false); r = radeon_fence_wait(fence, false);
if (r) { if (r) {
DRM_ERROR("Failed to wait for GTT->VRAM fence %d\n", i); DRM_ERROR("Failed to wait for GTT->VRAM fence %d\n", i);
goto out_cleanup; goto out_lclean_unpin;
} }
radeon_fence_unref(&fence); radeon_fence_unref(&fence);
...@@ -141,7 +141,7 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag) ...@@ -141,7 +141,7 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)
r = radeon_bo_kmap(vram_obj, &vram_map); r = radeon_bo_kmap(vram_obj, &vram_map);
if (r) { if (r) {
DRM_ERROR("Failed to map VRAM object after copy %d\n", i); DRM_ERROR("Failed to map VRAM object after copy %d\n", i);
goto out_cleanup; goto out_lclean_unpin;
} }
for (gtt_start = gtt_map, gtt_end = gtt_map + size, for (gtt_start = gtt_map, gtt_end = gtt_map + size,
...@@ -160,7 +160,7 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag) ...@@ -160,7 +160,7 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)
(vram_addr - rdev->mc.vram_start + (vram_addr - rdev->mc.vram_start +
(void*)gtt_start - gtt_map)); (void*)gtt_start - gtt_map));
radeon_bo_kunmap(vram_obj); radeon_bo_kunmap(vram_obj);
goto out_cleanup; goto out_lclean_unpin;
} }
*vram_start = vram_start; *vram_start = vram_start;
} }
...@@ -173,13 +173,13 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag) ...@@ -173,13 +173,13 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)
r = radeon_copy_blit(rdev, vram_addr, gtt_addr, size / RADEON_GPU_PAGE_SIZE, &fence); r = radeon_copy_blit(rdev, vram_addr, gtt_addr, size / RADEON_GPU_PAGE_SIZE, &fence);
if (r) { if (r) {
DRM_ERROR("Failed VRAM->GTT copy %d\n", i); DRM_ERROR("Failed VRAM->GTT copy %d\n", i);
goto out_cleanup; goto out_lclean_unpin;
} }
r = radeon_fence_wait(fence, false); r = radeon_fence_wait(fence, false);
if (r) { if (r) {
DRM_ERROR("Failed to wait for VRAM->GTT fence %d\n", i); DRM_ERROR("Failed to wait for VRAM->GTT fence %d\n", i);
goto out_cleanup; goto out_lclean_unpin;
} }
radeon_fence_unref(&fence); radeon_fence_unref(&fence);
...@@ -187,7 +187,7 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag) ...@@ -187,7 +187,7 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)
r = radeon_bo_kmap(gtt_obj[i], &gtt_map); r = radeon_bo_kmap(gtt_obj[i], &gtt_map);
if (r) { if (r) {
DRM_ERROR("Failed to map GTT object after copy %d\n", i); DRM_ERROR("Failed to map GTT object after copy %d\n", i);
goto out_cleanup; goto out_lclean_unpin;
} }
for (gtt_start = gtt_map, gtt_end = gtt_map + size, for (gtt_start = gtt_map, gtt_end = gtt_map + size,
...@@ -206,7 +206,7 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag) ...@@ -206,7 +206,7 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)
(gtt_addr - rdev->mc.gtt_start + (gtt_addr - rdev->mc.gtt_start +
(void*)vram_start - vram_map)); (void*)vram_start - vram_map));
radeon_bo_kunmap(gtt_obj[i]); radeon_bo_kunmap(gtt_obj[i]);
goto out_cleanup; goto out_lclean_unpin;
} }
} }
...@@ -214,31 +214,32 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag) ...@@ -214,31 +214,32 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)
DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n", DRM_INFO("Tested GTT->VRAM and VRAM->GTT copy for GTT offset 0x%llx\n",
gtt_addr - rdev->mc.gtt_start); gtt_addr - rdev->mc.gtt_start);
continue;
out_lclean_unpin:
radeon_bo_unpin(gtt_obj[i]);
out_lclean_unres:
radeon_bo_unreserve(gtt_obj[i]);
out_lclean_unref:
radeon_bo_unref(&gtt_obj[i]);
out_lclean:
for (--i; i >= 0; --i) {
radeon_bo_unpin(gtt_obj[i]);
radeon_bo_unreserve(gtt_obj[i]);
radeon_bo_unref(&gtt_obj[i]);
}
if (fence)
radeon_fence_unref(&fence);
break;
} }
radeon_bo_unpin(vram_obj);
out_unres:
radeon_bo_unreserve(vram_obj);
out_unref:
radeon_bo_unref(&vram_obj);
out_cleanup: out_cleanup:
if (vram_obj) { kfree(gtt_obj);
if (radeon_bo_is_reserved(vram_obj)) {
radeon_bo_unpin(vram_obj);
radeon_bo_unreserve(vram_obj);
}
radeon_bo_unref(&vram_obj);
}
if (gtt_obj) {
for (i = 0; i < n; i++) {
if (gtt_obj[i]) {
if (radeon_bo_is_reserved(gtt_obj[i])) {
radeon_bo_unpin(gtt_obj[i]);
radeon_bo_unreserve(gtt_obj[i]);
}
radeon_bo_unref(&gtt_obj[i]);
}
}
kfree(gtt_obj);
}
if (fence) {
radeon_fence_unref(&fence);
}
if (r) { if (r) {
printk(KERN_WARNING "Error while testing BO move.\n"); printk(KERN_WARNING "Error while testing BO move.\n");
} }
......
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