Skip to contentSkip to conversation

core/iommu changes for v2.6.33

GIT PULL Ingo Molnar 1 participant 1 message Dec 3, 2009

Subsystems (7)
Memory management x86 PowerPC PCI +3 more subsystems
lore
Share & tools
lore
#0 lore raw

Linus,

Please pull the latest IOMMU git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git core-iommu-for-linus

Highlights: refactorings, restructuring and cleanups mostly, all over the place. A new bootmem function is added, free_bootmem_late(). Also some fixes that didnt make it into .32.

Thanks,

Ingo

------------------>
Darrick J. Wong (1):
x86, Calgary IOMMU quirk: Find nearest matching Calgary while walking up the PCI tree

FUJITA Tomonori (20):
x86: Use x86_platform for iommu_shutdown
x86: Add iommu_init to x86_init_ops
x86: Calgary: Convert detect_calgary() to use iommu_init hook
x86: GART: Convert gart_iommu_hole_init() to use iommu_init hook
x86: amd_iommu: Convert amd_iommu_detect() to use iommu_init hook
x86: intel-iommu: Convert detect_intel_iommu to use iommu_init hook
bootmem: Add free_bootmem_late()
swiotlb: Add swiotlb_free() function
swiotlb: Defer swiotlb init printing, export swiotlb_print_info()
x86: Handle HW IOMMU initialization failure gracefully x86, 32-bit: Fix swiotlb boot crash
swiotlb: Remove the swiotlb variable usage
x86: Set dma_ops to nommu_dma_ops by default
x86: Move iommu_shutdown_noop to x86_init.c
swiotlb: Remove duplicate swiotlb_force extern declarations
x86: Make calgary_iommu_init() static
x86: gart: Add own dma_mapping_error function
x86: Kill bad_dma_address variable
x86: Calgary: Remove unnecessary DMA_ERROR_CODE usage
x86: Fix iommu=soft boot option

Hiroshi Shimamoto (1):
x86: Don't put iommu_shutdown_noop() in init section

Ingo Molnar (2):
x86: Add iommu_init to x86_init_ops, fix build
x86: gart: Clean up the code a bit

Joe Perches (1):
x86: GART: pci-gart_64.c: Use correct length in strncmp

Joerg Roedel (36):
x86/amd-iommu: un__init iommu_setup_msi
x86/amd-iommu: attach devices to pre-allocated domains early x86/amd-iommu: Separate internal interface definitions x86/amd-iommu: Update copyright headers
x86/amd-iommu: Add an index field to struct amd_iommu x86/amd-iommu: Add per IOMMU reference counting x86/amd-iommu: Add function to complete a tlb flush x86/amd-iommu: Make iommu_flush_pages aware of multiple IOMMUs x86/amd-iommu: Use __iommu_flush_pages for tlb flushes x86/amd-iommu: Remove iommu_flush_domain function x86/amd-iommu: Implement protection domain list x86/amd-iommu: Reimplement amd_iommu_flush_all_domains() x86/amd-iommu: Reimplement flush_all_domains_on_iommu() x86/amd-iommu: Make np-cache a global flag
x86/amd-iommu: Use check_device for amd_iommu_dma_supported x86/amd-iommu: Use check_device in get_device_resources x86/amd-iommu: Remove iommu parameter from dma_ops_domain_(un)map x86/amd-iommu: Make alloc_new_range aware of multiple IOMMUs x86/amd-iommu: Remove iommu parameter from __(un)map_single x86/amd-iommu: Remove iommu specific handling from dma_ops path x86/amd-iommu: Let domain_for_device handle aliases x86/amd-iommu: Simplify get_device_resources() x86/amd-iommu: Move find_protection_domain to helper functions x86/amd-iommu: Use get_device_id and check_device where appropriate x86/amd-iommu: Remove iommu parameter from dma_ops_domain_alloc x86/amd-iommu: Move some pte allocation functions in the right section x86/amd-iommu: Rearrange dma_ops related functions x86/amd-iommu: Remove support for domain sharing x86/amd-iommu: Use dev->arch->iommu to store iommu related information x86/amd-iommu: Add device bind reference counting x86/amd-iommu: Keep devices per domain in a list x86/amd-iommu: Cleanup attach/detach_device code x86/amd-iommu: Introduce iommu_flush_device() function x86/amd-iommu: Cleanup DTE flushing code
x86/amd-iommu: Move reset_iommu_command_buffer out of locked code x86/amd-iommu: Remove amd_iommu_pd_table

Pavel Vasilyev (1):
agp/amd64: Remove GART dependency on AGP_AMD64

