v5: ILK vt-d fix, more like v3 now
Subsystems (4)
cover v5: ILK vt-d fix, more like v3 now
I think Daniel caved in and agrees that making the idle cause the GPU to be uninterruptible was the correct approach. So this patch is pretty much the same as v3, except it has David's new global to determine the IOMMU status. In other words, disregard v4.
For the series:
Ben Widawsky (2):
drm/i915: Remove early exit on i915_gpu_idle
drm/i915: ILK + VT-d workaround
David Woodhouse (2):
intel-iommu: Workaround IOTLB hang on Ironlake GPU
intel-iommu: Export a flag indicating that the IOMMU is used for
iGFX.
drivers/char/agp/intel-gtt.c | 28 ++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_gem.c | 6 ------ drivers/gpu/drm/i915/i915_gem_gtt.c | 30 ++++++++++++++++++++++++++++++ drivers/iommu/intel-iommu.c | 31 ++++++++++++++++++++----------- include/drm/intel-gtt.h | 2 ++ 5 files changed, 80 insertions(+), 17 deletions(-)
Signature · 1 line
1.7.7
PATCH 1/4 intel-iommu: Workaround IOTLB hang on Ironlake GPU
From: David Woodhouse <[email protected]>
To work around a hardware issue, we have to submit IOTLB flushes while the graphics engine is idle. The graphics driver will (we hope) go to great lengths to ensure that it gets that right on the affected chipset(s)... so let's not screw it over by deferring the unmap and doing it later. That wouldn't be very helpful.
--- drivers/iommu/intel-iommu.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/iommu/intel-iommu.c +5 -1
@@ -3950,7 +3950,11 @@ static void __devinit quirk_calpella_no_shadow_gtt(struct pci_dev *dev)if (!(ggc &GGC_MEMORY_VT_ENABLED )) {printk (KERN_INFO "DMAR: BIOS has allocated no shadow GTT; disabling IOMMU for graphics\n" ); dmar_map_gfx =0 ; - } + }else if (dmar_map_gfx) { +/* we have to ensure the gfx device is idle before we flush */ +printk (KERN_INFO "DMAR: Disabling batched IOTLB flush on Ironlake\n" ); + intel_iommu_strict =1 ; + } }DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_INTEL ,0x0040 , quirk_calpella_no_shadow_gtt);DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_INTEL ,0x0044 , quirk_calpella_no_shadow_gtt);
Signature · 1 line
1.7.7
PATCH 2/4 intel-iommu: Export a flag indicating that the IOMMU is used for iGFX.
In reply to Ben WidawskyFrom: David Woodhouse <[email protected]>
We really don't want this to work in the general case; device drivers *shouldn't* care whether they are behind an IOMMU or not. But the integrated graphics is a special case, because the IOMMU and the GTT are all kind of smashed into one and generally horrifically buggy, so it's reasonable for the graphics driver to want to know when the IOMMU is active for the graphics hardware.
--- drivers/iommu/intel-iommu.c | 25 +++++++++++++++---------- 1 files changed, 15 insertions(+), 10 deletions(-)
drivers/iommu/intel-iommu.c +15 -10
@@ -404,6 +404,9 @@ static int dmar_forcedac;static int intel_iommu_strict;static int intel_iommu_superpage =1 ; +int intel_iommu_gfx_mapped; +EXPORT_SYMBOL_GPL (intel_iommu_gfx_mapped); +#define DUMMY_DEVICE_DOMAIN_INFO ((struct device_domain_info *)(-1))static DEFINE_SPINLOCK (device_domain_lock);static LIST_HEAD (device_domain_list);
@@ -3226,9 +3229,6 @@ static void __init init_no_remapping_devices(void) } } -if (dmar_map_gfx) -return ; -for_each_drhd_unit (drhd) {int i;if (drhd->ignored || drhd->include_all)
@@ -3236,18 +3236,23 @@ static void __init init_no_remapping_devices(void)for (i =0 ; i < drhd->devices_cnt; i++)if (drhd->devices[i] && - !IS_GFX_DEVICE (drhd->devices[i])) + !IS_GFX_DEVICE (drhd->devices[i]))break ;if (i < drhd->devices_cnt)continue ; -/* bypass IOMMU if it is just for gfx devices */ - drhd->ignored =1 ; -for (i =0 ; i < drhd->devices_cnt; i++) { -if (!drhd->devices[i]) -continue ; - drhd->devices[i]->dev.archdata.iommu =DUMMY_DEVICE_DOMAIN_INFO ; +/* This IOMMU has *only* gfx devices. Either bypass it or +set the gfx_mapped flag, as appropriate */ +if (dmar_map_gfx) { + intel_iommu_gfx_mapped =1 ; + }else { + drhd->ignored =1 ; +for (i =0 ; i < drhd->devices_cnt; i++) { +if (!drhd->devices[i]) +continue ; + drhd->devices[i]->dev.archdata.iommu =DUMMY_DEVICE_DOMAIN_INFO ; + } } } }
Signature · 1 line
1.7.7
PATCH 3/4 drm/i915: Remove early exit on i915_gpu_idle
In reply to Ben Widawsky[Description from: Daniel Vetter]
I've just discussed this quickly with Chris on irc and it's probably best to just kill the list_empty early bailout. gpu_idle isn't a fastpath, so who cares. One candidate where we emit commands to the ring without adding anything onto these lists is e.g. pageflip. There are probably more.
--- drivers/gpu/drm/i915/i915_gem.c | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +0 -6
@@ -2191,14 +2191,8 @@ int i915_gpu_idle(struct drm_device *dev) {drm_i915_private_t *dev_priv = dev->dev_private; -bool lists_empty;int ret, i; - lists_empty = (list_empty (&dev_priv->mm.flushing_list) && -list_empty (&dev_priv->mm.active_list)); -if (lists_empty) -return 0 ; -/* Flush everything onto the inactive list. */ for (i =0 ; i <I915_NUM_RINGS ; i++) { ret =i915_ring_idle (&dev_priv->ring[i]);
Signature · 1 line
1.7.7
PATCH 4/4 drm/i915: ILK + VT-d workaround
In reply to Ben WidawskyIdle the GPU before doing any unmaps. We know if VT-d is in use through an exported variable from iommu code.
This should avoid a known HW issue.
--- drivers/char/agp/intel-gtt.c | 28 ++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_gem_gtt.c | 30 ++++++++++++++++++++++++++++++ include/drm/intel-gtt.h | 2 ++ 3 files changed, 60 insertions(+), 0 deletions(-)
drivers/char/agp/intel-gtt.c +28 -0
@@ -923,6 +923,9 @@ static int intel_fake_agp_insert_entries(struct agp_memory *mem, {int ret = -EINVAL ; +if (intel_private.base.do_idle_maps) +return -ENODEV ; +if (intel_private.clear_fake_agp) {int start = intel_private.base.stolen_size /PAGE_SIZE ;int end = intel_private.base.gtt_mappable_entries;
@@ -985,6 +988,9 @@ static int intel_fake_agp_remove_entries(struct agp_memory *mem,if (mem->page_count ==0 )return 0 ; +if (intel_private.base.do_idle_maps) +return -ENODEV ; +intel_gtt_clear_range (pg_start, mem->page_count);if (intel_private.base.needs_dmar) {
@@ -1177,6 +1183,25 @@ static void gen6_cleanup(void) { } +/* Certain Gen5 chipsets require require idling the GPU before +* unmapping anything from the GTT when VT-d is enabled. +*/ +extern int intel_iommu_gfx_mapped; +static inline int needs_idle_maps (void ) +{ +const unsigned short gpu_devid = intel_private.pcidev->device; + +/* Query intel_iommu to see if we need the workaround. Presumably that +* was loaded first. +*/ +if ((gpu_devid ==PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB || + gpu_devid ==PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG ) && + intel_iommu_gfx_mapped) +return 1 ; + +return 0 ; +} +static int i9xx_setup (void ) {u32 reg_addr;
@@ -1211,6 +1236,9 @@ static int i9xx_setup(void) intel_private.gtt_bus_addr = reg_addr + gtt_offset; } +if (needs_idle_maps ()); + intel_private.base.do_idle_maps =1 ; +intel_i9xx_setup_flush ();return 0 ;
drivers/gpu/drm/i915/i915_gem_gtt.c +30 -0
@@ -49,6 +49,28 @@ static unsigned int cache_level_to_agp_type(struct drm_device *dev, } } +static bool do_idling (struct drm_i915_private *dev_priv) +{ +bool ret = dev_priv->mm.interruptible; + +if (unlikely (dev_priv->mm.gtt->do_idle_maps)) { + dev_priv->mm.interruptible = false; +if (i915_gpu_idle (dev_priv->dev)) { +DRM_ERROR ("Couldn't idle GPU\n" ); +/* Wait a bit, in hopes it avoids the hang */ +udelay (10 ); + } + } + +return ret; +} + +static void undo_idling (struct drm_i915_private *dev_priv,bool interruptible) +{ +if (unlikely (dev_priv->mm.gtt->do_idle_maps)) + dev_priv->mm.interruptible = interruptible; +} +void i915_gem_restore_gtt_mappings (struct drm_device *dev) {struct drm_i915_private *dev_priv = dev->dev_private;
@@ -117,6 +139,12 @@ void i915_gem_gtt_rebind_object(struct drm_i915_gem_object *obj,void i915_gem_gtt_unbind_object (struct drm_i915_gem_object *obj) { +struct drm_device *dev = obj->base.dev; +struct drm_i915_private *dev_priv = dev->dev_private; +bool interruptible; + + interruptible =do_idling (dev_priv); +intel_gtt_clear_range (obj->gtt_space->start >>PAGE_SHIFT , obj->base.size >>PAGE_SHIFT );
@@ -124,4 +152,6 @@ void i915_gem_gtt_unbind_object(struct drm_i915_gem_object *obj)intel_gtt_unmap_memory (obj->sg_list, obj->num_sg); obj->sg_list =NULL ; } + +undo_idling (dev_priv, interruptible); }
include/drm/intel-gtt.h +2 -0
@@ -13,6 +13,8 @@ const struct intel_gtt {unsigned int gtt_mappable_entries;/* Whether i915 needs to use the dmar apis or not. */ unsigned int needs_dmar : 1; +/* Whether we idle the gpu before mapping/unmapping */ + unsigned int do_idle_maps : 1; } *intel_gtt_get (void);void intel_gtt_chipset_flush (void );
Signature · 1 line
1.7.7
Re: [PATCH 4/4] drm/i915: ILK + VT-d workaround
Am Montag, den 17.10.2011, 15:51 -0700 schrieb Ben Widawsky:
Quoted 4 lines
Idle the GPU before doing any unmaps. We know if VT-d is in use through an exported variable from iommu code.
This should avoid a known HW issue.
Please describe the issue more in detail or provide a link to more information.
Quoted 6 lines
Signed-off-by Ben Widawsky <[email protected]>--- drivers/char/agp/intel-gtt.c | 28 ++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_gem_gtt.c | 30 ++++++++++++++++++++++++++++++ include/drm/intel-gtt.h | 2 ++ 3 files changed, 60 insertions(+), 0 deletions(-)
[…]
Thanks,
Paul
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/4] drm/i915: ILK + VT-d workaround
Quoted 16 lines · On Tue, 18 Oct 2011 09:24:41 +0200 Paul Menzel…
Am Montag, den 17.10.2011, 15:51 -0700 schrieb Ben Widawsky:
Quoted 4 lines
Idle the GPU before doing any unmaps. We know if VT-d is in use through an exported variable from iommu code.
This should avoid a known HW issue.
Please describe the issue more in detail or provide a link to more information.
Quoted 6 lines
Signed-off-by Ben Widawsky <[email protected]>--- drivers/char/agp/intel-gtt.c | 28 ++++++++++++++++++++++++++++ drivers/gpu/drm/i915/i915_gem_gtt.c | 30 ++++++++++++++++++++++++++++++ include/drm/intel-gtt.h | 2 ++ 3 files changed, 60 insertions(+), 0 deletions(-)
Quoted 6 lines
[…]
Thanks,
Paul
Please see patch 1 and 2 in the series for the description.
_______________________________________________
Intel-gfx mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/4] drm/i915: ILK + VT-d workaround
In reply to Ben WidawskyQuoted 7 lines · Ben Widawsky
Idle the GPU before doing any unmaps. We know if VT-d is in use through an exported variable from iommu code.
This should avoid a known HW issue.
Signed-off-by Ben Widawsky <[email protected]>---
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48