Konrad Rzeszutek Wilk
2009-Sep-14  15:20 UTC
[Xen-devel] [PATCH 2/2] Fix calling order wherein iommu_detected would be set after software IO TLB was initialized causing double IO TLB allocation.
The iommu_detected flag was set _after_ the Software IO TLB was initialized.
This caused the Xen software IO TLB to be init and right after that the software
IO TLB.
Merging xen_swiotlb_init and xen_swiotlb_init_alloc in one function that sets
this argument fixes the issue.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 arch/x86/include/asm/xen/swiotlb.h |    6 ++----
 arch/x86/kernel/pci-dma.c          |    2 +-
 arch/x86/xen/pci-swiotlb.c         |   13 +++----------
 3 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/arch/x86/include/asm/xen/swiotlb.h
b/arch/x86/include/asm/xen/swiotlb.h
index 81d8502..d094f89 100644
--- a/arch/x86/include/asm/xen/swiotlb.h
+++ b/arch/x86/include/asm/xen/swiotlb.h
@@ -2,11 +2,9 @@
 #define _ASM_X86_XEN_SWIOTLB_H
 
 #ifdef CONFIG_PCI_XEN
-extern int xen_swiotlb_init(void);
-extern void xen_swiotlb_init_alloc(void);
+extern void xen_swiotlb_init(void);
 #else
-static inline int xen_swiotlb_init(void) { return -ENODEV; }
-static void xen_swiotlb_init_alloc(void) { }
+static void xen_swiotlb_init(void) { }
 #endif
 
 #endif
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 90da583..4695757 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -130,7 +130,7 @@ void __init pci_iommu_alloc(void)
 
 	amd_iommu_detect();
 
-	xen_swiotlb_init_alloc();
+	xen_swiotlb_init();
 
 	pci_swiotlb_init();
 }
diff --git a/arch/x86/xen/pci-swiotlb.c b/arch/x86/xen/pci-swiotlb.c
index 19b78e2..76194d4 100644
--- a/arch/x86/xen/pci-swiotlb.c
+++ b/arch/x86/xen/pci-swiotlb.c
@@ -970,19 +970,12 @@ static struct dma_map_ops xen_swiotlb_dma_ops = {
 	.dma_supported = NULL,
 };
 
-int __init xen_swiotlb_init(void)
+void __init xen_swiotlb_init(void)
 {
-	if (xen_pv_domain() && xen_initial_domain()) {
-		iommu_detected = 1;
-		return 0;
-	}
-	return -ENODEV;
-}
-void __init xen_swiotlb_init_alloc(void)
-{
-	if (xen_pv_domain() && xen_initial_domain()) {
+	if (xen_initial_domain()) {
 		printk(KERN_INFO "PCI-DMA: Using Xen software bounce buffering for IO
(Xen-SWIOTLB)\n");
 		xen_swiotlb_init_with_default_size(64 * (1<<20));	/* default to 64MB */
 		dma_ops = &xen_swiotlb_dma_ops;
+		iommu_detected = 1;
 	}
 }
-- 
1.6.2.5
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel