]> git.karo-electronics.de Git - linux-beck.git/commitdiff
powerpc/swiotlb: Enable at early stage and disable if not necessary
authorJia Hongtao <B38951@freescale.com>
Fri, 3 Aug 2012 10:14:10 +0000 (18:14 +0800)
committerKumar Gala <galak@kernel.crashing.org>
Wed, 12 Sep 2012 19:57:09 +0000 (14:57 -0500)
Remove the dependency on PCI initialization for SWIOTLB initialization.
So that PCI can be initialized at proper time.

SWIOTLB is partly determined by PCI inbound/outbound map which is assigned
in PCI initialization. But swiotlb_init() should be done at the stage of
mem_init() which is much earlier than PCI initialization. So we reserve the
memory for SWIOTLB first and free it if not necessary.

All boards are converted to fit this change.

Signed-off-by: Jia Hongtao <B38951@freescale.com>
Signed-off-by: Li Yang <leoli@freescale.com>
Acked-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
arch/powerpc/include/asm/swiotlb.h
arch/powerpc/kernel/dma-swiotlb.c
arch/powerpc/mm/mem.c
arch/powerpc/platforms/44x/currituck.c
arch/powerpc/platforms/85xx/mpc85xx_ds.c
arch/powerpc/platforms/85xx/qemu_e500.c
arch/powerpc/sysdev/fsl_pci.c

index 8979d4cd3d70500fc1f0dbada65b9f834e020faa..de99d6e29430341623fd8a0f6ee3d3a4c4e1a768 100644 (file)
@@ -22,4 +22,10 @@ int __init swiotlb_setup_bus_notifier(void);
 
 extern void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev);
 
+#ifdef CONFIG_SWIOTLB
+void swiotlb_detect_4g(void);
+#else
+static inline void swiotlb_detect_4g(void) {}
+#endif
+
 #endif /* __ASM_SWIOTLB_H */
index a720b54b971cd1f2a81a33e5168b3836678864cd..bd1a2aba599f59aaee4d31d9d971f5afb9d5bca4 100644 (file)
@@ -105,3 +105,23 @@ int __init swiotlb_setup_bus_notifier(void)
                              &ppc_swiotlb_plat_bus_notifier);
        return 0;
 }
+
+void swiotlb_detect_4g(void)
+{
+       if ((memblock_end_of_DRAM() - 1) > 0xffffffff)
+               ppc_swiotlb_enable = 1;
+}
+
+static int __init swiotlb_late_init(void)
+{
+       if (ppc_swiotlb_enable) {
+               swiotlb_print_info();
+               set_pci_dma_ops(&swiotlb_dma_ops);
+               ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
+       } else {
+               swiotlb_free();
+       }
+
+       return 0;
+}
+subsys_initcall(swiotlb_late_init);
index 44cf2b20503da71f491177ac5252664ea200c498..0dba5066c22ac4f59578c3663c212f8a07ca3a78 100644 (file)
@@ -300,8 +300,7 @@ void __init mem_init(void)
        unsigned long reservedpages = 0, codesize, initsize, datasize, bsssize;
 
 #ifdef CONFIG_SWIOTLB
-       if (ppc_swiotlb_enable)
-               swiotlb_init(1);
+       swiotlb_init(0);
 #endif
 
        num_physpages = memblock_phys_mem_size() >> PAGE_SHIFT;
index 9f6c33d63a42c207a80444650646c1b3a1af7d08..6bd89a0e0dead4dcf112baca8aca5a0380f84a8c 100644 (file)
@@ -21,7 +21,6 @@
  */
 
 #include <linux/init.h>
-#include <linux/memblock.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/rtc.h>
@@ -159,13 +158,8 @@ static void __init ppc47x_setup_arch(void)
 
        /* No need to check the DMA config as we /know/ our windows are all of
         * RAM.  Lets hope that doesn't change */
-#ifdef CONFIG_SWIOTLB
-       if ((memblock_end_of_DRAM() - 1) > 0xffffffff) {
-               ppc_swiotlb_enable = 1;
-               set_pci_dma_ops(&swiotlb_dma_ops);
-               ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
-       }
-#endif
+       swiotlb_detect_4g();
+
        ppc47x_smp_init();
 }
 
index 6d3265fe7718c7ff71785329133013ec1382c979..56f8c8f674df108d46d4f69866475b26ae1f1476 100644 (file)
@@ -159,6 +159,7 @@ static void __init mpc85xx_ds_setup_arch(void)
        if (ppc_md.progress)
                ppc_md.progress("mpc85xx_ds_setup_arch()", 0);
 
+       swiotlb_detect_4g();
        mpc85xx_ds_pci_init();
        mpc85xx_smp_init();
 
index 95a2e53af71b6ee66fcbf0013aa1020c85068692..3c5490c8423feecd8ecd545e40e8eceb6a65cae6 100644 (file)
@@ -42,6 +42,7 @@ static void __init qemu_e500_setup_arch(void)
        ppc_md.progress("qemu_e500_setup_arch()", 0);
 
        fsl_pci_init();
+       swiotlb_detect_4g();
        mpc85xx_smp_init();
 }
 
index 6938792ccfd9c4e82071d1d835edefac5bcf20a9..da7a3d7f54cc8a20f685fc9e6abdde6c3fcc987c 100644 (file)
@@ -872,11 +872,8 @@ void __devinit fsl_pci_init(void)
         * we need SWIOTLB to handle buffers located outside of
         * dma capable memory region
         */
-       if (memblock_end_of_DRAM() - 1 > max) {
+       if (memblock_end_of_DRAM() - 1 > max)
                ppc_swiotlb_enable = 1;
-               set_pci_dma_ops(&swiotlb_dma_ops);
-               ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
-       }
 #endif
 }
 #endif