Skip to contentSkip to conversation

x86-64: Calgary IOMMU - Calgary specific bits

PATCH In review Jon Mason 1 participant 1 message May 25, 2006 Documentation

lore
Share & tools
lore

Jon Mason

author
#0 lore raw

PATCH 4/4 x86-64: Calgary IOMMU - Calgary specific bits

This patch hooks Calgary into the build, the x86-64 IOMMU initialization paths, and introduces the Calgary specific bits. The implementation draws inspiration from both PPC (which has support for the same chip but requires firmware support which we don't have on x86-64) and gart. Calgary is different from gart in that it support a translation table per PHB, as opposed to the single gart aperture.

Changes from previous version:
* Addition of boot-time disablement for bus-level translation/isolation (e.g, enable userspace DMA for things like X)
* Usage of newer IOMMU abstraction functions

Documentation/x86_64/boot-options.txt +20 -0
diff -r 688a6a25478b Documentation/x86_64/boot-options.txt
@@ -205,6 +205,26 @@ IOMMU
   pages  Prereserve that many 128K pages for the software IO bounce buffering.
   force  Force all IO through the software TLB.
 
+  calgary=[64k,128k,256k,512k,1M,2M,4M,8M]
+  calgary=[translate_empty_slots,translate_phb0]
+
+    64k,...,8M - Set the size of each PCI slot's translation table
+    when using the Calgary IOMMU. This is the size of the translation
+    table itself in main memory. The smallest table, 64k, covers an IO
+    space of 32MB; the largest, 8MB table, can cover an IO space of
+    4GB. Normally the kernel will make the right choice by itself.
+
+    translate_empty_slots - Enable translation even on slots that have
+    no devices attached to them, in case a device will be hotplugged
+    in the future.
+
+    disable=<PCI bus number> - Disable translation on a given PHB. For
+    example, the built-in graphics adapter resides on the first bridge
+    (PCI bus number 0); if translation (isolation) is enabled on this
+    bridge, X servers that access the hardware directly from user
+    space might stop working. Use this option if you have devices that
+    are accessed from userspace directly on some PCI host bridge.
+
 Debugging
 
   oops=panic Always panic on oopses. Default is to just kill the process,
arch/x86_64/Kconfig +19 -0
diff -r 688a6a25478b arch/x86_64/Kconfig
@@ -401,6 +401,25 @@ config GART_IOMMU
   	  northbridge and a software emulation used on other systems without
 	  hardware IOMMU.  If unsure, say Y.
 
+config CALGARY_IOMMU
+	bool "IBM Calgary IOMMU support"
+	default y
+	select SWIOTLB
+	depends on PCI && EXPERIMENTAL
+	help
+	  Support for hardware IOMMUs in IBM's xSeries x366 and x460
+	  systems. Needed to run systems with more than 3GB of memory
+	  properly with 32-bit PCI devices that do not support DAC
+	  (Double Address Cycle). Calgary also supports bus level 
+	  isolation, where all DMAs pass through the IOMMU.  This 
+	  prevents them from going anywhere except their intended 
+	  destination. This catches hard-to-find kernel bugs and
+	  mis-behaving drivers and devices that do not use the DMA-API
+	  properly to set up their DMA buffers.  The IOMMU can be 
+	  turned off at boot time with the iommu=off parameter.  
+	  Normally the kernel will make the right choice by itself.
+	  If unsure, say Y.
+
 # need this always enabled with GART_IOMMU for the VIA workaround
 config SWIOTLB
 	bool
arch/x86_64/kernel/Makefile +1 -0
diff -r 688a6a25478b arch/x86_64/kernel/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_CPU_FREQ)		+= cpufreq/
 obj-$(CONFIG_CPU_FREQ)		+= cpufreq/
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 obj-$(CONFIG_GART_IOMMU)	+= pci-gart.o aperture.o
+obj-$(CONFIG_CALGARY_IOMMU)	+= pci-calgary.o tce.o
 obj-$(CONFIG_SWIOTLB)		+= pci-swiotlb.o
 obj-$(CONFIG_KPROBES)		+= kprobes.o
 obj-$(CONFIG_X86_PM_TIMER)	+= pmtimer.o
arch/x86_64/kernel/pci-dma.c +9 -0
diff -r 688a6a25478b arch/x86_64/kernel/pci-dma.c
@@ -9,6 +9,7 @@
 #include <linux/module.h>
 #include <asm/io.h>
 #include <asm/proto.h>
+#include <asm/calgary.h>
 
 int iommu_merge __read_mostly = 0;
 EXPORT_SYMBOL(iommu_merge);
@@ -287,6 +288,10 @@ void __init pci_iommu_alloc(void)
 	iommu_hole_init();
 #endif
 
+#ifdef CONFIG_CALGARY_IOMMU 
+	detect_calgary();
+#endif
+
 #ifdef CONFIG_SWIOTLB
 	pci_swiotlb_init();
 #endif
@@ -294,6 +299,10 @@ void __init pci_iommu_alloc(void)
 
 static int __init pci_iommu_init(void)
 {
+#ifdef CONFIG_CALGARY_IOMMU 
+	calgary_iommu_init();
+#endif
+
 #ifdef CONFIG_GART_IOMMU
 	gart_iommu_init();
 #endif
include/asm-x86_64/pci.h +1 -1
diff -r 688a6a25478b include/asm-x86_64/pci.h
@@ -52,7 +52,7 @@ extern void pci_iommu_alloc(void);
  */
 #define PCI_DMA_BUS_IS_PHYS (dma_ops->is_phys)
 
-#ifdef CONFIG_GART_IOMMU
+#if defined(CONFIG_GART_IOMMU) || defined(CONFIG_CALGARY_IOMMU)
 
 /*
  * x86-64 always supports DAC, but sometimes it is useful to force
arch/x86_64/kernel/pci-calgary.c new file +1018 -0

1,018 lines not on this page · raw message

arch/x86_64/kernel/tce.c new file +202 -0

202 lines not on this page · raw message

include/asm-x86_64/calgary.h new file +66 -0

66 lines not on this page · raw message

include/asm-x86_64/tce.h new file +47 -0

47 lines not on this page · raw message