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

Submitted by Huang, Ray on Sept. 11, 2019, 11:50 a.m.

Details

Message ID 1568202584-14471-14-git-send-email-ray.huang@amd.com
State New
Headers show
Series "drm/amdgpu: introduce secure buffer object support (trusted memory zone)" ( rev: 1 ) in DRI devel

Not browsing as part of any series.

Commit Message

Huang, Ray Sept. 11, 2019, 11:50 a.m.
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@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

Patch hide | download patch | download mbox

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) +