Skip to contentSkip to conversation

drm/i915: Fix pte updates in ggtt clear range

PATCH In review Ben Widawsky 2 participants 5 messages Nov 27, 2012 – Nov 28, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Fix pte updates in ggtt clear range

This bug was introduced by me:
commit e76e9aebcdbfebae8f4cd147e3c0f800d36e97f3

Author: Ben Widawsky <[email protected]>
Date:   Sun Nov 4 09:21:27 2012 -0800

drm/i915: Stop using AGP layer for GEN6+

The existing code uses memset_io which follows memset semantics in only guaranteeing a write of individual bytes. Since a PTE entry is 4 bytes, this can only be correct if the scratch page address is 0.

This caused unsightly errors when we clear the range at load time, though I'm not really sure what the heck is referencing that memory anyway. I caught this is because I believe we have some other bug where the display is doing reads of memory we feel should be cleared (or we are relying on scratch pages to be a specific value).

---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +4 -2
index 51f79bb..f7ac61e 100644
@@ -367,8 +367,9 @@ static void i915_ggtt_clear_range(struct drm_device *dev,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	gtt_pte_t scratch_pte;
-	volatile void __iomem *gtt_base = dev_priv->mm.gtt->gtt + first_entry;
+	gtt_pte_t __iomem *gtt_base = dev_priv->mm.gtt->gtt + first_entry;
 	const int max_entries = dev_priv->mm.gtt->gtt_total_entries - first_entry;
+	int i;
 
 	if (INTEL_INFO(dev)->gen < 6) {
 		intel_gtt_clear_range(first_entry, num_entries);
@@ -381,7 +382,8 @@ static void i915_ggtt_clear_range(struct drm_device *dev,
 		num_entries = max_entries;
 
 	scratch_pte = pte_encode(dev, dev_priv->mm.gtt->scratch_page_dma, I915_CACHE_LLC);
-	memset_io(gtt_base, scratch_pte, num_entries * sizeof(scratch_pte));
+	for (i = 0; i < num_entries; i++)
+		iowrite32(scratch_pte, &gtt_base[i]);
 	readl(gtt_base);
 }
 
Signature · 1 line
1.8.0.1
#1 lore raw
Quoted 10 lines · Ben Widawsky

This bug was introduced by me:
commit e76e9aebcdbfebae8f4cd147e3c0f800d36e97f3

Author: Ben Widawsky <[email protected]>
Date:   Sun Nov 4 09:21:27 2012 -0800

drm/i915: Stop using AGP layer for GEN6+

The existing code uses memset_io which follows memset semantics in only guaranteeing a write of individual bytes. Since a PTE entry is 4 bytes, this can only be correct if the scratch page address is 0.

Gah. Wasn't there an iowrite32_rep?

Quoted 5 lines

This caused unsightly errors when we clear the range at load time, though I'm not really sure what the heck is referencing that memory anyway. I caught this is because I believe we have some other bug where the display is doing reads of memory we feel should be cleared (or we are relying on scratch pages to be a specific value).

That's just because we are no longer disabling outputs before updating the GTT and hence continue to scanout from the BIOS fb during module load. It's a regression that we'll be able to finally fix properly with fastboot - though that will not be without its downsides either. -Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#2 lore raw
Quoted 7 lines · On Tue, 27 Nov 2012 08:22:01 +0000 Chris Wilson <[email protected]>…
Quoted 5 lines · Ben Widawsky

This bug was introduced by me:
commit e76e9aebcdbfebae8f4cd147e3c0f800d36e97f3

Author: Ben Widawsky <[email protected]>
Date:   Sun Nov 4 09:21:27 2012 -0800
Quoted 7 lines
Quoted 5 lines

drm/i915: Stop using AGP layer for GEN6+

The existing code uses memset_io which follows memset semantics in only guaranteeing a write of individual bytes. Since a PTE entry is 4 bytes, this can only be correct if the scratch page address is 0.

Gah. Wasn't there an iowrite32_rep?

And you would hope it does what you want... but it seems like just a memcpy of dword sized chunks.

My first thought was to write my own memset which does what you want, but this seemed like a path of less resistance.

Quoted 13 lines
Quoted 6 lines

This caused unsightly errors when we clear the range at load time, though I'm not really sure what the heck is referencing that memory anyway. I caught this is because I believe we have some other bug where the display is doing reads of memory we feel should be cleared (or we are relying on scratch pages to be a specific value).

That's just because we are no longer disabling outputs before updating the GTT and hence continue to scanout from the BIOS fb during module load. It's a regression that we'll be able to finally fix properly with fastboot - though that will not be without its downsides either. -Chris

Reviewed-by
#3 lore raw
Quoted 12 lines · Ben Widawsky
Quoted 9 lines · On Tue, 27 Nov 2012 08:22:01 +0000 Chris Wilson <[email protected]>…
Quoted 7 lines · Ben Widawsky

This bug was introduced by me:
commit e76e9aebcdbfebae8f4cd147e3c0f800d36e97f3

Author: Ben Widawsky <[email protected]>
Date:   Sun Nov 4 09:21:27 2012 -0800

drm/i915: Stop using AGP layer for GEN6+

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

The existing code uses memset_io which follows memset semantics in only guaranteeing a write of individual bytes. Since a PTE entry is 4 bytes, this can only be correct if the scratch page address is 0.

Gah. Wasn't there an iowrite32_rep?

And you would hope it does what you want... but it seems like just a memcpy of dword sized chunks.

I feel suitably embarassed at missing it the first time, especially as we've had similar conversations in the past.

-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#4 lore raw
In reply to Ben Widawsky
Quoted 38 lines · On Mon, 26 Nov 2012 21:52:54 -0800 Ben Widawsky <[email protected]> wrote:

This bug was introduced by me:
commit e76e9aebcdbfebae8f4cd147e3c0f800d36e97f3

Author: Ben Widawsky <[email protected]>
Date:   Sun Nov 4 09:21:27 2012 -0800

drm/i915: Stop using AGP layer for GEN6+

The existing code uses memset_io which follows memset semantics in only guaranteeing a write of individual bytes. Since a PTE entry is 4 bytes, this can only be correct if the scratch page address is 0.

This caused unsightly errors when we clear the range at load time, though I'm not really sure what the heck is referencing that memory anyway. I caught this is because I believe we have some other bug where the display is doing reads of memory we feel should be cleared (or we are relying on scratch pages to be a specific value).

---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_gem_gtt.c +2 -1
index 51f79bb..f7ac61e 100644
@@ -367,8 +367,9 @@ static void i915_ggtt_clear_range(struct drm_device *dev,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	gtt_pte_t scratch_pte;
-	volatile void __iomem *gtt_base = dev_priv->mm.gtt->gtt + first_entry;
+	gtt_pte_t __iomem *gtt_base = dev_priv->mm.gtt->gtt + first_entry;
 	const int max_entries = dev_priv->mm.gtt->gtt_total_entries - first_entry;
+	int i;
 
 	if (INTEL_INFO(dev)->gen < 6) {
 		intel_gtt_clear_range(first_entry, num_entries);

drivers/gpu/drm/i915/i915_gem_gtt.c static void i915_ggtt_clear_range(struct drm_device *dev, · line 389

Quoted 9 lines
drivers/gpu/drm/i915/i915_gem_gtt.c +2 -1
@@ -381,7 +382,8 @@ static void i915_ggtt_clear_range(struct drm_device *dev,
 		num_entries = max_entries;
 
 	scratch_pte = pte_encode(dev, dev_priv->mm.gtt->scratch_page_dma, I915_CACHE_LLC);
-	memset_io(gtt_base, scratch_pte, num_entries * sizeof(scratch_pte));
+	for (i = 0; i < num_entries; i++)
+		iowrite32(scratch_pte, &gtt_base[i]);
 	readl(gtt_base);
 }
 

"This has been slurped into -queued. Thanks for the patch" - or something like that.

Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center