[PATCH 7/8] drm/i915/gtt: Check for physical page for pd entry always

Mika Kuoppala mika.kuoppala at linux.intel.com
Mon Jun 10 12:09:04 UTC 2019


Check the physical page before writing the entry into
the physical page. This further generalizes the pd
so that manipulation in callsites will be identical,
removing the need to handle pdps differently for gen8.

Signed-off-by: Mika Kuoppala <mika.kuoppala at linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index 5b1db2be1943..bdcfbbf758fb 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -743,12 +743,8 @@ static void __set_pd_entry(struct i915_page_directory * const pd,
 
 #define set_pd_entry(pd, pde, to) \
 	(pd)->entry[(pde)] = (to); \
-	__set_pd_entry((pd), (pde), gen8_pde_encode(px_dma(to), I915_CACHE_LLC));
-
-#define set_pdp_entry(pdp, pdpe, to) \
-	(pdp)->entry[(pdpe)] = (to); \
-	if (pd_has_phys_page(pdp)) \
-		__set_pd_entry((pdp), (pdpe), gen8_pde_encode(px_dma(to), I915_CACHE_LLC));
+	if (likely(pd_has_phys_page(pd))) \
+		__set_pd_entry((pd), (pde), gen8_pde_encode(px_dma(to), I915_CACHE_LLC))
 
 /*
  * PDE TLBs are a pain to invalidate on GEN8+. When we modify
@@ -830,7 +826,7 @@ static bool gen8_ppgtt_clear_pdp(struct i915_address_space *vm,
 
 		spin_lock(&pdp->lock);
 		if (!atomic_read(&pd->used)) {
-			set_pdp_entry(pdp, pdpe, vm->scratch_pd);
+			set_pd_entry(pdp, pdpe, vm->scratch_pd);
 
 			GEM_BUG_ON(!atomic_read(&pdp->used));
 			atomic_dec(&pdp->used);
@@ -1368,7 +1364,7 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
 
 			old = cmpxchg(&pdp->entry[pdpe], vm->scratch_pd, pd);
 			if (old == vm->scratch_pd) {
-				set_pdp_entry(pdp, pdpe, pd);
+				set_pd_entry(pdp, pdpe, pd);
 				atomic_inc(&pdp->used);
 			} else {
 				free_pd(vm, pd);
@@ -1394,7 +1390,7 @@ static int gen8_ppgtt_alloc_pdp(struct i915_address_space *vm,
 unwind_pd:
 	spin_lock(&pdp->lock);
 	if (atomic_dec_and_test(&pd->used)) {
-		set_pdp_entry(pdp, pdpe, vm->scratch_pd);
+		set_pd_entry(pdp, pdpe, vm->scratch_pd);
 		GEM_BUG_ON(!atomic_read(&pdp->used));
 		atomic_dec(&pdp->used);
 		free_pd(vm, pd);
@@ -1486,7 +1482,7 @@ static int gen8_preallocate_top_level_pdp(struct i915_hw_ppgtt *ppgtt)
 			goto unwind;
 
 		init_pd(vm, pd, vm->scratch_pt);
-		set_pdp_entry(pdp, pdpe, pd);
+		set_pd_entry(pdp, pdpe, pd);
 
 		atomic_inc(&pdp->used);
 	}
@@ -1498,7 +1494,7 @@ static int gen8_preallocate_top_level_pdp(struct i915_hw_ppgtt *ppgtt)
 unwind:
 	start -= from;
 	gen8_for_each_pdpe(pd, pdp, from, start, pdpe) {
-		set_pdp_entry(pdp, pdpe, vm->scratch_pd);
+		set_pd_entry(pdp, pdpe, vm->scratch_pd);
 		free_pd(vm, pd);
 	}
 	atomic_set(&pdp->used, 0);
-- 
2.17.1



More information about the Intel-gfx-trybot mailing list