x86/iommu for v2.6.37
Subsystems (3)
Linus,
Please pull the latest x86-iommu-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git x86-iommu-for-linus
out-of-topic modifications in x86-iommu-for-linus:
--------------------------------------------------
arch/ia64/include/asm/iommu_table.h# fc6a2f3: ia64, iommu: Add a dummy iommu_tadrivers/pci/dmar.c # 4db77ff: x86, VT-d: Make Intel VT-d IOMMU
# 480125b: x86, iommu: Make all IOMMU's dete
include/linux/dmar.h # 480125b: x86, iommu: Make all IOMMU's dete
Thanks,
Ingo
------------------>
Konrad Rzeszutek Wilk (14):
x86, iommu: Add IOMMU_INIT macros, .iommu_table section, and iommu_table_entry structure x86, iommu: Make all IOMMU's detection routines return a value.
x86, iommu: Add proper dependency sort routine (and sanity check).
x86, swiotlb: Simplify SWIOTLB pci_swiotlb_detect routine.
x86, swiotlb: Make SWIOTLB use IOMMU_INIT_* macros.
x86, xen-swiotlb: Make Xen-SWIOTLB use IOMMU_INIT_* macros.
x86, calgary: Make Calgary IOMMU use IOMMU_INIT_* macros.
x86, GART/AMD-VI: Make AMD GART and IOMMU use IOMMU_INIT_* macros.
x86, VT-d: Make Intel VT-d IOMMU use IOMMU_INIT_* macros.
x86, iommu: Utilize the IOMMU_INIT macros functionality.
x86, doc: Adding comments about .iommu_table and its neighbors.
x86, iommu: Fix IOMMU_INIT alignment rules
ia64, iommu: Add a dummy iommu_table.h file in IA64.
x86, iommu: Update header comments with appropriate naming
arch/ia64/include/asm/iommu_table.h | 6 ++ arch/x86/include/asm/amd_iommu.h | 4 +- arch/x86/include/asm/calgary.h | 4 +- arch/x86/include/asm/gart.h | 5 +- arch/x86/include/asm/iommu_table.h | 100 +++++++++++++++++++++++++++++++++++ arch/x86/include/asm/swiotlb.h | 13 ++++- arch/x86/kernel/Makefile | 1 + arch/x86/kernel/amd_iommu_init.c | 15 ++++-- arch/x86/kernel/aperture_64.c | 11 +++-- arch/x86/kernel/pci-calgary_64.c | 18 ++++--- arch/x86/kernel/pci-dma.c | 44 +++++++-------- arch/x86/kernel/pci-gart_64.c | 2 + arch/x86/kernel/pci-iommu_table.c | 89 +++++++++++++++++++++++++++++++ arch/x86/kernel/pci-swiotlb.c | 44 +++++++++++++--- arch/x86/kernel/vmlinux.lds.S | 28 ++++++++++ arch/x86/xen/pci-swiotlb-xen.c | 5 ++ drivers/pci/dmar.c | 6 ++- include/linux/dmar.h | 6 +- 18 files changed, 344 insertions(+), 57 deletions(-) create mode 100644 arch/ia64/include/asm/iommu_table.h create mode 100644 arch/x86/include/asm/iommu_table.h create mode 100644 arch/x86/kernel/pci-iommu_table.c
arch/ia64/include/asm/iommu_table.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef _ASM_IA64_IOMMU_TABLE_H +#define _ASM_IA64_IOMMU_TABLE_H + +#define IOMMU_INIT_POST (_detect) + +#endif /* _ASM_IA64_IOMMU_TABLE_H */
arch/x86/include/asm/amd_iommu.h +2 -2
@@ -24,11 +24,11 @@#ifdef CONFIG_AMD_IOMMU -extern void amd_iommu_detect (void ); +extern int amd_iommu_detect (void );#else -static inline void amd_iommu_detect (void ) { } +static inline int amd_iommu_detect (void ) {return -ENODEV ; }#endif
arch/x86/include/asm/calgary.h +2 -2
@@ -62,9 +62,9 @@ struct cal_chipset_ops {extern int use_calgary;#ifdef CONFIG_CALGARY_IOMMU -extern void detect_calgary (void ); +extern int detect_calgary (void );#else -static inline void detect_calgary (void ) {return ; } +static inline int detect_calgary (void ) {return -ENODEV ; }#endif #endif /* _ASM_X86_CALGARY_H */
arch/x86/include/asm/gart.h +3 -2
@@ -37,7 +37,7 @@ extern int gart_iommu_aperture_disabled;extern void early_gart_iommu_check (void );extern int gart_iommu_init (void );extern void __init gart_parse_options (char *); -extern void gart_iommu_hole_init (void ); +extern int gart_iommu_hole_init (void );#else #define gart_iommu_aperture 0
@@ -50,8 +50,9 @@ static inline void early_gart_iommu_check(void)static inline void gart_parse_options (char *options) { } -static inline void gart_iommu_hole_init (void ) +static inline int gart_iommu_hole_init (void ) { +return -ENODEV ; }#endif
arch/x86/include/asm/iommu_table.h new file +100 -0
100 lines not on this page · raw message
arch/x86/include/asm/swiotlb.h +11 -2
@@ -5,17 +5,26 @@#ifdef CONFIG_SWIOTLB extern int swiotlb; -extern int __init pci_swiotlb_detect (void ); +extern int __init pci_swiotlb_detect_override (void ); +extern int __init pci_swiotlb_detect_4gb (void );extern void __init pci_swiotlb_init (void ); +extern void __init pci_swiotlb_late_init (void );#else #define swiotlb 0 -static inline int pci_swiotlb_detect (void ) +static inline int pci_swiotlb_detect_override (void ) +{ +return 0 ; +} +static inline int pci_swiotlb_detect_4gb (void ) {return 0 ; }static inline void pci_swiotlb_init (void ) { } +static inline void pci_swiotlb_late_init (void ) +{ +}#endif static inline void dma_mark_clean (void *addr,size_t size) {}
arch/x86/kernel/Makefile +1 -0
@@ -42,6 +42,7 @@ obj-y += bootflag.o e820.o obj-y += pci-dma.o quirks.o i8237.o topology.o kdebugfs.o obj-y += alternative.o i8253.o pci-nommu.o hw_breakpoint.o obj-y += tsc.o io_delay.o rtc.o +obj-y += pci-iommu_table.o obj-$(CONFIG_X86_TRAMPOLINE) += trampoline.o obj-y += process.o
arch/x86/kernel/amd_iommu_init.c +11 -4
@@ -31,7 +31,7 @@#include <asm/iommu.h> #include <asm/gart.h> #include <asm/x86_init.h> - +#include <asm/iommu_table.h> /* * definitions for the ACPI scanning code */
@@ -1382,13 +1382,13 @@ static int __init early_amd_iommu_detect(struct acpi_table_header *table)return 0 ; } -void __init amd_iommu_detect (void ) +int __init amd_iommu_detect (void ) {if (no_iommu || (iommu_detected && !gart_iommu_aperture)) -return ; +return -ENODEV ;if (amd_iommu_disabled) -return ; +return -ENODEV ;if (acpi_table_parse ("IVRS" , early_amd_iommu_detect) ==0 ) { iommu_detected =1 ;
@@ -1397,7 +1397,9 @@ void __init amd_iommu_detect(void)/* Make sure ACS will be enabled */ pci_request_acs (); +return 1 ; } +return -ENODEV ; }/****************************************************************************
@@ -1428,3 +1430,8 @@ static int __init parse_amd_iommu_options(char *str)__setup ("amd_iommu_dump" , parse_amd_iommu_dump);__setup ("amd_iommu=" , parse_amd_iommu_options); + +IOMMU_INIT_FINISH (amd_iommu_detect, + gart_iommu_hole_init, +0 , +0 );
arch/x86/kernel/aperture_64.c +7 -4
@@ -371,7 +371,7 @@ void __init early_gart_iommu_check(void)static int __initdata printed_gart_size_msg; -void __init gart_iommu_hole_init (void ) +int __init gart_iommu_hole_init (void ) {u32 agp_aper_base =0 , agp_aper_order =0 ;u32 aper_size, aper_alloc =0 , aper_order =0 , last_aper_order =0 ;
@@ -381,7 +381,7 @@ void __init gart_iommu_hole_init(void)if (gart_iommu_aperture_disabled || !fix_aperture || !early_pci_allowed ()) -return ; +return -ENODEV ;printk (KERN_INFO "Checking aperture...\n" );
@@ -463,8 +463,9 @@ out:unsigned long n = (32 *1024 *1024 ) << last_aper_order;insert_aperture_resource ((u32 )last_aper_base, n); +return 1 ; } -return ; +return 0 ; }if (!fallback_aper_force) {
@@ -500,7 +501,7 @@ out:panic ("Not enough memory for aperture" ); } }else { -return ; +return 0 ; }/* Fix up the north bridges */
@@ -524,4 +525,6 @@ out: }set_up_gart_resume (aper_order, aper_alloc); + +return 1 ; }
arch/x86/kernel/pci-calgary_64.c +11 -7
@@ -47,6 +47,7 @@#include <asm/rio.h> #include <asm/bios_ebda.h> #include <asm/x86_init.h> +#include <asm/iommu_table.h> #ifdef CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT int use_calgary__read_mostly =1 ;
@@ -1364,7 +1365,7 @@ static int __init calgary_iommu_init(void)return 0 ; } -void __init detect_calgary (void ) +int __init detect_calgary (void ) {int bus;void *tbl;
@@ -1378,13 +1379,13 @@ void __init detect_calgary(void)* another HW IOMMU already, bail out. */ if (no_iommu || iommu_detected) -return ; +return -ENODEV ;if (!use_calgary) -return ; +return -ENODEV ;if (!early_pci_allowed ()) -return ; +return -ENODEV ;printk (KERN_DEBUG "Calgary: detecting Calgary via BIOS EBDA area\n" );
@@ -1410,13 +1411,13 @@ void __init detect_calgary(void)if (!rio_table_hdr) {printk (KERN_DEBUG "Calgary: Unable to locate Rio Grande table " "in EBDA - bailing!\n" ); -return ; +return -ENODEV ; } ret =build_detail_arrays ();if (ret) {printk (KERN_DEBUG "Calgary: build_detail_arrays ret %d\n" , ret); -return ; +return -ENOMEM ; } specified_table_size = determine_tce_table_size((is_kdump_kernel() ?
@@ -1464,7 +1465,7 @@ void __init detect_calgary(void) x86_init.iommu.iommu_init = calgary_iommu_init; } -return ; +return calgary_found; cleanup:for (--bus; bus >=0 ; --bus) {
@@ -1473,6 +1474,7 @@ cleanup:if (info->tce_space)free_tce_table (info->tce_space); } +return -ENOMEM ; }static int __init calgary_parse_options (char *p)
@@ -1594,3 +1596,5 @@ static int __init calgary_fixup_tce_spaces(void)* and before device_initcall. */ rootfs_initcall (calgary_fixup_tce_spaces); + +IOMMU_INIT_POST (detect_calgary);
arch/x86/kernel/pci-dma.c +21 -23
80 lines not on this page · raw message
arch/x86/kernel/pci-gart_64.c +2 -0
@@ -41,6 +41,7 @@#include <asm/dma.h> #include <asm/k8.h> #include <asm/x86_init.h> +#include <asm/iommu_table.h> static unsigned long iommu_bus_base;/* GART remapping area (physical) */ static unsigned long iommu_size;/* size of remapping area bytes */
@@ -896,3 +897,4 @@ void __init gart_parse_options(char *p) } } } +IOMMU_INIT_POST (gart_iommu_hole_init);
arch/x86/kernel/pci-iommu_table.c new file +89 -0
89 lines not on this page · raw message
arch/x86/kernel/pci-swiotlb.c +37 -7
72 lines not on this page · raw message
arch/x86/kernel/vmlinux.lds.S +28 -0
@@ -242,6 +242,12 @@ SECTIONS __x86_cpu_dev_end = .; } + /* + * start address and size of operations which during runtime + * can be patched with virtualization friendly instructions or + * baremetal native ones. Think page table operations. + * Details in paravirt_types.h + */ . = ALIGN(8); .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) { __parainstructions = .;
@@ -249,6 +255,11 @@ SECTIONS __parainstructions_end = .; } + /* + * struct alt_inst entries. From the header (alternative.h): + * "Alternative instructions for different CPU types or capabilities" + * Think locking instructions on spinlocks. + */ . = ALIGN(8); .altinstructions : AT(ADDR(.altinstructions) - LOAD_OFFSET) { __alt_instructions = .;
@@ -256,11 +267,28 @@ SECTIONS __alt_instructions_end = .; } + /* + * And here are the replacement instructions. The linker sticks + * them as binary blobs. The .altinstructions has enough data to + * get the address and the length of them to patch the kernel safely. + */ .altinstr_replacement : AT(ADDR(.altinstr_replacement) - LOAD_OFFSET) { *(.altinstr_replacement) } /* + * struct iommu_table_entry entries are injected in this section. + * It is an array of IOMMUs which during run time gets sorted depending + * on its dependency order. After rootfs_initcall is complete + * this section can be safely removed. + */ + .iommu_table : AT(ADDR(.iommu_table) - LOAD_OFFSET) { + __iommu_table = .; + *(.iommu_table) + __iommu_table_end = .; + } + . = ALIGN(8); + /* * .exit.text is discard at runtime, not link time, to deal with * references from .altinstructions and .eh_frame */
arch/x86/xen/pci-swiotlb-xen.c +5 -0
@@ -5,6 +5,7 @@#include <asm/xen/hypervisor.h> #include <xen/xen.h> +#include <asm/iommu_table.h> int xen_swiotlb__read_mostly ;
@@ -56,3 +57,7 @@ void __init pci_xen_swiotlb_init(void) dma_ops = &xen_swiotlb_dma_ops; } } +IOMMU_INIT_FINISH (pci_xen_swiotlb_detect, +0 , + pci_xen_swiotlb_init, +0 );
drivers/pci/dmar.c +5 -1
@@ -36,6 +36,7 @@#include <linux/tboot.h> #include <linux/dmi.h> #include <linux/slab.h> +#include <asm/iommu_table.h> #define PREFIX "DMAR: "
@@ -687,7 +688,7 @@ failed:return 0 ; } -void __init detect_intel_iommu (void ) +int __init detect_intel_iommu (void ) {int ret;
@@ -723,6 +724,8 @@ void __init detect_intel_iommu(void) }early_acpi_os_unmap_memory (dmar_tbl, dmar_tbl_size); dmar_tbl =NULL ; + +return ret ?1 : -ENODEV ; }
@@ -1455,3 +1458,4 @@ int __init dmar_ir_support(void)return 0 ;return dmar->flags &0x1 ; } +IOMMU_INIT_POST (detect_intel_iommu);
include/linux/dmar.h +3 -3
@@ -57,15 +57,15 @@ extern int dmar_table_init(void);extern int dmar_dev_scope_init (void );/* Intel IOMMU detection */ -extern void detect_intel_iommu (void ); +extern int detect_intel_iommu (void );extern int enable_drhd_fault_handling (void );extern int parse_ioapics_under_ir (void );extern int alloc_iommu (struct dmar_drhd_unit *);#else -static inline void detect_intel_iommu (void ) +static inline int detect_intel_iommu (void ) { -return ; +return -ENODEV ; }static inline int dmar_table_init (void )
Quoted 18 lines · Ingo Molnar
Linus,
Please pull the latest x86-iommu-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git x86-iommu-for-linusout-of-topic modifications in x86-iommu-for-linus:
--------------------------------------------------
arch/ia64/include/asm/iommu_table.h# fc6a2f3: ia64, iommu: Add a dummyiommu_tadrivers/pci/dmar.c# 4db77ff: x86, VT-d: Make Intel VT-d IOMMU# 480125b: x86, iommu: Make all IOMMU's dete
include/linux/dmar.h# 480125b: x86, iommu: Make all IOMMU's deteThanks,
Ingo
Quoted 9 lines
------------------>
Konrad Rzeszutek Wilk (14):
x86, iommu: AddIOMMU_INITmacros, .iommu_table section, andiommu_table_entrystructure x86, iommu: Make all IOMMU's detection routines return a value.
x86, iommu: Add proper dependency sort routine (and sanity check).
x86, swiotlb: Simplify SWIOTLBpci_swiotlb_detectroutine.
x86, swiotlb: Make SWIOTLB use IOMMU_INIT_* macros.
x86, xen-swiotlb: Make Xen-SWIOTLB use IOMMU_INIT_* macros.
x86, calgary: Make Calgary IOMMU use IOMMU_INIT_* macros.
I initially did not have a IBM box with a Calgary chipset, but about a week ago got one cheap on eBay so was able to test this.
Quoted 2 lines
x86, GART/AMD-VI: Make AMD GART and IOMMU use IOMMU_INIT_* macros. x86, VT-d: Make Intel VT-d IOMMU use IOMMU_INIT_* macros.
And also this one.
Quoted 5 lines
x86, iommu: Utilize the
IOMMU_INITmacros functionality. x86, doc: Adding comments about .iommu_table and its neighbors. x86, iommu: FixIOMMU_INITalignment rules
ia64, iommu: Add a dummyiommu_table.hfile in IA64. x86, iommu: Update header comments with appropriate naming