Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/swiotlb: Enable at early stage and disable if not necessary

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>

authored by

Jia Hongtao and committed by
Kumar Gala
688ba1db 39be5b4a

+32 -14
+6
arch/powerpc/include/asm/swiotlb.h
··· 22 22 23 23 extern void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev); 24 24 25 + #ifdef CONFIG_SWIOTLB 26 + void swiotlb_detect_4g(void); 27 + #else 28 + static inline void swiotlb_detect_4g(void) {} 29 + #endif 30 + 25 31 #endif /* __ASM_SWIOTLB_H */
+20
arch/powerpc/kernel/dma-swiotlb.c
··· 105 105 &ppc_swiotlb_plat_bus_notifier); 106 106 return 0; 107 107 } 108 + 109 + void swiotlb_detect_4g(void) 110 + { 111 + if ((memblock_end_of_DRAM() - 1) > 0xffffffff) 112 + ppc_swiotlb_enable = 1; 113 + } 114 + 115 + static int __init swiotlb_late_init(void) 116 + { 117 + if (ppc_swiotlb_enable) { 118 + swiotlb_print_info(); 119 + set_pci_dma_ops(&swiotlb_dma_ops); 120 + ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; 121 + } else { 122 + swiotlb_free(); 123 + } 124 + 125 + return 0; 126 + } 127 + subsys_initcall(swiotlb_late_init);
+1 -2
arch/powerpc/mm/mem.c
··· 300 300 unsigned long reservedpages = 0, codesize, initsize, datasize, bsssize; 301 301 302 302 #ifdef CONFIG_SWIOTLB 303 - if (ppc_swiotlb_enable) 304 - swiotlb_init(1); 303 + swiotlb_init(0); 305 304 #endif 306 305 307 306 num_physpages = memblock_phys_mem_size() >> PAGE_SHIFT;
+2 -8
arch/powerpc/platforms/44x/currituck.c
··· 21 21 */ 22 22 23 23 #include <linux/init.h> 24 - #include <linux/memblock.h> 25 24 #include <linux/of.h> 26 25 #include <linux/of_platform.h> 27 26 #include <linux/rtc.h> ··· 158 159 159 160 /* No need to check the DMA config as we /know/ our windows are all of 160 161 * RAM. Lets hope that doesn't change */ 161 - #ifdef CONFIG_SWIOTLB 162 - if ((memblock_end_of_DRAM() - 1) > 0xffffffff) { 163 - ppc_swiotlb_enable = 1; 164 - set_pci_dma_ops(&swiotlb_dma_ops); 165 - ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; 166 - } 167 - #endif 162 + swiotlb_detect_4g(); 163 + 168 164 ppc47x_smp_init(); 169 165 } 170 166
+1
arch/powerpc/platforms/85xx/mpc85xx_ds.c
··· 159 159 if (ppc_md.progress) 160 160 ppc_md.progress("mpc85xx_ds_setup_arch()", 0); 161 161 162 + swiotlb_detect_4g(); 162 163 mpc85xx_ds_pci_init(); 163 164 mpc85xx_smp_init(); 164 165
+1
arch/powerpc/platforms/85xx/qemu_e500.c
··· 42 42 ppc_md.progress("qemu_e500_setup_arch()", 0); 43 43 44 44 fsl_pci_init(); 45 + swiotlb_detect_4g(); 45 46 mpc85xx_smp_init(); 46 47 } 47 48
+1 -4
arch/powerpc/sysdev/fsl_pci.c
··· 872 872 * we need SWIOTLB to handle buffers located outside of 873 873 * dma capable memory region 874 874 */ 875 - if (memblock_end_of_DRAM() - 1 > max) { 875 + if (memblock_end_of_DRAM() - 1 > max) 876 876 ppc_swiotlb_enable = 1; 877 - set_pci_dma_ops(&swiotlb_dma_ops); 878 - ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; 879 - } 880 877 #endif 881 878 } 882 879 #endif