diff mbox series

[44/45] drm/ttm: move more functionality into helper function.

Message ID 20200924051845.397177-45-airlied@gmail.com
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/amd/amdgpu/amdgpu_ttm.c | 10 ----------
 drivers/gpu/drm/nouveau/nouveau_bo.c    |  7 -------
 drivers/gpu/drm/radeon/radeon_ttm.c     |  8 --------
 drivers/gpu/drm/ttm/ttm_bo.c            |  4 ++++
 4 files changed, 4 insertions(+), 25 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 099752bc42e9..efb74ddc1877 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -534,11 +534,6 @@  static int amdgpu_move_vram_ram(struct ttm_buffer_object *bo, bool evict,
 		return r;
 	}
 
-	/* set caching flags */
-	r = ttm_bo_move_to_new_tt_mem(bo, ctx, &tmp_mem);
-	if (unlikely(r))
-		goto out_cleanup;
-
 	/* Bind the memory to the GTT space */
 	r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, &tmp_mem);
 	if (unlikely(r)) {
@@ -588,11 +583,6 @@  static int amdgpu_move_ram_vram(struct ttm_buffer_object *bo, bool evict,
 		return r;
 	}
 
-	/* move/bind old memory to GTT space */
-	r = ttm_bo_move_to_new_tt_mem(bo, ctx, &tmp_mem);
-	if (unlikely(r)) {
-		goto out_cleanup;
-	}
 	r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, &tmp_mem);
 	if (unlikely(r))
 		goto out_cleanup;
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 1786c92bf3fc..08beb92b0571 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -891,10 +891,6 @@  nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict,
 	if (ret)
 		return ret;
 
-	ret = ttm_bo_move_to_new_tt_mem(bo, ctx, &tmp_reg);
-	if (ret)
-		return ret;
-
 	ret = nouveau_ttm_tt_bind(bo->bdev, bo->ttm, &tmp_reg);
 	if (ret)
 		goto out;
@@ -931,9 +927,6 @@  nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict,
 	if (ret)
 		return ret;
 
-	ret = ttm_bo_move_to_new_tt_mem(bo, ctx, &tmp_reg);
-	if (ret)
-		goto out;
 	ret = nouveau_ttm_tt_bind(bo->bdev, bo->ttm, &tmp_reg);
 	if (ret)
 		goto out;
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index ccd588bd4ea5..6698e288cfbc 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -220,10 +220,6 @@  static int radeon_move_vram_ram(struct ttm_buffer_object *bo,
 	if (unlikely(r)) {
 		return r;
 	}
-	r = ttm_bo_move_to_new_tt_mem(bo, ctx, &tmp_mem);
-	if (unlikely(r)) {
-		goto out_cleanup;
-	}
 
 	r = radeon_ttm_tt_bind(bo->bdev, bo->ttm, &tmp_mem);
 	if (unlikely(r)) {
@@ -260,10 +256,6 @@  static int radeon_move_ram_vram(struct ttm_buffer_object *bo,
 	int r;
 
 	r = ttm_bo_create_tt_tmp(bo, ctx, new_mem, &tmp_mem);
-	if (unlikely(r)) {
-		return r;
-	}
-	r = ttm_bo_move_to_new_tt_mem(bo, ctx, &tmp_mem);
 	if (unlikely(r)) {
 		goto out_cleanup;
 	}
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 358d1580dc16..7ea7ed85e289 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1566,6 +1566,10 @@  int ttm_bo_create_tt_tmp(struct ttm_buffer_object *bo,
 	if (ret)
 		return ret;
 
+	ret  = ttm_bo_move_to_new_tt_mem(bo, ctx, new_temp);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 EXPORT_SYMBOL(ttm_bo_create_tt_tmp);