Skip to contentSkip to conversation

drm/i915: fix vxd392 memory corruption on VLV and >4GB

PATCH In review Sean V Kelley 4 participants 7 messages Mar 8, 2014 – Mar 9, 2014

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

PATCH 1/1 drm/i915: fix vxd392 memory corruption on VLV and >4GB

On VLV systems addressing 4GB of memory or greater, memory corruption was seen when initializing and attempting to render VP8 hardware decode surfaces using the VXD392 HW IP block.

The VXD MMU has a limitation to addressing only 32bits. On 64bit kernel and user space builds this can cause problems for use of that IP block.

When 2G memory is inserted, fw buffer pfn was at 0x5f62b, which is below 4GB. While for 4GB of memory the fw buffer pfn was 0x162ea9 with a physical address at 0x162ea9000, above 4GB.

So although the memory is 4GB in the test hardware (Bayleybay CRB), a large physical region (for example 3G-4G) can be occupied by onboard system resources.

Enabling ZONE_DMA32 and setting the correct mask DMA for this device resolves the issue kernel side.

Cc Jesse Barnes <[email protected]>
Cc Alan Cox <[email protected]>
Cc Fei Jiang <[email protected]>
---
 drivers/gpu/drm/i915/i915_dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_dma.c +1 -1
index e4d2b9f..b8c6efc 100644
@@ -1636,7 +1636,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 	 * behaviour if any general state is accessed within a page above 4GB,
 	 * which also needs to be handled carefully.
 	 */
-	if (IS_BROADWATER(dev) || IS_CRESTLINE(dev))
+	if (IS_BROADWATER(dev) || IS_CRESTLINE(dev) || IS_VALLEYVIEW(dev))
 		dma_set_coherent_mask(&dev->pdev->dev, DMA_BIT_MASK(32));
 
 	aperture_size = dev_priv->gtt.mappable_end;
Signature · 1 line
1.9.0
#1 lore raw
Quoted 11 lines · Sean V Kelley

On VLV systems addressing 4GB of memory or greater, memory corruption was seen when initializing and attempting to render VP8 hardware decode surfaces using the VXD392 HW IP block.

The VXD MMU has a limitation to addressing only 32bits. On 64bit kernel and user space builds this can cause problems for use of that IP block.

When 2G memory is inserted, fw buffer pfn was at 0x5f62b, which is below 4GB. While for 4GB of memory the fw buffer pfn was 0x162ea9 with a physical address at 0x162ea9000, above 4GB.

Quoted 6 lines

So although the memory is 4GB in the test hardware (Bayleybay CRB), a large physical region (for example 3G-4G) can be occupied by onboard system resources.

Enabling ZONE_DMA32 and setting the correct mask DMA for this device resolves the issue kernel side.

That's a shame. I guess this is restricted to a subset of byt?

Quoted 13 lines
Cc Jesse Barnes <[email protected]>
Cc Alan Cox <[email protected]>
Cc Fei Jiang <[email protected]>
---
 drivers/gpu/drm/i915/i915_dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_dma.c +0 -0
index e4d2b9f..b8c6efc 100644

drivers/gpu/drm/i915/i915_dma.c int i915_driver_load(struct drm_device *dev, unsigned long flags) · line 1637

Quoted 2 lines
drivers/gpu/drm/i915/i915_dma.c +0 -0
@@ -1636,7 +1636,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 	 * behaviour if any general state is accessed within a page above 4GB,
 	 * which also needs to be handled carefully.

Also add a sentence here giving a quick explanation as to why we need to quirk IS_VLV as well.

Quoted 6 lines
drivers/gpu/drm/i915/i915_dma.c +1 -1
 	 */
-	if (IS_BROADWATER(dev) || IS_CRESTLINE(dev))
+	if (IS_BROADWATER(dev) || IS_CRESTLINE(dev) || IS_VALLEYVIEW(dev))
 		dma_set_coherent_mask(&dev->pdev->dev, DMA_BIT_MASK(32));
 
 	aperture_size = dev_priv->gtt.mappable_end;
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#2 lore raw
Quoted 40 lines · Chris Wilson
Quoted 11 lines · Sean V Kelley

On VLV systems addressing 4GB of memory or greater, memory corruption was seen when initializing and attempting to render VP8 hardware decode surfaces using the VXD392 HW IP block.

The VXD MMU has a limitation to addressing only 32bits. On 64bit kernel and user space builds this can cause problems for use of that IP block.

When 2G memory is inserted, fw buffer pfn was at 0x5f62b, which is below 4GB. While for 4GB of memory the fw buffer pfn was 0x162ea9 with a physical address at 0x162ea9000, above 4GB.

Quoted 6 lines

So although the memory is 4GB in the test hardware (Bayleybay CRB), a large physical region (for example 3G-4G) can be occupied by onboard system resources.