Tejun Heo (1):
x86: Fix iommu=nodac parameter handling

 arch/ia64/include/asm/swiotlb.h        |    2 -
 arch/ia64/kernel/pci-swiotlb.c         |    4 +-
 arch/powerpc/kernel/setup_32.c         |    2 +-
 arch/powerpc/kernel/setup_64.c         |    2 +-
 arch/x86/include/asm/amd_iommu.h       |   16 +-
 arch/x86/include/asm/amd_iommu_proto.h |   38 +
 arch/x86/include/asm/amd_iommu_types.h |   54 ++-
 arch/x86/include/asm/calgary.h         |    2 -
 arch/x86/include/asm/device.h          |    2 +-
 arch/x86/include/asm/dma-mapping.h     |    5 +-
 arch/x86/include/asm/gart.h            |    9 +-
 arch/x86/include/asm/iommu.h           |    2 -
 arch/x86/include/asm/swiotlb.h         |    9 +-
 arch/x86/include/asm/x86_init.h        |   10 +
 arch/x86/kernel/amd_iommu.c            | 1247 +++++++++++++++++---------------
 arch/x86/kernel/amd_iommu_init.c       |   94 +--
 arch/x86/kernel/aperture_64.c          |    4 +-
 arch/x86/kernel/crash.c                |    5 +-
 arch/x86/kernel/pci-calgary_64.c       |   94 +--
 arch/x86/kernel/pci-dma.c              |   39 +-
 arch/x86/kernel/pci-gart_64.c          |  156 +++--
 arch/x86/kernel/pci-nommu.c            |   11 +-
 arch/x86/kernel/pci-swiotlb.c          |   18 +-
 arch/x86/kernel/reboot.c               |    4 +-
 arch/x86/kernel/x86_init.c             |    8 +
 drivers/char/agp/Kconfig               |    3 +-
 drivers/pci/dmar.c                     |    7 +-
 drivers/pci/intel-iommu.c              |    6 +-
 include/linux/bootmem.h                |    1 +
 include/linux/dmar.h                   |   15 +-
 include/linux/swiotlb.h                |   12 +-
 lib/swiotlb.c                          |   46 +-
 mm/bootmem.c                           |   24 +
 33 files changed, 1068 insertions(+), 883 deletions(-)
 create mode 100644 arch/x86/include/asm/amd_iommu_proto.h
arch/ia64/include/asm/swiotlb.h +0 -2
index dcbaea7..f0acde6 100644
@@ -4,8 +4,6 @@
 #include <linux/dma-mapping.h>
 #include <linux/swiotlb.h>
 
-extern int swiotlb_force;
-
 #ifdef CONFIG_SWIOTLB
 extern int swiotlb;
 extern void pci_swiotlb_init(void);
arch/ia64/kernel/pci-swiotlb.c +2 -2
index 285aae8..53292ab 100644
@@ -41,7 +41,7 @@ struct dma_map_ops swiotlb_dma_ops = {
 void __init swiotlb_dma_init(void)
 {
 	dma_ops = &swiotlb_dma_ops;
-	swiotlb_init();
+	swiotlb_init(1);
 }
 
 void __init pci_swiotlb_init(void)
@@ -51,7 +51,7 @@ void __init pci_swiotlb_init(void)
 		swiotlb = 1;
 		printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
 		machvec_init("dig");
-		swiotlb_init();
+		swiotlb_init(1);
 		dma_ops = &swiotlb_dma_ops;
 #else
 		panic("Unable to find Intel IOMMU");
arch/powerpc/kernel/setup_32.c +1 -1
index 53bcf3d..b152de3 100644
@@ -345,7 +345,7 @@ void __init setup_arch(char **cmdline_p)
 
 #ifdef CONFIG_SWIOTLB
 	if (ppc_swiotlb_enable)
-		swiotlb_init();
+		swiotlb_init(1);
 #endif
 
 	paging_init();
arch/powerpc/kernel/setup_64.c +1 -1
index 04f638d..df2c9e9 100644
@@ -550,7 +550,7 @@ void __init setup_arch(char **cmdline_p)
 
 #ifdef CONFIG_SWIOTLB
 	if (ppc_swiotlb_enable)
-		swiotlb_init();
+		swiotlb_init(1);
 #endif
 
 	paging_init();
arch/x86/include/asm/amd_iommu.h +5 -11
index 4b18089..5af2982 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2008 Advanced Micro Devices, Inc.
+ * Copyright (C) 2007-2009 Advanced Micro Devices, Inc.
  * Author: Joerg Roedel <[email protected]>
  *         Leo Duran <[email protected]>
  *
@@ -23,19 +23,13 @@
 #include <linux/irqreturn.h>
 
 #ifdef CONFIG_AMD_IOMMU
-extern int amd_iommu_init(void);
-extern int amd_iommu_init_dma_ops(void);
-extern int amd_iommu_init_passthrough(void);
+
 extern void amd_iommu_detect(void);
-extern irqreturn_t amd_iommu_int_handler(int irq, void *data);
-extern void amd_iommu_flush_all_domains(void);
-extern void amd_iommu_flush_all_devices(void);
-extern void amd_iommu_shutdown(void);
-extern void amd_iommu_apply_erratum_63(u16 devid);
+
 #else
-static inline int amd_iommu_init(void) { return -ENODEV; }
+
 static inline void amd_iommu_detect(void) { }
-static inline void amd_iommu_shutdown(void) { }
+
 #endif
 
 #endif /* _ASM_X86_AMD_IOMMU_H */
arch/x86/include/asm/amd_iommu_proto.h new file +38 -0
new file mode 100644
index 0000000..84786fb
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2009 Advanced Micro Devices, Inc.
+ * Author: Joerg Roedel <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ */
+
+#ifndef _ASM_X86_AMD_IOMMU_PROTO_H
+#define _ASM_X86_AMD_IOMMU_PROTO_H
+
+struct amd_iommu;
+
+extern int amd_iommu_init_dma_ops(void);
+extern int amd_iommu_init_passthrough(void);
+extern irqreturn_t amd_iommu_int_handler(int irq, void *data);
+extern void amd_iommu_flush_all_domains(void);
+extern void amd_iommu_flush_all_devices(void);
+extern void amd_iommu_apply_erratum_63(u16 devid);
+extern void amd_iommu_reset_cmd_buffer(struct amd_iommu *iommu);
+
+#ifndef CONFIG_AMD_IOMMU_STATS
+
+static inline void amd_iommu_stats_init(void) { }
+
+#endif /* !CONFIG_AMD_IOMMU_STATS */
+
+#endif /* _ASM_X86_AMD_IOMMU_PROTO_H  */
arch/x86/include/asm/amd_iommu_types.h +42 -12

110 lines not on this page · raw message

arch/x86/include/asm/calgary.h +0 -2
index b03bedb..0918654 100644
@@ -62,10 +62,8 @@ struct cal_chipset_ops {
 extern int use_calgary;
 
 #ifdef CONFIG_CALGARY_IOMMU
-extern int calgary_iommu_init(void);
 extern void detect_calgary(void);
 #else
-static inline int calgary_iommu_init(void) { return 1; }
 static inline void detect_calgary(void) { return; }
 #endif
 
arch/x86/include/asm/device.h +1 -1
index cee34e9..029f230 100644
@@ -8,7 +8,7 @@ struct dev_archdata {
 #ifdef CONFIG_X86_64
 struct dma_map_ops *dma_ops;
 #endif
-#ifdef CONFIG_DMAR
+#if defined(CONFIG_DMAR) || defined(CONFIG_AMD_IOMMU)
 	void *iommu; /* hook for IOMMU specific extension */
 #endif
 };
arch/x86/include/asm/dma-mapping.h +3 -2
index 6a25d5d..0f6c02f 100644
@@ -20,7 +20,8 @@
 # define ISA_DMA_BIT_MASK DMA_BIT_MASK(32)
 #endif
 
-extern dma_addr_t bad_dma_address;
+#define DMA_ERROR_CODE	0
+
 extern int iommu_merge;
 extern struct device x86_dma_fallback_dev;
 extern int panic_on_overflow;
@@ -48,7 +49,7 @@ static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 	if (ops->mapping_error)
 		return ops->mapping_error(dev, dma_addr);
 
-	return (dma_addr == bad_dma_address);
+	return (dma_addr == DMA_ERROR_CODE);
 }
 
 #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
arch/x86/include/asm/gart.h +1 -8
index 6cfdafa..4ac5b0f 100644
@@ -35,8 +35,7 @@ extern int gart_iommu_aperture_allowed;
 extern int gart_iommu_aperture_disabled;
 
 extern void early_gart_iommu_check(void);
-extern void gart_iommu_init(void);
-extern void gart_iommu_shutdown(void);
+extern int gart_iommu_init(void);
 extern void __init gart_parse_options(char *);
 extern void gart_iommu_hole_init(void);
 
@@ -48,12 +47,6 @@ extern void gart_iommu_hole_init(void);
 static inline void early_gart_iommu_check(void)
 {
 }
-static inline void gart_iommu_init(void)
-{
-}
-static inline void gart_iommu_shutdown(void)
-{
-}
 static inline void gart_parse_options(char *options)
 {
 }
arch/x86/include/asm/iommu.h +0 -2
index fd6d21b..345c99c 100644
@@ -1,8 +1,6 @@
 #ifndef _ASM_X86_IOMMU_H
 #define _ASM_X86_IOMMU_H
 
-extern void pci_iommu_shutdown(void);
-extern void no_iommu_init(void);
 extern struct dma_map_ops nommu_dma_ops;
 extern int force_iommu, no_iommu;
 extern int iommu_detected;
arch/x86/include/asm/swiotlb.h +3 -6
index b9e4e20..87ffcb1 100644
@@ -3,17 +3,14 @@
 
 #include <linux/swiotlb.h>
 
-/* SWIOTLB interface */
-
-extern int swiotlb_force;
-
 #ifdef CONFIG_SWIOTLB
 extern int swiotlb;
-extern void pci_swiotlb_init(void);
+extern int pci_swiotlb_init(void);
 #else
 #define swiotlb 0
-static inline void pci_swiotlb_init(void)
+static inline int pci_swiotlb_init(void)
 {
+	return 0;
 }
 #endif
 
arch/x86/include/asm/x86_init.h +10 -0
index 2c756fd..d8e7145 100644
@@ -91,6 +91,14 @@ struct x86_init_timers {
 };
 
 /**
+ * struct x86_init_iommu - platform specific iommu setup
+ * @iommu_init:			platform specific iommu setup
+ */
+struct x86_init_iommu {
+	int (*iommu_init)(void);
+};
+
+/**
  * struct x86_init_ops - functions for platform specific setup
  *
  */
@@ -101,6 +109,7 @@ struct x86_init_ops {
 	struct x86_init_oem		oem;
 	struct x86_init_paging		paging;
 	struct x86_init_timers		timers;
+	struct x86_init_iommu		iommu;
 };
 
 /**
@@ -121,6 +130,7 @@ struct x86_platform_ops {
 	unsigned long (*calibrate_tsc)(void);
 	unsigned long (*get_wallclock)(void);
 	int (*set_wallclock)(unsigned long nowtime);
+	void (*iommu_shutdown)(void);
 };
 
 extern struct x86_init_ops x86_init;
arch/x86/kernel/amd_iommu.c +669 -578

1,947 lines not on this page · raw message

arch/x86/kernel/amd_iommu_init.c +37 -57

205 lines not on this page · raw message

arch/x86/kernel/aperture_64.c +3 -1
index 128111d..e0dfb68 100644
@@ -28,6 +28,7 @@
 #include <asm/pci-direct.h>
 #include <asm/dma.h>
 #include <asm/k8.h>
+#include <asm/x86_init.h>
 
 int gart_iommu_aperture;
 int gart_iommu_aperture_disabled __initdata;
@@ -400,6 +401,7 @@ void __init gart_iommu_hole_init(void)
 
 			iommu_detected = 1;
 			gart_iommu_aperture = 1;
+			x86_init.iommu.iommu_init = gart_iommu_init;
 
 			aper_order = (read_pci_config(bus, slot, 3, AMD64_GARTAPERTURECTL) >> 1) & 7;
 			aper_size = (32 * 1024 * 1024) << aper_order;
@@ -456,7 +458,7 @@ out:
 
 	if (aper_alloc) {
 		/* Got the aperture from the AGP bridge */
-	} else if (swiotlb && !valid_agp) {
+	} else if (!valid_agp) {
 		/* Do nothing */
 	} else if ((!no_iommu && max_pfn > MAX_DMA32_PFN) ||
 		   force_iommu ||
arch/x86/kernel/crash.c +2 -3
index 5e409dc..a4849c1 100644
@@ -27,8 +27,7 @@
 #include <asm/cpu.h>
 #include <asm/reboot.h>
 #include <asm/virtext.h>
-#include <asm/iommu.h>
-
+#include <asm/x86_init.h>
 
 #if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC)
 
@@ -106,7 +105,7 @@ void native_machine_crash_shutdown(struct pt_regs *regs)
 #endif
 
 #ifdef CONFIG_X86_64
-	pci_iommu_shutdown();
+	x86_platform.iommu_shutdown();
 #endif
 
 	crash_save_cpu(regs, safe_smp_processor_id());
arch/x86/kernel/pci-calgary_64.c +40 -54

184 lines not on this page · raw message

arch/x86/kernel/pci-dma.c +13 -26
index a6e804d..afcc58b 100644
@@ -11,10 +11,11 @@
 #include <asm/gart.h>
 #include <asm/calgary.h>
 #include <asm/amd_iommu.h>
+#include <asm/x86_init.h>
 
 static int forbid_dac __read_mostly;
 
-struct dma_map_ops *dma_ops;
+struct dma_map_ops *dma_ops = &nommu_dma_ops;
 EXPORT_SYMBOL(dma_ops);
 
 static int iommu_sac_force __read_mostly;
@@ -42,9 +43,6 @@ int iommu_detected __read_mostly = 0;
  */
 int iommu_pass_through __read_mostly;
 
-dma_addr_t bad_dma_address __read_mostly = 0;
-EXPORT_SYMBOL(bad_dma_address);
-
 /* Dummy device used for NULL arguments (normally ISA). */
 struct device x86_dma_fallback_dev = {
 	.init_name = "fallback device",
@@ -126,20 +124,17 @@ void __init pci_iommu_alloc(void)
 	/* free the range so iommu could get some range less than 4G */
 	dma32_free_bootmem();
 #endif
+	if (pci_swiotlb_init())
+		return;
 
-	/*
-	 * The order of these functions is important for
-	 * fall-back/fail-over reasons
-	 */
 	gart_iommu_hole_init();
 
 	detect_calgary();
 
 	detect_intel_iommu();
 
+	/* needs to be called after gart_iommu_hole_init */
 	amd_iommu_detect();
-
-	pci_swiotlb_init();
 }
 
 void *dma_generic_alloc_coherent(struct device *dev, size_t size,
@@ -214,7 +209,7 @@ static __init int iommu_setup(char *p)
 		if (!strncmp(p, "allowdac", 8))
 			forbid_dac = 0;
 		if (!strncmp(p, "nodac", 5))
-			forbid_dac = -1;
+			forbid_dac = 1;
 		if (!strncmp(p, "usedac", 6)) {
 			forbid_dac = -1;
 			return 1;
@@ -289,25 +284,17 @@ static int __init pci_iommu_init(void)
 #ifdef CONFIG_PCI
 	dma_debug_add_bus(&pci_bus_type);
 #endif
+	x86_init.iommu.iommu_init();
 
-	calgary_iommu_init();
-
-	intel_iommu_init();
+	if (swiotlb) {
+		printk(KERN_INFO "PCI-DMA: "
+		       "Using software bounce buffering for IO (SWIOTLB)\n");
+		swiotlb_print_info();
+	} else
+		swiotlb_free();
 
-	amd_iommu_init();
-
-	gart_iommu_init();
-
-	no_iommu_init();
 	return 0;
 }
-
-void pci_iommu_shutdown(void)
-{
-	gart_iommu_shutdown();
-
-	amd_iommu_shutdown();
-}
 /* Must execute after PCI subsystem */
 rootfs_initcall(pci_iommu_init);
 
arch/x86/kernel/pci-gart_64.c +84 -72

212 lines not on this page · raw message

arch/x86/kernel/pci-nommu.c +1 -10
index a3933d4..22be12b 100644

Lines of this file are not shown. View the raw message.

arch/x86/kernel/pci-swiotlb.c +14 -4
index aaa6b78..e3c0a66 100644

Lines of this file are not shown. View the raw message.

arch/x86/kernel/reboot.c +2 -2
index f930787..2b97fc5 100644

Lines of this file are not shown. View the raw message.

arch/x86/kernel/x86_init.c +8 -0
index 4449a4a..d11c5ff 100644

Lines of this file are not shown. View the raw message.

drivers/char/agp/Kconfig +1 -2
index ccb1fa8..2fb3a48 100644

Lines of this file are not shown. View the raw message.

drivers/pci/dmar.c +5 -2
index 22b02c6..4373996 100644

Lines of this file are not shown. View the raw message.

drivers/pci/intel-iommu.c +4 -2
index b1e97e6..43d755a 100644

Lines of this file are not shown. View the raw message.

include/linux/bootmem.h +1 -0
index dd97fb8..b10ec49 100644

Lines of this file are not shown. View the raw message.

include/linux/dmar.h +4 -11
index 4a2b162..5de4c9e 100644

Lines of this file are not shown. View the raw message.

include/linux/swiotlb.h +10 -2
index 73b1f1c..febedcf 100644

Lines of this file are not shown. View the raw message.

lib/swiotlb.c +39 -7

46 lines not on this page · raw message

mm/bootmem.c +24 -0
index 555d5d2..d1dc23c 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.