[patch 06/39] Fix Intel IOMMU write-buffer flushing

From: Greg KH
Date: Wed Feb 18 2009 - 16:37:55 EST


2.6.28-stable review patch. If anyone has any objections, please let us know.

------------------

From: David Woodhouse <dwmw2@xxxxxxxxxxxxx>

commit ca77fde8e62cecb2c0769052228d15b901367af8 upstream.

This is the cause of the DMA faults and disk corruption that people have
been seeing. Some chipsets neglect to report the RWBF "capability" --
the flag which says that we need to flush the chipset write-buffer when
changing the DMA page tables, to ensure that the change is visible to
the IOMMU.

Override that bit on the affected chipsets, and everything is happy
again.

Thanks to Chris and Bhavesh and others for helping to debug.

Signed-off-by: David Woodhouse <David.Woodhouse@xxxxxxxxx>
Tested-by: Chris Wright <chrisw@xxxxxxxxxxxx>
Reviewed-by: Bhavesh Davda <bhavesh@xxxxxxxxxx>
Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

---
drivers/pci/intel-iommu.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -506,7 +506,7 @@ static void iommu_flush_write_buffer(str
u32 val;
unsigned long flag;

- if (!cap_rwbf(iommu->cap))
+ if (!rwbf_quirk && !cap_rwbf(iommu->cap))
return;
val = iommu->gcmd | DMA_GCMD_WBF;

@@ -1315,6 +1315,8 @@ static void domain_remove_dev_info(struc
spin_unlock_irqrestore(&device_domain_lock, flags);
}

+static int rwbf_quirk = 0;
+
/*
* find_domain
* Note: we use struct pci_dev->dev.archdata.iommu stores the info
@@ -2436,3 +2438,13 @@ u64 intel_iommu_iova_to_pfn(struct dmar_
return pfn >> VTD_PAGE_SHIFT;
}
EXPORT_SYMBOL_GPL(intel_iommu_iova_to_pfn);
+
+static void __devinit quirk_iommu_rwbf(struct pci_dev *dev)
+{
+ /* Mobile 4 Series Chipset neglects to set RWBF capability,
+ but needs it */
+ printk(KERN_INFO "DMAR: Forcing write-buffer flush capability\n");
+ rwbf_quirk = 1;
+}
+
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_rwbf);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/