[PATCH 5/8] drm/amdgpu: don't use ttm_bo_move_ttm in amdgpu_ttm_bind

Christian König deathsimple at vodafone.de
Thu Oct 26 16:06:20 UTC 2017


From: Christian König <christian.koenig at amd.com>

Just unbind and rebind to force updates of the GART space.

This prevents forcing the BO to be idle.

Signed-off-by: Christian König <christian.koenig at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 3045701..b40d2f3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -917,14 +917,26 @@ int amdgpu_ttm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *bo_mem)
 	if (unlikely(r))
 		return r;
 
-	r = ttm_bo_move_ttm(bo, true, false, &tmp);
-	if (unlikely(r))
+	if (ttm->state == tt_bound) {
+		r = ttm->func->unbind(ttm);
+		if (unlikely(r))
+			return r;
+
+		ttm->state = tt_unbound;
+	}
+
+	r = ttm_tt_bind(ttm, &tmp);
+	if (unlikely(r)) {
 		ttm_bo_mem_put(bo, &tmp);
-	else
-		bo->offset = (bo->mem.start << PAGE_SHIFT) +
-			bo->bdev->man[bo->mem.mem_type].gpu_offset;
+		return r;
+	}
 
-	return r;
+	ttm_bo_mem_put(bo, bo_mem);
+	bo->mem = tmp;
+	bo->offset = (bo->mem.start << PAGE_SHIFT) +
+		bo->bdev->man[bo->mem.mem_type].gpu_offset;
+
+	return 0;
 }
 
 int amdgpu_ttm_recover_gart(struct amdgpu_device *adev)
-- 
2.7.4



More information about the amd-gfx mailing list