aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2009-01-05 09:36:12 -0500
committerIngo Molnar <mingo@elte.hu>2009-01-06 08:06:50 -0500
commit4d9b977ca674dd40cfc1409a75cb73fca2cee423 (patch)
tree417f80889ab49c61c2258b157cfe993bdf8d8357 /arch
parentc82e4417ace9a3a4dddf3332379c771c41040040 (diff)
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>
Diffstat (limited to 'arch')
-rw-r--r--arch/ia64/hp/common/hwsw_iommu.c3
-rw-r--r--arch/ia64/hp/common/sba_iommu.c9
-rw-r--r--arch/ia64/include/asm/machvec.h4
-rw-r--r--arch/ia64/include/asm/machvec_hpzx1.h3
-rw-r--r--arch/ia64/include/asm/machvec_sn2.h3
-rw-r--r--arch/ia64/kernel/Makefile2
-rw-r--r--arch/ia64/kernel/dma-mapping.c4
-rw-r--r--arch/ia64/kernel/pci-dma.c6
-rw-r--r--arch/ia64/kernel/pci-swiotlb.c6
-rw-r--r--arch/ia64/sn/pci/pci_dma.c5
10 files changed, 38 insertions, 7 deletions
diff --git a/arch/ia64/hp/common/hwsw_iommu.c b/arch/ia64/hp/common/hwsw_iommu.c
index a40dcdd22eeb..22145ded58f6 100644
--- a/arch/ia64/hp/common/hwsw_iommu.c
+++ b/arch/ia64/hp/common/hwsw_iommu.c
@@ -56,9 +56,12 @@ use_swiotlb (struct device *dev)
56 return dev && dev->dma_mask && !hwiommu_dma_supported(dev, *dev->dma_mask); 56 return dev && dev->dma_mask && !hwiommu_dma_supported(dev, *dev->dma_mask);
57} 57}
58 58
59struct dma_mapping_ops hwsw_dma_ops;
60
59void __init 61void __init
60hwsw_init (void) 62hwsw_init (void)
61{ 63{
64 dma_ops = &hwsw_dma_ops;
62 /* default to a smallish 2MB sw I/O TLB */ 65 /* default to a smallish 2MB sw I/O TLB */
63 if (swiotlb_late_init_with_default_size (2 * (1<<20)) != 0) { 66 if (swiotlb_late_init_with_default_size (2 * (1<<20)) != 0) {
64#ifdef CONFIG_IA64_GENERIC 67#ifdef CONFIG_IA64_GENERIC
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index 655b9a17db93..e82870a76801 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -2065,6 +2065,8 @@ static struct acpi_driver acpi_sba_ioc_driver = {
2065 }, 2065 },
2066}; 2066};
2067 2067
2068extern struct dma_mapping_ops swiotlb_dma_ops;
2069
2068static int __init 2070static int __init
2069sba_init(void) 2071sba_init(void)
2070{ 2072{
@@ -2078,6 +2080,7 @@ sba_init(void)
2078 * a successful kdump kernel boot is to use the swiotlb. 2080 * a successful kdump kernel boot is to use the swiotlb.
2079 */ 2081 */
2080 if (is_kdump_kernel()) { 2082 if (is_kdump_kernel()) {
2083 dma_ops = &swiotlb_dma_ops;
2081 if (swiotlb_late_init_with_default_size(64 * (1<<20)) != 0) 2084 if (swiotlb_late_init_with_default_size(64 * (1<<20)) != 0)
2082 panic("Unable to initialize software I/O TLB:" 2085 panic("Unable to initialize software I/O TLB:"
2083 " Try machvec=dig boot option"); 2086 " Try machvec=dig boot option");
@@ -2093,6 +2096,7 @@ sba_init(void)
2093 * If we didn't find something sba_iommu can claim, we 2096 * If we didn't find something sba_iommu can claim, we
2094 * need to setup the swiotlb and switch to the dig machvec. 2097 * need to setup the swiotlb and switch to the dig machvec.
2095 */ 2098 */
2099 dma_ops = &swiotlb_dma_ops;
2096 if (swiotlb_late_init_with_default_size(64 * (1<<20)) != 0) 2100 if (swiotlb_late_init_with_default_size(64 * (1<<20)) != 0)
2097 panic("Unable to find SBA IOMMU or initialize " 2101 panic("Unable to find SBA IOMMU or initialize "
2098 "software I/O TLB: Try machvec=dig boot option"); 2102 "software I/O TLB: Try machvec=dig boot option");
@@ -2196,3 +2200,8 @@ struct dma_mapping_ops sba_dma_ops = {
2196 .dma_supported_op = sba_dma_supported, 2200 .dma_supported_op = sba_dma_supported,
2197 .mapping_error = sba_dma_mapping_error, 2201 .mapping_error = sba_dma_mapping_error,
2198}; 2202};
2203
2204void sba_dma_init(void)
2205{
2206 dma_ops = &sba_dma_ops;
2207}
diff --git a/arch/ia64/include/asm/machvec.h b/arch/ia64/include/asm/machvec.h
index 59c17e446683..d40722c386b4 100644
--- a/arch/ia64/include/asm/machvec.h
+++ b/arch/ia64/include/asm/machvec.h
@@ -298,6 +298,8 @@ extern void machvec_init_from_cmdline(const char *cmdline);
298# error Unknown configuration. Update arch/ia64/include/asm/machvec.h. 298# error Unknown configuration. Update arch/ia64/include/asm/machvec.h.
299# endif /* CONFIG_IA64_GENERIC */ 299# endif /* CONFIG_IA64_GENERIC */
300 300
301extern void swiotlb_dma_init(void);
302
301/* 303/*
302 * Define default versions so we can extend machvec for new platforms without having 304 * Define default versions so we can extend machvec for new platforms without having
303 * to update the machvec files for all existing platforms. 305 * to update the machvec files for all existing platforms.
@@ -328,7 +330,7 @@ extern void machvec_init_from_cmdline(const char *cmdline);
328# define platform_kernel_launch_event machvec_noop 330# define platform_kernel_launch_event machvec_noop
329#endif 331#endif
330#ifndef platform_dma_init 332#ifndef platform_dma_init
331# define platform_dma_init swiotlb_init 333# define platform_dma_init swiotlb_dma_init
332#endif 334#endif
333#ifndef platform_dma_alloc_coherent 335#ifndef platform_dma_alloc_coherent
334# define platform_dma_alloc_coherent swiotlb_alloc_coherent 336# define platform_dma_alloc_coherent swiotlb_alloc_coherent
diff --git a/arch/ia64/include/asm/machvec_hpzx1.h b/arch/ia64/include/asm/machvec_hpzx1.h
index 2f57f5144b9f..dd4140b4dd2f 100644
--- a/arch/ia64/include/asm/machvec_hpzx1.h
+++ b/arch/ia64/include/asm/machvec_hpzx1.h
@@ -2,6 +2,7 @@
2#define _ASM_IA64_MACHVEC_HPZX1_h 2#define _ASM_IA64_MACHVEC_HPZX1_h
3 3
4extern ia64_mv_setup_t dig_setup; 4extern ia64_mv_setup_t dig_setup;
5extern ia64_mv_dma_init sba_dma_init;
5extern ia64_mv_dma_alloc_coherent sba_alloc_coherent; 6extern ia64_mv_dma_alloc_coherent sba_alloc_coherent;
6extern ia64_mv_dma_free_coherent sba_free_coherent; 7extern ia64_mv_dma_free_coherent sba_free_coherent;
7extern ia64_mv_dma_map_single_attrs sba_map_single_attrs; 8extern ia64_mv_dma_map_single_attrs sba_map_single_attrs;
@@ -20,7 +21,7 @@ extern ia64_mv_dma_mapping_error sba_dma_mapping_error;
20 */ 21 */
21#define platform_name "hpzx1" 22#define platform_name "hpzx1"
22#define platform_setup dig_setup 23#define platform_setup dig_setup
23#define platform_dma_init machvec_noop 24#define platform_dma_init sba_dma_init
24#define platform_dma_alloc_coherent sba_alloc_coherent 25#define platform_dma_alloc_coherent sba_alloc_coherent
25#define platform_dma_free_coherent sba_free_coherent 26#define platform_dma_free_coherent sba_free_coherent
26#define platform_dma_map_single_attrs sba_map_single_attrs 27#define platform_dma_map_single_attrs sba_map_single_attrs
diff --git a/arch/ia64/include/asm/machvec_sn2.h b/arch/ia64/include/asm/machvec_sn2.h
index 781308ea7b88..c1f6f871da81 100644
--- a/arch/ia64/include/asm/machvec_sn2.h
+++ b/arch/ia64/include/asm/machvec_sn2.h
@@ -55,6 +55,7 @@ extern ia64_mv_readb_t __sn_readb_relaxed;
55extern ia64_mv_readw_t __sn_readw_relaxed; 55extern ia64_mv_readw_t __sn_readw_relaxed;
56extern ia64_mv_readl_t __sn_readl_relaxed; 56extern ia64_mv_readl_t __sn_readl_relaxed;
57extern ia64_mv_readq_t __sn_readq_relaxed; 57extern ia64_mv_readq_t __sn_readq_relaxed;
58extern ia64_mv_dma_init sn_dma_init;
58extern ia64_mv_dma_alloc_coherent sn_dma_alloc_coherent; 59extern ia64_mv_dma_alloc_coherent sn_dma_alloc_coherent;
59extern ia64_mv_dma_free_coherent sn_dma_free_coherent; 60extern ia64_mv_dma_free_coherent sn_dma_free_coherent;
60extern ia64_mv_dma_map_single_attrs sn_dma_map_single_attrs; 61extern ia64_mv_dma_map_single_attrs sn_dma_map_single_attrs;
@@ -110,7 +111,7 @@ extern ia64_mv_pci_fixup_bus_t sn_pci_fixup_bus;
110#define platform_pci_get_legacy_mem sn_pci_get_legacy_mem 111#define platform_pci_get_legacy_mem sn_pci_get_legacy_mem
111#define platform_pci_legacy_read sn_pci_legacy_read 112#define platform_pci_legacy_read sn_pci_legacy_read
112#define platform_pci_legacy_write sn_pci_legacy_write 113#define platform_pci_legacy_write sn_pci_legacy_write
113#define platform_dma_init machvec_noop 114#define platform_dma_init sn_dma_init
114#define platform_dma_alloc_coherent sn_dma_alloc_coherent 115#define platform_dma_alloc_coherent sn_dma_alloc_coherent
115#define platform_dma_free_coherent sn_dma_free_coherent 116#define platform_dma_free_coherent sn_dma_free_coherent
116#define platform_dma_map_single_attrs sn_dma_map_single_attrs 117#define platform_dma_map_single_attrs sn_dma_map_single_attrs
diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile
index bc1f62a5cfd0..f2778f2c4fd9 100644
--- a/arch/ia64/kernel/Makefile
+++ b/arch/ia64/kernel/Makefile
@@ -7,7 +7,7 @@ extra-y := head.o init_task.o vmlinux.lds
7obj-y := acpi.o entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o irq_ia64.o \ 7obj-y := acpi.o entry.o efi.o efi_stub.o gate-data.o fsys.o ia64_ksyms.o irq.o irq_ia64.o \
8 irq_lsapic.o ivt.o machvec.o pal.o patch.o process.o perfmon.o ptrace.o sal.o \ 8 irq_lsapic.o ivt.o machvec.o pal.o patch.o process.o perfmon.o ptrace.o sal.o \
9 salinfo.o setup.o signal.o sys_ia64.o time.o traps.o unaligned.o \ 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
12obj-$(CONFIG_IA64_BRL_EMU) += brl_emu.o 12obj-$(CONFIG_IA64_BRL_EMU) += brl_emu.o
13obj-$(CONFIG_IA64_GENERIC) += acpi-ext.o 13obj-$(CONFIG_IA64_GENERIC) += acpi-ext.o
diff --git a/arch/ia64/kernel/dma-mapping.c b/arch/ia64/kernel/dma-mapping.c
new file mode 100644
index 000000000000..876665ae9fff
--- /dev/null
+++ b/arch/ia64/kernel/dma-mapping.c
@@ -0,0 +1,4 @@
1#include <linux/dma-mapping.h>
2
3struct dma_mapping_ops *dma_ops;
4EXPORT_SYMBOL(dma_ops);
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c
index f8c38bd2c368..1c1224bd0179 100644
--- a/arch/ia64/kernel/pci-dma.c
+++ b/arch/ia64/kernel/pci-dma.c
@@ -41,8 +41,11 @@ struct device fallback_dev = {
41 .dma_mask = &fallback_dev.coherent_dma_mask, 41 .dma_mask = &fallback_dev.coherent_dma_mask,
42}; 42};
43 43
44extern struct dma_mapping_ops vtd_dma_ops;
45
44void __init pci_iommu_alloc(void) 46void __init pci_iommu_alloc(void)
45{ 47{
48 dma_ops = &vtd_dma_ops;
46 /* 49 /*
47 * The order of these functions is important for 50 * The order of these functions is important for
48 * fall-back/fail-over reasons 51 * fall-back/fail-over reasons
@@ -76,9 +79,6 @@ iommu_dma_init(void)
76 return; 79 return;
77} 80}
78 81
79struct dma_mapping_ops *dma_ops;
80EXPORT_SYMBOL(dma_ops);
81
82int iommu_dma_supported(struct device *dev, u64 mask) 82int iommu_dma_supported(struct device *dev, u64 mask)
83{ 83{
84 struct dma_mapping_ops *ops = get_dma_ops(dev); 84 struct dma_mapping_ops *ops = get_dma_ops(dev);
diff --git a/arch/ia64/kernel/pci-swiotlb.c b/arch/ia64/kernel/pci-swiotlb.c
index b62fb932b99a..9f172c864377 100644
--- a/arch/ia64/kernel/pci-swiotlb.c
+++ b/arch/ia64/kernel/pci-swiotlb.c
@@ -37,6 +37,12 @@ struct dma_mapping_ops swiotlb_dma_ops = {
37 .mapping_error = swiotlb_dma_mapping_error, 37 .mapping_error = swiotlb_dma_mapping_error,
38}; 38};
39 39
40void swiotlb_dma_init(void)
41{
42 dma_ops = &swiotlb_dma_ops;
43 swiotlb_init();
44}
45
40void __init pci_swiotlb_init(void) 46void __init pci_swiotlb_init(void)
41{ 47{
42 if (!iommu_detected) { 48 if (!iommu_detected) {
diff --git a/arch/ia64/sn/pci/pci_dma.c b/arch/ia64/sn/pci/pci_dma.c
index 4ad13ff7cf1e..174a74e63882 100644
--- a/arch/ia64/sn/pci/pci_dma.c
+++ b/arch/ia64/sn/pci/pci_dma.c
@@ -481,3 +481,8 @@ struct dma_mapping_ops sn_dma_ops = {
481 .mapping_error = sn_dma_mapping_error, 481 .mapping_error = sn_dma_mapping_error,
482 .dma_supported_op = sn_dma_supported, 482 .dma_supported_op = sn_dma_supported,
483}; 483};
484
485void sn_dma_init(void)
486{
487 dma_ops = &sn_dma_ops;
488}