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

set up dma_ops appropriately

This patch introduces a global pointer, dma_ops, which points to an
appropriate dma_mapping_ops that the kernel should use. This is a
common way to handle multiple dma_mapping_ops (X86, POWER, and SPARC).

dma_ops is set in platform_dma_init. We also set it by hand where
machvec_init is callev via subsys_initcall.

- IA64_DIG_VTD uses vtd_dma_ops.
- IA64_HP_ZX1 uses sba_dma_ops.
- IA64_HP_ZX1_SWIOTLB uses hwsw_dma_ops.
- IA64_SGI_SN2 uses sn_dma_ops.
- The rest use swiotlb_dma_ops.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by

FUJITA Tomonori and committed by
Ingo Molnar
4d9b977c c82e4417

+38 -7
+3
arch/ia64/hp/common/hwsw_iommu.c
··· 56 56 return dev && dev->dma_mask && !hwiommu_dma_supported(dev, *dev->dma_mask); 57 57 } 58 58 59 + struct dma_mapping_ops hwsw_dma_ops; 60 + 59 61 void __init 60 62 hwsw_init (void) 61 63 { 64 + dma_ops = &hwsw_dma_ops; 62 65 /* default to a smallish 2MB sw I/O TLB */ 63 66 if (swiotlb_late_init_with_default_size (2 * (1<<20)) != 0) { 64 67 #ifdef CONFIG_IA64_GENERIC
+9
arch/ia64/hp/common/sba_iommu.c
··· 2065 2065 }, 2066 2066 }; 2067 2067 2068 + extern struct dma_mapping_ops swiotlb_dma_ops; 2069 + 2068 2070 static int __init 2069 2071 sba_init(void) 2070 2072 { ··· 2080 2078 * a successful kdump kernel boot is to use the swiotlb. 2081 2079 */ 2082 2080 if (is_kdump_kernel()) { 2081 + dma_ops = &swiotlb_dma_ops; 2083 2082 if (swiotlb_late_init_with_default_size(64 * (1<<20)) != 0) 2084 2083 panic("Unable to initialize software I/O TLB:" 2085 2084 " Try machvec=dig boot option"); ··· 2096 2093 * If we didn't find something sba_iommu can claim, we 2097 2094 * need to setup the swiotlb and switch to the dig machvec. 2098 2095 */ 2096 + dma_ops = &swiotlb_dma_ops; 2099 2097 if (swiotlb_late_init_with_default_size(64 * (1<<20)) != 0) 2100 2098 panic("Unable to find SBA IOMMU or initialize " 2101 2099 "software I/O TLB: Try machvec=dig boot option"); ··· 2200 2196 .dma_supported_op = sba_dma_supported, 2201 2197 .mapping_error = sba_dma_mapping_error, 2202 2198 }; 2199 + 2200 + void sba_dma_init(void) 2201 + { 2202 + dma_ops = &sba_dma_ops; 2203 + }
+3 -1
arch/ia64/include/asm/machvec.h
··· 298 298 # error Unknown configuration. Update arch/ia64/include/asm/machvec.h. 299 299 # endif /* CONFIG_IA64_GENERIC */ 300 300 301 + extern void swiotlb_dma_init(void); 302 + 301 303 /* 302 304 * Define default versions so we can extend machvec for new platforms without having 303 305 * to update the machvec files for all existing platforms. ··· 330 328 # define platform_kernel_launch_event machvec_noop 331 329 #endif 332 330 #ifndef platform_dma_init 333 - # define platform_dma_init swiotlb_init 331 + # define platform_dma_init swiotlb_dma_init 334 332 #endif 335 333 #ifndef platform_dma_alloc_coherent 336 334 # define platform_dma_alloc_coherent swiotlb_alloc_coherent
+2 -1
arch/ia64/include/asm/machvec_hpzx1.h
··· 2 2 #define _ASM_IA64_MACHVEC_HPZX1_h 3 3 4 4 extern ia64_mv_setup_t dig_setup; 5 + extern ia64_mv_dma_init sba_dma_init; 5 6 extern ia64_mv_dma_alloc_coherent sba_alloc_coherent; 6 7 extern ia64_mv_dma_free_coherent sba_free_coherent; 7 8 extern ia64_mv_dma_map_single_attrs sba_map_single_attrs; ··· 21 20 */ 22 21 #define platform_name "hpzx1" 23 22 #define platform_setup dig_setup 24 - #define platform_dma_init machvec_noop 23 + #define platform_dma_init sba_dma_init 25 24 #define platform_dma_alloc_coherent sba_alloc_coherent 26 25 #define platform_dma_free_coherent sba_free_coherent 27 26 #define platform_dma_map_single_attrs sba_map_single_attrs
+2 -1
arch/ia64/include/asm/machvec_sn2.h
··· 55 55 extern ia64_mv_readw_t __sn_readw_relaxed; 56 56 extern ia64_mv_readl_t __sn_readl_relaxed; 57 57 extern ia64_mv_readq_t __sn_readq_relaxed; 58 + extern ia64_mv_dma_init sn_dma_init; 58 59 extern ia64_mv_dma_alloc_coherent sn_dma_alloc_coherent; 59 60 extern ia64_mv_dma_free_coherent sn_dma_free_coherent; 60 61 extern ia64_mv_dma_map_single_attrs sn_dma_map_single_attrs; ··· 111 110 #define platform_pci_get_legacy_mem sn_pci_get_legacy_mem 112 111 #define platform_pci_legacy_read sn_pci_legacy_read 113 112 #define platform_pci_legacy_write sn_pci_legacy_write 114 - #define platform_dma_init machvec_noop 113 + #define platform_dma_init sn_dma_init 115 114 #define platform_dma_alloc_coherent sn_dma_alloc_coherent 116 115 #define platform_dma_free_coherent sn_dma_free_coherent 117 116 #define platform_dma_map_single_attrs sn_dma_map_single_attrs
+1 -1
arch/ia64/kernel/Makefile
··· 7 7 obj-y := acpi.o entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o irq_ia64.o \ 8 8 irq_lsapic.o ivt.o machvec.o pal.o patch.o process.o perfmon.o ptrace.o sal.o \ 9 9 salinfo.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o \ 10 - unwind.o mca.o mca_asm.o topology.o 10 + unwind.o mca.o mca_asm.o topology.o dma-mapping.o 11 11 12 12 obj-$(CONFIG_IA64_BRL_EMU) += brl_emu.o 13 13 obj-$(CONFIG_IA64_GENERIC) += acpi-ext.o
+4
arch/ia64/kernel/dma-mapping.c
··· 1 + #include <linux/dma-mapping.h> 2 + 3 + struct dma_mapping_ops *dma_ops; 4 + EXPORT_SYMBOL(dma_ops);
+3 -3
arch/ia64/kernel/pci-dma.c
··· 41 41 .dma_mask = &fallback_dev.coherent_dma_mask, 42 42 }; 43 43 44 + extern struct dma_mapping_ops vtd_dma_ops; 45 + 44 46 void __init pci_iommu_alloc(void) 45 47 { 48 + dma_ops = &vtd_dma_ops; 46 49 /* 47 50 * The order of these functions is important for 48 51 * fall-back/fail-over reasons ··· 78 75 { 79 76 return; 80 77 } 81 - 82 - struct dma_mapping_ops *dma_ops; 83 - EXPORT_SYMBOL(dma_ops); 84 78 85 79 int iommu_dma_supported(struct device *dev, u64 mask) 86 80 {
+6
arch/ia64/kernel/pci-swiotlb.c
··· 37 37 .mapping_error = swiotlb_dma_mapping_error, 38 38 }; 39 39 40 + void swiotlb_dma_init(void) 41 + { 42 + dma_ops = &swiotlb_dma_ops; 43 + swiotlb_init(); 44 + } 45 + 40 46 void __init pci_swiotlb_init(void) 41 47 { 42 48 if (!iommu_detected) {
+5
arch/ia64/sn/pci/pci_dma.c
··· 481 481 .mapping_error = sn_dma_mapping_error, 482 482 .dma_supported_op = sn_dma_supported, 483 483 }; 484 + 485 + void sn_dma_init(void) 486 + { 487 + dma_ops = &sn_dma_ops; 488 + }