x86: unify pci iommu setup and allow swiotlb to compile for 32 bit
authorJeremy Fitzhardinge <jeremy@goop.org>
Tue, 16 Dec 2008 20:17:36 +0000 (12:17 -0800)
committerIngo Molnar <mingo@elte.hu>
Wed, 17 Dec 2008 17:58:19 +0000 (18:58 +0100)
swiotlb on 32 bit will be used by Xen domain 0 support.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/include/asm/dma-mapping.h
arch/x86/include/asm/pci.h
arch/x86/include/asm/pci_64.h
arch/x86/kernel/Makefile
arch/x86/kernel/pci-dma.c
arch/x86/kernel/pci-swiotlb_64.c
arch/x86/mm/init_32.c

index 097794ff6b796a2f955ddc7a8eef96a249c8b94f..3b43a65894c4ac44c5c96e6a736d12ec1ceeb664 100644 (file)
@@ -65,7 +65,7 @@ static inline struct dma_mapping_ops *get_dma_ops(struct device *dev)
                return dma_ops;
        else
                return dev->archdata.dma_ops;
-#endif /* _ASM_X86_DMA_MAPPING_H */
+#endif
 }
 
 /* Make sure we keep the same behaviour */
index 875b38edf19383f0e1176b9a73dede0f49f42c38..50ac542c9382ec371aa336e937bd6bc779a52581 100644 (file)
@@ -82,6 +82,8 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 static inline void early_quirks(void) { }
 #endif
 
+extern void pci_iommu_alloc(void);
+
 #endif  /* __KERNEL__ */
 
 #ifdef CONFIG_X86_32
index d02d936840a3ed8e3b7f94fade13929c9a3d6413..4da207982777e75a970fca5fee80cb2883381e4e 100644 (file)
@@ -23,7 +23,6 @@ extern int (*pci_config_write)(int seg, int bus, int dev, int fn,
                               int reg, int len, u32 value);
 
 extern void dma32_reserve_bootmem(void);
-extern void pci_iommu_alloc(void);
 
 /* The PCI address space does equal the physical memory
  * address space.  The networking and block device layers use
index b62a7667828eb77574128a8ca82b1f54cee28238..a9c656f2d6613c0339d05c4fb100022d80c1a755 100644 (file)
@@ -105,6 +105,8 @@ microcode-$(CONFIG_MICROCODE_INTEL) += microcode_intel.o
 microcode-$(CONFIG_MICROCODE_AMD)      += microcode_amd.o
 obj-$(CONFIG_MICROCODE)                        += microcode.o
 
+obj-$(CONFIG_SWIOTLB)                  += pci-swiotlb_64.o # NB rename without _64
+
 ###
 # 64 bit specific files
 ifeq ($(CONFIG_X86_64),y)
@@ -118,7 +120,6 @@ ifeq ($(CONFIG_X86_64),y)
         obj-$(CONFIG_GART_IOMMU)       += pci-gart_64.o aperture_64.o
         obj-$(CONFIG_CALGARY_IOMMU)    += pci-calgary_64.o tce_64.o
         obj-$(CONFIG_AMD_IOMMU)                += amd_iommu_init.o amd_iommu.o
-        obj-$(CONFIG_SWIOTLB)          += pci-swiotlb_64.o
 
         obj-$(CONFIG_PCI_MMCONFIG)     += mmconf-fam10h_64.o
 endif
index e150ad4f0cccbc5ca03a5959be72787c49476ab5..00e07447a5bd4881f474e843f5a93abdf52fcb49 100644 (file)
@@ -105,11 +105,15 @@ static void __init dma32_free_bootmem(void)
        dma32_bootmem_ptr = NULL;
        dma32_bootmem_size = 0;
 }
+#endif
 
 void __init pci_iommu_alloc(void)
 {
+#ifdef CONFIG_X86_64
        /* free the range so iommu could get some range less than 4G */
        dma32_free_bootmem();
+#endif
+
        /*
         * The order of these functions is important for
         * fall-back/fail-over reasons
@@ -125,8 +129,6 @@ void __init pci_iommu_alloc(void)
        pci_swiotlb_init();
 }
 
-#endif
-
 void *dma_generic_alloc_coherent(struct device *dev, size_t size,
                                 dma_addr_t *dma_addr, gfp_t flag)
 {
index f47a097a135bb0f25e7b06498d178b22635763f9..a991afea6700904e909a527d59d9c7f511d024bb 100644 (file)
@@ -62,8 +62,10 @@ struct dma_mapping_ops swiotlb_dma_ops = {
 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)
               swiotlb = 1;
+#endif
        if (swiotlb_force)
                swiotlb = 1;
        if (swiotlb) {
index c483f424207938cc16ff3a2eb6b92eee5175e6b5..2b4b14fc0c048ba683776f59282b5d64574c4bd9 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/init.h>
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
+#include <linux/pci.h>
 #include <linux/pfn.h>
 #include <linux/poison.h>
 #include <linux/bootmem.h>
@@ -971,6 +972,8 @@ void __init mem_init(void)
 
        start_periodic_check_for_corruption();
 
+       pci_iommu_alloc();
+
 #ifdef CONFIG_FLATMEM
        BUG_ON(!mem_map);
 #endif