Enabling ZONE_DMA32 and setting the correct mask DMA for this device resolves the issue kernel side.

That's a shame. I guess this is restricted to a subset of byt?

Quoted 13 lines
Cc Jesse Barnes <[email protected]>
Cc Alan Cox <[email protected]>
Cc Fei Jiang <[email protected]>
---
 drivers/gpu/drm/i915/i915_dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_dma.c +0 -0
index e4d2b9f..b8c6efc 100644

drivers/gpu/drm/i915/i915_dma.c int i915_driver_load(struct drm_device *dev, unsigned long flags) · line 1637

Quoted 2 lines
drivers/gpu/drm/i915/i915_dma.c +0 -0
@@ -1636,7 +1636,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 	 * behaviour if any general state is accessed within a page above 4GB,
 	 * which also needs to be handled carefully.

Also add a sentence here giving a quick explanation as to why we need to quirk IS_VLV as well.

Quoted 4 lines

drivers/gpu/drm/i915/i915_dma.c int i915_driver_load(struct drm_device *dev, unsigned long flags) · line 1640

Quoted 4 lines
drivers/gpu/drm/i915/i915_dma.c +1 -1
 	 */
-	if (IS_BROADWATER(dev) || IS_CRESTLINE(dev))
+	if (IS_BROADWATER(dev) || IS_CRESTLINE(dev) || IS_VALLEYVIEW(dev))
 		dma_set_coherent_mask(&dev->pdev->dev, DMA_BIT_MASK(32));

Nack because:
- the vxd392 isn't merged upstream
- we can allocate shared buffers from vxd392 and have the restriction just there
- for shared buffers allocated in i915 imo the right approach is to move offending pages around when vxd392 attaches - i.e. we need to check the attached device's dma masks and if there's something offending, migrate the buffer with a differen shmem allocation mask. Iirc Alan Cox had patches to do just that (but for swapoff, still the same idea though).

Cheers, Daniel

Quoted 9 lines
Quoted 2 lines
drivers/gpu/drm/i915/i915_dma.c +0 -0
 	aperture_size = dev_priv->gtt.mappable_end;
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#3 lore raw

On Saturday 08 Mar 2014 at 11:07:50 (+0100), Daniel Vetter writes :

Quoted 41 lines · Chris Wilson
Quoted 40 lines · Sean V Kelley
Quoted 11 lines

On VLV systems addressing 4GB of memory or greater, memory corruption was seen when initializing and attempting to render VP8 hardware decode surfaces using the VXD392 HW IP block.

The VXD MMU has a limitation to addressing only 32bits. On 64bit kernel and user space builds this can cause problems for use of that IP block.

When 2G memory is inserted, fw buffer pfn was at 0x5f62b, which is below 4GB. While for 4GB of memory the fw buffer pfn was 0x162ea9 with a physical address at 0x162ea9000, above 4GB.

Quoted 6 lines

So although the memory is 4GB in the test hardware (Bayleybay CRB), a large physical region (for example 3G-4G) can be occupied by onboard system resources.

Enabling ZONE_DMA32 and setting the correct mask DMA for this device resolves the issue kernel side.

That's a shame. I guess this is restricted to a subset of byt?

Quoted 13 lines
Cc Jesse Barnes <[email protected]>
Cc Alan Cox <[email protected]>
Cc Fei Jiang <[email protected]>
---
 drivers/gpu/drm/i915/i915_dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_dma.c +0 -0
index e4d2b9f..b8c6efc 100644

drivers/gpu/drm/i915/i915_dma.c int i915_driver_load(struct drm_device *dev, unsigned long flags) · line 1637

Quoted 2 lines
drivers/gpu/drm/i915/i915_dma.c +0 -0
@@ -1636,7 +1636,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 	 * behaviour if any general state is accessed within a page above 4GB,
 	 * which also needs to be handled carefully.

Also add a sentence here giving a quick explanation as to why we need to quirk IS_VLV as well.

Quoted 7 lines
Quoted 4 lines

drivers/gpu/drm/i915/i915_dma.c int i915_driver_load(struct drm_device *dev, unsigned long flags) · line 1640

Quoted 4 lines
drivers/gpu/drm/i915/i915_dma.c +1 -1
 	 */
-	if (IS_BROADWATER(dev) || IS_CRESTLINE(dev))
+	if (IS_BROADWATER(dev) || IS_CRESTLINE(dev) || IS_VALLEYVIEW(dev))
 		dma_set_coherent_mask(&dev->pdev->dev, DMA_BIT_MASK(32));

Nack because:
- the vxd392 isn't merged upstream

Sure, I just wanted to get some feedback. Yeah, in it's current state my driver port will not be acceptable upstream until I cleanup the deprecated API from the driver, remove my wrappers/hooks from the i915, and make similar API changes to the user mode driver. That is a work-in-progress for me now.

Quoted 7 lines

- we can allocate shared buffers from vxd392 and have the restriction just there
- for shared buffers allocated in i915 imo the right approach is to move offending pages around when vxd392 attaches - i.e. we need to check the attached device's dma masks and if there's something offending, migrate the buffer with a differen shmem allocation mask. Iirc Alan Cox had patches to do just that (but for swapoff, still the same idea though).

Will keep that in mind. I have been getting some feedback from Alan too.

Thanks,

Sean

Quoted 16 lines

Cheers, Daniel

Quoted 9 lines
Quoted 2 lines
drivers/gpu/drm/i915/i915_dma.c +0 -0
 	aperture_size = dev_priv->gtt.mappable_end;
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw
In reply to Daniel Vetter
Quoted 4 lines

offending pages around when vxd392 attaches - i.e. we need to check the attached device's dma masks and if there's something offending, migrate the buffer with a differen shmem allocation mask. Iirc Alan Cox had patches to do just that (but for swapoff, still the same idea though).

The shmemfs code knows about this for GEM (and anything else it backs). My only credit is finding the problem, I didn't do the fixing!

Alan

#5 lore raw
In reply to Chris Wilson

On Saturday 08 Mar 2014 at 09:25:54 (+0000), Chris Wilson writes :

Quoted 12 lines · Sean V Kelley
Quoted 11 lines

On VLV systems addressing 4GB of memory or greater, memory corruption was seen when initializing and attempting to render VP8 hardware decode surfaces using the VXD392 HW IP block.

The VXD MMU has a limitation to addressing only 32bits. On 64bit kernel and user space builds this can cause problems for use of that IP block.

When 2G memory is inserted, fw buffer pfn was at 0x5f62b, which is below 4GB. While for 4GB of memory the fw buffer pfn was 0x162ea9 with a physical address at 0x162ea9000, above 4GB.

Quoted 8 lines
Quoted 6 lines

So although the memory is 4GB in the test hardware (Bayleybay CRB), a large physical region (for example 3G-4G) can be occupied by onboard system resources.

Enabling ZONE_DMA32 and setting the correct mask DMA for this device resolves the issue kernel side.

That's a shame. I guess this is restricted to a subset of byt?

It should affect all baytrail systems. To my knowledge there are no subsets that have it fused off.

Quoted 9 lines
Quoted 9 lines
Cc Jesse Barnes <[email protected]>
Cc Alan Cox <[email protected]>
Cc Fei Jiang <[email protected]>
---
 drivers/gpu/drm/i915/i915_dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 10 lines

drivers/gpu/drm/i915/i915_dma.c int i915_driver_load(struct drm_device *dev, unsigned long flags) · line 1637

Quoted 7 lines
drivers/gpu/drm/i915/i915_dma.c +0 -0
index e4d2b9f..b8c6efc 100644
@@ -1636,7 +1636,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
 	 * behaviour if any general state is accessed within a page above 4GB,
 	 * which also needs to be handled carefully.

Also add a sentence here giving a quick explanation as to why we need to quirk IS_VLV as well.

Thanks for the feedback also going through Daniel's.

Sean

Quoted 10 lines
Quoted 7 lines
drivers/gpu/drm/i915/i915_dma.c +1 -1
 	 */
-	if (IS_BROADWATER(dev) || IS_CRESTLINE(dev))
+	if (IS_BROADWATER(dev) || IS_CRESTLINE(dev) || IS_VALLEYVIEW(dev))
 		dma_set_coherent_mask(&dev->pdev->dev, DMA_BIT_MASK(32));
 
 	aperture_size = dev_priv->gtt.mappable_end;
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw
Quoted 17 lines · Sean V Kelley

On Saturday 08 Mar 2014 at 09:25:54 (+0000), Chris Wilson writes :

Quoted 16 lines · Sean V Kelley
Quoted 15 lines

On VLV systems addressing 4GB of memory or greater, memory corruption was seen when initializing and attempting to render VP8 hardware decode surfaces using the VXD392 HW IP block.

The VXD MMU has a limitation to addressing only 32bits. On 64bit kernel and user space builds this can cause problems for use of that IP block.

When 2G memory is inserted, fw buffer pfn was at 0x5f62b, which is below 4GB. While for 4GB of memory the fw buffer pfn was 0x162ea9 with a physical address at 0x162ea9000, above 4GB.

So although the memory is 4GB in the test hardware (Bayleybay CRB), a large physical region (for example 3G-4G) can be occupied by onboard system resources.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Enabling ZONE_DMA32 and setting the correct mask DMA for this device resolves the issue kernel side.

That's a shame. I guess this is restricted to a subset of byt?

It should affect all baytrail systems. To my knowledge there are no subsets that have it fused off.

This is in the gross hacks department but what happens if you set the VXD to DMA to GTT translated addresses, does it see the memory directly or via the GTT translations ?

Alan