diff mbox series

[27/45] drm/radeon/ttm: cleanup move exit paths

Message ID 20200924051845.397177-28-airlied@gmail.com (mailing list archive)
State New, archived
Headers show
Series TTM move refactoring | expand

Commit Message

Dave Airlie Sept. 24, 2020, 5:18 a.m. UTC
From: Dave Airlie <airlied@redhat.com>

Signed-off-by: Dave Airlie <airlied@redhat.com>
---
 drivers/gpu/drm/radeon/radeon_ttm.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 496e7b1e14ad..490c7355c9cc 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -342,15 +342,12 @@  static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
 		return -EINVAL;
 
 	rdev = radeon_get_rdev(bo->bdev);
-	if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL) {
-		ttm_bo_move_null(bo, new_mem);
-		return 0;
-	}
+	if (old_mem->mem_type == TTM_PL_SYSTEM && bo->ttm == NULL)
+		goto out_assign;
+
 	if (old_mem->mem_type == TTM_PL_SYSTEM &&
-	    new_mem->mem_type == TTM_PL_TT) {
-		ttm_bo_move_null(bo, new_mem);
-		return 0;
-	}
+	    new_mem->mem_type == TTM_PL_TT)
+		goto out_assign;
 
 	if (old_mem->mem_type == TTM_PL_TT &&
 	    new_mem->mem_type == TTM_PL_SYSTEM) {
@@ -360,8 +357,7 @@  static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
 		r = ttm_tt_set_placement_caching(bo->ttm, new_mem->placement);
 		if (r)
 			return r;
-		ttm_bo_assign_mem(bo, new_mem);
-		return 0;
+		goto out_assign;
 	}
 
 	if (!rdev->ring[radeon_copy_ring_index(rdev)].ready ||
@@ -394,6 +390,9 @@  static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
 	/* update statistics */
 	atomic64_add((u64)bo->num_pages << PAGE_SHIFT, &rdev->num_bytes_moved);
 	return 0;
+out_assign:
+	ttm_bo_assign_mem(bo, new_mem);
+	return 0;
 }
 
 static int radeon_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_resource *mem)