[PATCH 13/14] drm/amdgpu: modify the method to use mem under buffer object for amdgpu_ttm_tt_pte_flags

Huang, Ray Ray.Huang at amd.com
Wed Sep 11 11:50:46 UTC 2019


amdgpu_ttm_tt_pte_flags will be used for updating tmz bits while the bo is
secure, so we need pass the ttm_mem_reg under a buffer object.

Signed-off-by: Huang Rui <ray.huang at amd.com>
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index c05638c..3663655 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -1117,8 +1117,8 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
 	} else {
 
 		/* allocate GART space */
-		tmp = bo->mem;
-		tmp.mm_node = NULL;
+		tmp = bo->mem; /* cache bo->mem */
+		bo->mem.mm_node = NULL;
 		placement.num_placement = 1;
 		placement.placement = &placements;
 		placement.num_busy_placement = 1;
@@ -1128,23 +1128,25 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
 		placements.flags = (bo->mem.placement & ~TTM_PL_MASK_MEM) |
 			TTM_PL_FLAG_TT;
 
-		r = ttm_bo_mem_space(bo, &placement, &tmp, &ctx);
-		if (unlikely(r))
+		r = ttm_bo_mem_space(bo, &placement, &bo->mem, &ctx);
+		if (unlikely(r)) {
+			bo->mem = tmp;
 			return r;
+		}
 
 		/* compute PTE flags for this buffer object */
-		flags = amdgpu_ttm_tt_pte_flags(adev, bo->ttm, &tmp);
+		flags = amdgpu_ttm_tt_pte_flags(adev, bo->ttm, &bo->mem);
 
 		/* Bind pages */
-		gtt->offset = (u64)tmp.start << PAGE_SHIFT;
+		gtt->offset = (u64)bo->mem.start << PAGE_SHIFT;
 		r = amdgpu_ttm_gart_bind(adev, bo, flags);
 		if (unlikely(r)) {
+			bo->mem = tmp;
 			ttm_bo_mem_put(bo, &tmp);
 			return r;
 		}
 
-		ttm_bo_mem_put(bo, &bo->mem);
-		bo->mem = tmp;
+		ttm_bo_mem_put(bo, &tmp);
 	}
 
 	bo->offset = (bo->mem.start << PAGE_SHIFT) +
-- 
2.7.4



More information about the dri-devel mailing list