浏览代码

Intel IOMMU: Iommu floppy workaround

This config option (DMAR_FLPY_WA) sets up 1:1 mapping for the floppy device so
that the floppy device which does not use DMA api's will continue to work.

Once the floppy driver starts using DMA api's this config option can be turn
off or this patch can be yanked out of kernel at that time.

[akpm@linux-foundation.org: cleanups, rename things, build fix]
[jengelh@computergmbh.de: Kconfig fixes]
Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Cc: Andi Kleen <ak@suse.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Muli Ben-Yehuda <muli@il.ibm.com>
Cc: "Siddha, Suresh B" <suresh.b.siddha@intel.com>
Cc: Arjan van de Ven <arjan@infradead.org>
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Christoph Lameter <clameter@sgi.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Jan Engelhardt <jengelh@gmx.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Keshavamurthy, Anil S 17 年之前
父节点
当前提交
49a0429e53
共有 2 个文件被更改,包括 37 次插入0 次删除
  1. 10 0
      arch/x86_64/Kconfig
  2. 27 0
      drivers/pci/intel-iommu.c

+ 10 - 0
arch/x86_64/Kconfig

@@ -772,6 +772,16 @@ config DMAR_GFX_WA
 	 all the OS-visible memory. Hence the driver can continue
 	 all the OS-visible memory. Hence the driver can continue
 	 to use physical addresses for DMA.
 	 to use physical addresses for DMA.
 
 
+config DMAR_FLOPPY_WA
+	bool
+	depends on DMAR
+	default y
+	help
+	 Floppy disk drivers are know to bypass DMA API calls
+	 thereby failing to work when IOMMU is enabled. This
+	 workaround will setup a 1:1 mapping for the first
+	 16M to make floppy (an ISA device) work.
+
 source "drivers/pci/pcie/Kconfig"
 source "drivers/pci/pcie/Kconfig"
 
 
 source "drivers/pci/Kconfig"
 source "drivers/pci/Kconfig"

+ 27 - 0
drivers/pci/intel-iommu.c

@@ -1632,6 +1632,31 @@ error:
 }
 }
 #endif
 #endif
 
 
+#ifdef CONFIG_DMAR_FLOPPY_WA
+static inline void iommu_prepare_isa(void)
+{
+	struct pci_dev *pdev;
+	int ret;
+
+	pdev = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL);
+	if (!pdev)
+		return;
+
+	printk(KERN_INFO "IOMMU: Prepare 0-16M unity mapping for LPC\n");
+	ret = iommu_prepare_identity_map(pdev, 0, 16*1024*1024);
+
+	if (ret)
+		printk("IOMMU: Failed to create 0-64M identity map, "
+			"floppy might not work\n");
+
+}
+#else
+static inline void iommu_prepare_isa(void)
+{
+	return;
+}
+#endif /* !CONFIG_DMAR_FLPY_WA */
+
 int __init init_dmars(void)
 int __init init_dmars(void)
 {
 {
 	struct dmar_drhd_unit *drhd;
 	struct dmar_drhd_unit *drhd;
@@ -1697,6 +1722,8 @@ int __init init_dmars(void)
 
 
 	iommu_prepare_gfx_mapping();
 	iommu_prepare_gfx_mapping();
 
 
+	iommu_prepare_isa();
+
 	/*
 	/*
 	 * for each drhd
 	 * for each drhd
 	 *   enable fault log
 	 *   enable fault log