intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/i915/gtt: Fix pte clear range
@ 2016-10-31 15:24 Mika Kuoppala
  2016-10-31 15:24 ` [PATCH 2/2] drm/i915/gtt: Mark tlbs dirty on clear Mika Kuoppala
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Mika Kuoppala @ 2016-10-31 15:24 UTC (permalink / raw)
  To: intel-gfx

Comparing pte index to a number of entries is wrong
when clearing a range of pte entries. Use end marker
of 'one past' to correctly point adequate number of
ptes to the scratch page.

Fixes: d209b9c3cd28 ("drm/i915/gtt: Split gen8_ppgtt_clear_pte_range")
References: https://bugs.freedesktop.org/show_bug.cgi?id=98282
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Michel Thierry <michel.thierry@intel.com>
Cc: Michał Winiarski <michal.winiarski@intel.com>
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index e7afad5..cda263c 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -712,13 +712,13 @@ static int gen8_48b_mm_switch(struct i915_hw_ppgtt *ppgtt,
  */
 static bool gen8_ppgtt_clear_pt(struct i915_address_space *vm,
 				struct i915_page_table *pt,
-				uint64_t start,
-				uint64_t length)
+				const uint64_t start,
+				const uint64_t length)
 {
 	struct i915_hw_ppgtt *ppgtt = i915_vm_to_ppgtt(vm);
-	unsigned int pte_start = gen8_pte_index(start);
-	unsigned int num_entries = gen8_pte_count(start, length);
-	uint64_t pte;
+	const unsigned int num_entries = gen8_pte_count(start, length);
+	unsigned int pte = gen8_pte_index(start);
+	unsigned int pte_end = pte + num_entries;
 	gen8_pte_t *pt_vaddr;
 	gen8_pte_t scratch_pte = gen8_pte_encode(vm->scratch_page.daddr,
 						 I915_CACHE_LLC);
@@ -726,17 +726,20 @@ static bool gen8_ppgtt_clear_pt(struct i915_address_space *vm,
 	if (WARN_ON(!px_page(pt)))
 		return false;
 
-	bitmap_clear(pt->used_ptes, pte_start, num_entries);
+	bitmap_clear(pt->used_ptes, pte, num_entries);
 
 	if (bitmap_empty(pt->used_ptes, GEN8_PTES)) {
 		free_pt(vm->dev, pt);
 		return true;
 	}
 
+	if (WARN_ON_ONCE(pte_end > GEN8_PTES))
+		pte_end = GEN8_PTES;
+
 	pt_vaddr = kmap_px(pt);
 
-	for (pte = pte_start; pte < num_entries; pte++)
-		pt_vaddr[pte] = scratch_pte;
+	while (pte < pte_end)
+		pt_vaddr[pte++] = scratch_pte;
 
 	kunmap_px(ppgtt, pt_vaddr);
 
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-11-02  9:29 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-31 15:24 [PATCH 1/2] drm/i915/gtt: Fix pte clear range Mika Kuoppala
2016-10-31 15:24 ` [PATCH 2/2] drm/i915/gtt: Mark tlbs dirty on clear Mika Kuoppala
2016-10-31 15:49   ` Chris Wilson
2016-10-31 15:58     ` Mika Kuoppala
2016-10-31 17:14       ` Chris Wilson
2016-10-31 15:42 ` [PATCH 1/2] drm/i915/gtt: Fix pte clear range Chris Wilson
2016-10-31 15:46 ` ✗ Fi.CI.BAT: warning for series starting with [1/2] " Patchwork
2016-10-31 15:55 ` [PATCH 1/2] " Mika Kuoppala
2016-11-01  8:19   ` Joonas Lahtinen
2016-11-01 10:22     ` Mika Kuoppala
2016-11-01 10:28       ` Chris Wilson
2016-10-31 16:16 ` ✗ Fi.CI.BAT: warning for series starting with [1/2] drm/i915/gtt: Fix pte clear range (rev2) Patchwork
2016-11-01 13:27 ` [PATCH 1/2] drm/i915/gtt: Fix pte clear range Mika Kuoppala
2016-11-02  9:29   ` Joonas Lahtinen
2016-11-01 15:46 ` ✗ Fi.CI.BAT: warning for series starting with [1/2] drm/i915/gtt: Fix pte clear range (rev3) Patchwork
2016-11-01 16:28   ` Mika Kuoppala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).