[PATCH 24/45] drm/ttm: handle binding in move callback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Dave Airlie <airlied@xxxxxxxxxx>

Signed-off-by: Dave Airlie <airlied@xxxxxxxxxx>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c    | 8 ++++++++
 drivers/gpu/drm/nouveau/nouveau_bo.c       | 8 ++++++++
 drivers/gpu/drm/radeon/radeon_ttm.c        | 8 ++++++++
 drivers/gpu/drm/ttm/ttm_bo_util.c          | 6 ------
 drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c | 5 +++++
 5 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 805730481c3f..18b7d28a0c94 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -683,6 +683,14 @@ static int amdgpu_bo_move(struct ttm_buffer_object *bo, bool evict,
 
 	adev = amdgpu_ttm_adev(bo->bdev);
 
+	if ((new_mem->mem_type == TTM_PL_TT ||
+	     new_mem->mem_type == TTM_PL_SYSTEM) &&
+	    old_mem->mem_type == TTM_PL_VRAM) {
+		r = amdgpu_ttm_backend_bind(bo->bdev, bo->ttm, new_mem);
+		if (r)
+			return r;
+	}
+
 	amdgpu_bo_move_invalidate(abo, evict);
 	/* remember the eviction */
 	if (evict)
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index dde7d59f1168..1ce13223939b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1069,6 +1069,14 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict,
 	struct nouveau_drm_tile *new_tile = NULL;
 	int ret = 0;
 
+	if ((new_reg->mem_type == TTM_PL_TT ||
+	     new_reg->mem_type == TTM_PL_SYSTEM) &&
+	    old_reg->mem_type == TTM_PL_VRAM) {
+		ret = nouveau_ttm_tt_bind(bo->bdev, bo->ttm, new_reg);
+		if (ret)
+			return ret;
+	}
+
 	ret = ttm_bo_wait_ctx(bo, ctx);
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 2c7c11cd65d8..435dc37eea34 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -322,6 +322,14 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,
 
 	rbo = container_of(bo, struct radeon_bo, tbo);
 
+	if ((new_mem->mem_type == TTM_PL_TT ||
+	     new_mem->mem_type == TTM_PL_SYSTEM) &&
+	    old_mem->mem_type == TTM_PL_VRAM) {
+		r = radeon_ttm_tt_bind(bo->bdev, bo->ttm, new_mem);
+		if (r)
+			return r;
+	}
+
 	radeon_bo_invalidate(rbo);
 	radeon_bo_memory_usage(rbo, bo->mem.mem_type, new_mem->mem_type);
 
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 2cf3c89e7944..ac921d6456b7 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -103,12 +103,6 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
 	if (ret)
 		return ret;
 
-	if (new_mem->mem_type != TTM_PL_SYSTEM) {
-		ret = ttm_bo_tt_bind(bo, new_mem);
-		if (unlikely(ret != 0))
-			return ret;
-	}
-
 	ttm_bo_assign_mem(bo, new_mem);
 	return 0;
 }
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
index d3262e07e76d..2a99c24abbdf 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ttm_buffer.c
@@ -731,6 +731,11 @@ static int vmw_move(struct ttm_buffer_object *bo,
 	struct ttm_resource_manager *new_man = ttm_manager_type(bo->bdev, new_mem->mem_type);
 	int ret;
 
+	if (new_man->use_tt && bo->mem.mem_type != TTM_PL_SYSTEM) {
+		ret = vmw_ttm_bind(bo->bdev, bo->ttm, new_mem);
+		if (ret)
+			return ret;
+	}
 	vmw_move_notify(bo, new_mem);
 	if (old_man->use_tt && new_man->use_tt) {
 		if (bo->mem.mem_type == TTM_PL_SYSTEM) {
-- 
2.27.0

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux