IOMMU interaction fixes.
Subsystems (2)
PATCH 1/1 IOMMU interaction fixes.
Two fixes to make Xen boot on AMD machines with GART. Also (but not tested) with other IOMMUs, such as Calgary (IBM 3950,3850), AMD IOMMU, and Intel's IOMMUs.
[PATCH 1/2] Revert "xen/swiotlb: make sure GART iommu doesn't initialize if we want Xen swiotlb" [PATCH 2/2] Introduce xen_swiotlb variable that is set when Xen is running.
PATCH 1/2 Revert "xen/swiotlb: make sure GART iommu doesn't initialize if we want Xen swiotlb"
This reverts commit d26d4ca29d2a13c8ccb94a1fe2d154b2c46de9e0.
--- arch/x86/kernel/pci-dma.c | 4 ++-- arch/x86/xen/pci-swiotlb.c | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-)
arch/x86/kernel/pci-dma.c +2 -2
@@ -122,8 +122,6 @@ void __init pci_iommu_alloc(void)* The order of these functions is important for * fall-back/fail-over reasons */ -xen_swiotlb_init (); -gart_iommu_hole_init ();detect_calgary ();
@@ -132,6 +130,8 @@ void __init pci_iommu_alloc(void)amd_iommu_detect (); +xen_swiotlb_init (); +pci_swiotlb_init (); }
arch/x86/xen/pci-swiotlb.c +0 -8
@@ -43,10 +43,6 @@#include <xen/page.h> #include <xen/xen-ops.h> - -#include <linux/pci.h> -#include <asm/gart.h> -#define OFFSET (val,align) ((unsigned long) \ ( (val) & ( (align) - 1)))
@@ -989,9 +985,5 @@ void __init xen_swiotlb_init(void)xen_swiotlb_init_with_default_size (64 * (1 <<20 ));/* default to 64MB */ dma_ops = &xen_swiotlb_dma_ops; iommu_detected =1 ; -#ifdef CONFIG_GART_IOMMU - gart_iommu_aperture_disabled =1 ; -#endif - } }
Signature · 1 line
1.6.2.5
PATCH 2/2 Introduce xen_swiotlb variable that is set when Xen is running.
Having the 'xen_swiotlb' variable enabled causes all of the IOMMU's to be disabled (except the Xen-SWIOTLB). It is in essence a copy of what swiotlb variable does. However the swiotlb variable cannot be used because it would turn on the non-Xen SWIOTLB.
--- arch/x86/include/asm/dma-mapping.h | 1 + arch/x86/include/asm/xen/swiotlb.h | 4 +++- arch/x86/kernel/amd_iommu_init.c | 2 +- arch/x86/kernel/aperture_64.c | 2 +- arch/x86/kernel/pci-calgary_64.c | 2 +- arch/x86/kernel/pci-dma.c | 4 ++-- arch/x86/kernel/pci-gart_64.c | 2 +- arch/x86/kernel/pci-swiotlb.c | 4 ++-- arch/x86/xen/pci-swiotlb.c | 3 +++ 9 files changed, 15 insertions(+), 9 deletions(-)
arch/x86/include/asm/dma-mapping.h +1 -0
@@ -12,6 +12,7 @@#include <linux/dma-attrs.h> #include <asm/io.h> #include <asm/swiotlb.h> +#include <asm/xen/swiotlb.h> #include <asm-generic/dma-coherent.h> extern dma_addr_t bad_dma_address;
arch/x86/include/asm/xen/swiotlb.h +3 -1
@@ -2,9 +2,11 @@#define _ASM_X86_XEN_SWIOTLB_H#ifdef CONFIG_PCI_XEN +extern int xen_swiotlb;extern void xen_swiotlb_init (void );#else -static void xen_swiotlb_init (void ) { } +#define xen_swiotlb 0 +static inline void xen_swiotlb_init (void ) { }#endif #endif
arch/x86/kernel/amd_iommu_init.c +1 -1
@@ -1304,7 +1304,7 @@ static int __init early_amd_iommu_detect(struct acpi_table_header *table)void __init amd_iommu_detect (void ) { -if (swiotlb || no_iommu || (iommu_detected && !gart_iommu_aperture)) +if (swiotlb || xen_swiotlb || no_iommu || (iommu_detected && !gart_iommu_aperture))return ;if (acpi_table_parse ("IVRS" , early_amd_iommu_detect) ==0 ) {
arch/x86/kernel/aperture_64.c +1 -1
@@ -369,7 +369,7 @@ void __init gart_iommu_hole_init(void)int fix, slot, valid_agp =0 ;int i, node; -if (gart_iommu_aperture_disabled || !fix_aperture || +if (gart_iommu_aperture_disabled || !fix_aperture || xen_swiotlb || !early_pci_allowed ())return ;
arch/x86/kernel/pci-calgary_64.c +1 -1
@@ -1357,7 +1357,7 @@ void __init detect_calgary(void)* if the user specified iommu=off or iommu=soft or we found * another HW IOMMU already, bail out. */ -if (swiotlb || no_iommu || iommu_detected) +if (swiotlb || xen_swiotlb || no_iommu || iommu_detected)return ;if (!use_calgary)
arch/x86/kernel/pci-dma.c +2 -2
@@ -122,6 +122,8 @@ void __init pci_iommu_alloc(void)* The order of these functions is important for * fall-back/fail-over reasons */ +xen_swiotlb_init (); +gart_iommu_hole_init ();detect_calgary ();
@@ -130,8 +132,6 @@ void __init pci_iommu_alloc(void)amd_iommu_detect (); -xen_swiotlb_init (); -pci_swiotlb_init (); }
arch/x86/kernel/pci-gart_64.c +1 -1
@@ -730,7 +730,7 @@ void __init gart_iommu_init(void) (agp_copy_info (agp_bridge, &info) <0 );#endif -if (swiotlb) +if (swiotlb || xen_swiotlb)return ;/* Did we detect a different HW IOMMU? */
arch/x86/kernel/pci-swiotlb.c +2 -2
@@ -47,10 +47,10 @@ void __init pci_swiotlb_init(void)/* don't initialize swiotlb if iommu=off (no_iommu=1) */ #ifdef CONFIG_X86_64 if ((!iommu_detected && !no_iommu && max_pfn >MAX_DMA32_PFN ) || - iommu_pass_through) + iommu_pass_through || !xen_swiotlb) swiotlb =1 ;#endif -if (swiotlb_force) +if (swiotlb_force || !xen_swiotlb) swiotlb =1 ;if (swiotlb) {printk (KERN_INFO "PCI-DMA: Using software bounce buffering for IO (SWIOTLB)\n" );
arch/x86/xen/pci-swiotlb.c +3 -0
@@ -978,6 +978,8 @@ static struct dma_map_ops xen_swiotlb_dma_ops = { .dma_supported = NULL, }; +int xen_swiotlb__read_mostly ; +void __init xen_swiotlb_init (void ) {if (xen_initial_domain ()) {
@@ -985,5 +987,6 @@ void __init xen_swiotlb_init(void)xen_swiotlb_init_with_default_size (64 * (1 <<20 ));/* default to 64MB */ dma_ops = &xen_swiotlb_dma_ops; iommu_detected =1 ; + xen_swiotlb =1 ; } }
Signature · 1 line
1.6.2.5
Re: [PATCH 2/2] Introduce xen_swiotlb variable that is set when Xen is running.
Quoted 124 lines · Konrad Rzeszutek Wilk
Having the '
xen_swiotlb' variable enabled causes all of the IOMMU's to be disabled (except the Xen-SWIOTLB). It is in essence a copy of what swiotlb variable does. However the swiotlb variable cannot be used because it would turn on the non-Xen SWIOTLB.--- arch/x86/include/asm/dma-mapping.h | 1 + arch/x86/include/asm/xen/swiotlb.h | 4 +++- arch/x86/kernel/amd_iommu_init.c | 2 +- arch/x86/kernel/aperture_64.c | 2 +- arch/x86/kernel/pci-calgary_64.c | 2 +- arch/x86/kernel/pci-dma.c | 4 ++-- arch/x86/kernel/pci-gart_64.c | 2 +- arch/x86/kernel/pci-swiotlb.c | 4 ++-- arch/x86/xen/pci-swiotlb.c | 3 +++ 9 files changed, 15 insertions(+), 9 deletions(-)arch/x86/include/asm/dma-mapping.h +1
-0@@ -12,6 +12,7 @@#include <linux/dma-attrs.h> #include <asm/io.h> #include <asm/swiotlb.h> +#include <asm/xen/swiotlb.h> #include <asm-generic/dma-coherent.h> extern dma_addr_t bad_dma_address;arch/x86/include/asm/xen/swiotlb.h +3
-1@@ -2,9 +2,11 @@#define _ASM_X86_XEN_SWIOTLB_H#ifdef CONFIG_PCI_XEN +extern int xen_swiotlb;extern void xen_swiotlb_init (void );#else -static void xen_swiotlb_init (void ) { } +#define xen_swiotlb 0 +static inline void xen_swiotlb_init (void ) { }#endif #endif arch/x86/kernel/amd_iommu_init.c +1
-1@@ -1304,7 +1304,7 @@ static int __init early_amd_iommu_detect(struct acpi_table_header *table)void __init amd_iommu_detect (void ) { -if (swiotlb || no_iommu || (iommu_detected && !gart_iommu_aperture)) +if (swiotlb || xen_swiotlb || no_iommu || (iommu_detected && !gart_iommu_aperture))return ;if (acpi_table_parse ("IVRS" , early_amd_iommu_detect) ==0 ) {arch/x86/kernel/aperture_64.c +1
-1@@ -369,7 +369,7 @@ void __init gart_iommu_hole_init(void)int fix, slot, valid_agp =0 ;int i, node; -if (gart_iommu_aperture_disabled || !fix_aperture || +if (gart_iommu_aperture_disabled || !fix_aperture || xen_swiotlb || !early_pci_allowed ())return ;arch/x86/kernel/pci-calgary_64.c +1
-1@@ -1357,7 +1357,7 @@ void __init detect_calgary(void)* if the user specified iommu=off or iommu=soft or we found * another HW IOMMU already, bail out. */ -if (swiotlb || no_iommu || iommu_detected) +if (swiotlb || xen_swiotlb || no_iommu || iommu_detected)return ;if (!use_calgary)arch/x86/kernel/pci-dma.c +2
-2@@ -122,6 +122,8 @@ void __init pci_iommu_alloc(void)* The order of these functions is important for * fall-back/fail-over reasons */ +xen_swiotlb_init (); +gart_iommu_hole_init ();detect_calgary ();@@ -130,8 +132,6 @@ void __init pci_iommu_alloc(void)amd_iommu_detect (); -xen_swiotlb_init (); -pci_swiotlb_init (); }arch/x86/kernel/pci-gart_64.c +1
-1@@ -730,7 +730,7 @@ void __init gart_iommu_init(void) (agp_copy_info (agp_bridge, &info) <0 );#endif -if (swiotlb) +if (swiotlb || xen_swiotlb)return ;/* Did we detect a different HW IOMMU? */ arch/x86/kernel/pci-swiotlb.c +0
-0
arch/x86/kernel/pci-swiotlb.c void __init pci_swiotlb_init(void) · line 51
Quoted 6 lines
arch/x86/kernel/pci-swiotlb.c +1
-1@@ -47,10 +47,10 @@ void __init pci_swiotlb_init(void)/* don't initialize swiotlb if iommu=off (no_iommu=1) */ #ifdef CONFIG_X86_64 if ((!iommu_detected && !no_iommu && max_pfn >MAX_DMA32_PFN ) || - iommu_pass_through) + iommu_pass_through || !xen_swiotlb)
This doesn't apply to the xen/dom0/swiotlb-new branch.
arch/x86/kernel/pci-swiotlb.c void __init pci_swiotlb_init(void)
Quoted 5 lines
arch/x86/kernel/pci-swiotlb.c +1
-1swiotlb =1 ;#endif -if (swiotlb_force) +if (swiotlb_force || !xen_swiotlb)
Are you sure this is right? This will always enable swiotlb if !xen_swiotlb.
J
Re: Re: [PATCH 2/2] Introduce xen_swiotlb variable that is set when Xen is running.
Quoted 120 lines · Jeremy Fitzhardinge
Quoted 118 lines · Konrad Rzeszutek Wilk
Having the '
xen_swiotlb' variable enabled causes all of the IOMMU's to be disabled (except the Xen-SWIOTLB). It is in essence a copy of what swiotlb variable does. However the swiotlb variable cannot be used because it would turn on the non-Xen SWIOTLB.--- arch/x86/include/asm/dma-mapping.h | 1 + arch/x86/include/asm/xen/swiotlb.h | 4 +++- arch/x86/kernel/amd_iommu_init.c | 2 +- arch/x86/kernel/aperture_64.c | 2 +- arch/x86/kernel/pci-calgary_64.c | 2 +- arch/x86/kernel/pci-dma.c | 4 ++-- arch/x86/kernel/pci-gart_64.c | 2 +- arch/x86/kernel/pci-swiotlb.c | 4 ++-- arch/x86/xen/pci-swiotlb.c | 3 +++ 9 files changed, 15 insertions(+), 9 deletions(-)arch/x86/include/asm/dma-mapping.h +1
-0@@ -12,6 +12,7 @@#include <linux/dma-attrs.h> #include <asm/io.h> #include <asm/swiotlb.h> +#include <asm/xen/swiotlb.h> #include <asm-generic/dma-coherent.h> extern dma_addr_t bad_dma_address;arch/x86/include/asm/xen/swiotlb.h +3
-1@@ -2,9 +2,11 @@#define _ASM_X86_XEN_SWIOTLB_H#ifdef CONFIG_PCI_XEN +extern int xen_swiotlb;extern void xen_swiotlb_init (void );#else -static void xen_swiotlb_init (void ) { } +#define xen_swiotlb 0 +static inline void xen_swiotlb_init (void ) { }#endif #endif arch/x86/kernel/amd_iommu_init.c +1
-1@@ -1304,7 +1304,7 @@ static int __init early_amd_iommu_detect(struct acpi_table_header *table)void __init amd_iommu_detect (void ) { -if (swiotlb || no_iommu || (iommu_detected && !gart_iommu_aperture)) +if (swiotlb || xen_swiotlb || no_iommu || (iommu_detected && !gart_iommu_aperture))return ;if (acpi_table_parse ("IVRS" , early_amd_iommu_detect) ==0 ) {arch/x86/kernel/aperture_64.c +1
-1@@ -369,7 +369,7 @@ void __init gart_iommu_hole_init(void)int fix, slot, valid_agp =0 ;int i, node; -if (gart_iommu_aperture_disabled || !fix_aperture || +if (gart_iommu_aperture_disabled || !fix_aperture || xen_swiotlb || !early_pci_allowed ())return ;arch/x86/kernel/pci-calgary_64.c +1
-1@@ -1357,7 +1357,7 @@ void __init detect_calgary(void)* if the user specified iommu=off or iommu=soft or we found * another HW IOMMU already, bail out. */ -if (swiotlb || no_iommu || iommu_detected) +if (swiotlb || xen_swiotlb || no_iommu || iommu_detected)return ;if (!use_calgary)arch/x86/kernel/pci-dma.c +2
-2@@ -122,6 +122,8 @@ void __init pci_iommu_alloc(void)* The order of these functions is important for * fall-back/fail-over reasons */ +xen_swiotlb_init (); +gart_iommu_hole_init ();detect_calgary ();@@ -130,8 +132,6 @@ void __init pci_iommu_alloc(void)amd_iommu_detect (); -xen_swiotlb_init (); -pci_swiotlb_init (); }arch/x86/kernel/pci-gart_64.c +1
-1@@ -730,7 +730,7 @@ void __init gart_iommu_init(void) (agp_copy_info (agp_bridge, &info) <0 );#endif -if (swiotlb) +if (swiotlb || xen_swiotlb)return ;
Quoted 15 lines
arch/x86/kernel/pci-swiotlb.c void __init pci_swiotlb_init(void) · line 52
Quoted 13 lines
arch/x86/kernel/pci-gart_64.c +0
-0/* Did we detect a different HW IOMMU? */ arch/x86/kernel/pci-swiotlb.c +1
-1@@ -47,10 +47,10 @@ void __init pci_swiotlb_init(void)/* don't initialize swiotlb if iommu=off (no_iommu=1) */ #ifdef CONFIG_X86_64 if ((!iommu_detected && !no_iommu && max_pfn >MAX_DMA32_PFN ) || - iommu_pass_through) + iommu_pass_through || !xen_swiotlb)This doesn't apply to the xen/dom0/swiotlb-new branch.
OK, its against xen/master.
Quoted 9 lines
arch/x86/kernel/pci-swiotlb.c void __init pci_swiotlb_init(void) · line 56
Quoted 6 lines
arch/x86/kernel/pci-swiotlb.c +1
-1swiotlb =1 ;#endif -if (swiotlb_force) +if (swiotlb_force || !xen_swiotlb)Are you sure this is right? This will always enable swiotlb if !xen_swiotlb.
I went with this instead:
arch/x86/kernel/pci-swiotlb.c +3 -0
@@ -45,6 +45,9 @@ static struct dma_map_ops swiotlb_dma_ops = {void __init pci_swiotlb_init (void ) {/* don't initialize swiotlb if iommu=off (no_iommu=1) */ +if (xen_swiotlb) +return ; +#ifdef CONFIG_X86_64 if (!iommu_detected && !no_iommu && max_pfn >MAX_DMA32_PFN ) swiotlb =1 ;
Does that work?
J
Re: Re: [PATCH 2/2] Introduce xen_swiotlb variable that is set when Xen is running.
Quoted 4 lines
Quoted 2 lines
This doesn't apply to the xen/dom0/swiotlb-new branch.
OK, its against xen/master.
Do you want me to send patches against the swiotlb-new branch instead in the future?
Quoted 9 lines
Quoted 9 lines
Review
Quoted 7 lines
(quoted diff) +1
-1swiotlb = 1; #endif - if (swiotlb_force) + if (swiotlb_force || !xen_swiotlb)Are you sure this is right? This will always enable swiotlb if !xen_swiotlb.
That is wrong. Thanks for spotting that.
Quoted 19 lines
Quoted 1 line
I went with this instead:
arch/x86/kernel/pci-swiotlb.c +3
-0@@ -45,6 +45,9 @@ static struct dma_map_ops swiotlb_dma_ops = {void __init pci_swiotlb_init (void ) {/* don't initialize swiotlb if iommu=off (no_iommu=1) */ +if (xen_swiotlb) +return ; +#ifdef CONFIG_X86_64 if (!iommu_detected && !no_iommu && max_pfn >MAX_DMA32_PFN ) swiotlb =1 ;
Quoted 1 line
Does that work?
Yes. That will do it.
Re: Re: [PATCH 2/2] Introduce xen_swiotlb variable that is set when Xen is running.
Quoted 2 lines · Konrad Rzeszutek Wilk
Do you want me to send patches against the swiotlb-new branch instead in the future?
Yeah. I never apply patches to xen/master if I can possibly help it; its just the result of merging. All the real work should be happening on the appropriate topic branches. The only time I'd apply something to xen/master is to fix up some kind of merge-related problem.
J