public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Mika Kuoppala <mika.kuoppala@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 07/10] drm/i915/gtt: Check for physical page for pd entry always
Date: Fri, 14 Jun 2019 19:43:47 +0300	[thread overview]
Message-ID: <20190614164350.30415-7-mika.kuoppala@linux.intel.com> (raw)
In-Reply-To: <20190614164350.30415-1-mika.kuoppala@linux.intel.com>

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@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index a61fa24b6294..8baceb9f64c5 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -749,17 +749,11 @@ 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),					\
+	if (likely(pd_has_phys_page(pd)))				\
+		__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));\
-})
-
 /*
  * PDE TLBs are a pain to invalidate on GEN8+. When we modify
  * the page table structures, we mark them dirty so that
@@ -840,7 +834,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);
@@ -1381,7 +1375,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);
@@ -1407,7 +1401,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);
@@ -1499,7 +1493,7 @@ static int gen8_preallocate_top_level_pdp(struct i915_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);
 	}
@@ -1511,7 +1505,7 @@ static int gen8_preallocate_top_level_pdp(struct i915_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

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2019-06-14 16:43 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-14 16:43 [PATCH 01/10] drm/i915/gtt: No need to zero the table for page dirs Mika Kuoppala
2019-06-14 16:43 ` [PATCH 02/10] drm/i915/gtt: Use a common type for page directories Mika Kuoppala
2019-06-14 16:56   ` Chris Wilson
2019-06-14 16:43 ` [PATCH 03/10] drm/i915/gtt: Introduce init_pd_with_page Mika Kuoppala
2019-06-14 17:10   ` Chris Wilson
2019-06-14 16:43 ` [PATCH 04/10] drm/i915/gtt: Introduce init_pd Mika Kuoppala
2019-06-14 17:13   ` Chris Wilson
2019-06-14 16:43 ` [PATCH 05/10] drm/i915/gtt: Generalize alloc_pd Mika Kuoppala
2019-06-14 17:17   ` Chris Wilson
2019-06-14 16:43 ` [PATCH 06/10] drm/i915/gtt: pde entry encoding is identical Mika Kuoppala
2019-06-14 17:21   ` Chris Wilson
2019-06-14 16:43 ` Mika Kuoppala [this message]
2019-06-14 17:22   ` [PATCH 07/10] drm/i915/gtt: Check for physical page for pd entry always Chris Wilson
2019-06-14 16:43 ` [PATCH 08/10] drm/i915/gtt: Make swapping the pd entry generic Mika Kuoppala
2019-06-14 17:26   ` Chris Wilson
2019-06-14 16:43 ` [PATCH 09/10] drm/i915/gtt: Tear down setup and cleanup macros for page dma Mika Kuoppala
2019-06-14 17:30   ` Chris Wilson
2019-06-14 16:43 ` [PATCH 10/10] drm/i915/gtt: Setup phys pages for 3lvl pdps Mika Kuoppala
2019-06-14 17:36   ` Chris Wilson
2019-06-14 17:00 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/10] drm/i915/gtt: No need to zero the table for page dirs Patchwork
2019-06-14 17:04 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-06-15  4:59 ` ✓ Fi.CI.BAT: success " Patchwork
2019-06-17 10:32 ` ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190614164350.30415-7-mika.kuoppala@linux.intel.com \
    --to=mika.kuoppala@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox