aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2019-02-13 02:01:30 -0500
committerMichael Ellerman <mpe@ellerman.id.au>2019-02-18 06:41:04 -0500
commit68005b67d15a1ee5b5ddff965175728e65fa73e7 (patch)
tree7b8a2db46169d2e178cf8f0000592fa8fabfcfaf
parent461db2bdbf3c978e76dd10a04a63fa06bb29114f (diff)
powerpc/dma: use the generic direct mapping bypass
Now that we've switched all the powerpc nommu and swiotlb methods to use the generic dma_direct_* calls we can remove these ops vectors entirely and rely on the common direct mapping bypass that avoids indirect function calls entirely. This also allows to remove a whole lot of boilerplate code related to setting up these operations. Signed-off-by: Christoph Hellwig <hch@lst.de> Tested-by: Christian Zigotzky <chzigotzky@xenosoft.de> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r--arch/powerpc/include/asm/dma-mapping.h9
-rw-r--r--arch/powerpc/include/asm/swiotlb.h3
-rw-r--r--arch/powerpc/kernel/Makefile2
-rw-r--r--arch/powerpc/kernel/dma-swiotlb.c58
-rw-r--r--arch/powerpc/kernel/dma.c62
-rw-r--r--arch/powerpc/kernel/pci-common.c2
-rw-r--r--arch/powerpc/kernel/setup-common.c1
-rw-r--r--arch/powerpc/mm/dma-noncoherent.c6
-rw-r--r--arch/powerpc/platforms/44x/warp.c2
-rw-r--r--arch/powerpc/platforms/85xx/corenet_generic.c4
-rw-r--r--arch/powerpc/platforms/85xx/ge_imp3a.c2
-rw-r--r--arch/powerpc/platforms/85xx/mpc8536_ds.c2
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_ds.c4
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_mds.c4
-rw-r--r--arch/powerpc/platforms/85xx/p1010rdb.c1
-rw-r--r--arch/powerpc/platforms/85xx/p1022_ds.c2
-rw-r--r--arch/powerpc/platforms/85xx/p1022_rdk.c2
-rw-r--r--arch/powerpc/platforms/86xx/mpc86xx_hpcn.c1
-rw-r--r--arch/powerpc/platforms/cell/iommu.c3
-rw-r--r--arch/powerpc/platforms/pasemi/iommu.c2
-rw-r--r--arch/powerpc/platforms/pasemi/setup.c51
-rw-r--r--arch/powerpc/platforms/powernv/npu-dma.c2
-rw-r--r--arch/powerpc/platforms/pseries/vio.c7
-rw-r--r--arch/powerpc/sysdev/fsl_pci.c5
-rw-r--r--drivers/misc/cxl/vphb.c1
25 files changed, 16 insertions, 222 deletions
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 4de9d4ee23c1..93e57e28be28 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -18,14 +18,6 @@
18#include <asm/io.h> 18#include <asm/io.h>
19#include <asm/swiotlb.h> 19#include <asm/swiotlb.h>
20 20
21/* Some dma direct funcs must be visible for use in other dma_ops */
22extern void *__dma_nommu_alloc_coherent(struct device *dev, size_t size,
23 dma_addr_t *dma_handle, gfp_t flag,
24 unsigned long attrs);
25extern void __dma_nommu_free_coherent(struct device *dev, size_t size,
26 void *vaddr, dma_addr_t dma_handle,
27 unsigned long attrs);
28
29static inline unsigned long device_to_mask(struct device *dev) 21static inline unsigned long device_to_mask(struct device *dev)
30{ 22{
31 if (dev->dma_mask && *dev->dma_mask) 23 if (dev->dma_mask && *dev->dma_mask)
@@ -40,7 +32,6 @@ static inline unsigned long device_to_mask(struct device *dev)
40#ifdef CONFIG_PPC64 32#ifdef CONFIG_PPC64
41extern const struct dma_map_ops dma_iommu_ops; 33extern const struct dma_map_ops dma_iommu_ops;
42#endif 34#endif
43extern const struct dma_map_ops dma_nommu_ops;
44 35
45static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) 36static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
46{ 37{
diff --git a/arch/powerpc/include/asm/swiotlb.h b/arch/powerpc/include/asm/swiotlb.h
index 26a0f12b835b..b7d082c0ec25 100644
--- a/arch/powerpc/include/asm/swiotlb.h
+++ b/arch/powerpc/include/asm/swiotlb.h
@@ -13,10 +13,7 @@
13 13
14#include <linux/swiotlb.h> 14#include <linux/swiotlb.h>
15 15
16extern const struct dma_map_ops powerpc_swiotlb_dma_ops;
17
18extern unsigned int ppc_swiotlb_enable; 16extern unsigned int ppc_swiotlb_enable;
19int __init swiotlb_setup_bus_notifier(void);
20 17
21#ifdef CONFIG_SWIOTLB 18#ifdef CONFIG_SWIOTLB
22void swiotlb_detect_4g(void); 19void swiotlb_detect_4g(void);
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index 9bb12cd642ef..8809e287b80d 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -36,7 +36,7 @@ obj-y := cputable.o ptrace.o syscalls.o \
36 process.o systbl.o idle.o \ 36 process.o systbl.o idle.o \
37 signal.o sysfs.o cacheinfo.o time.o \ 37 signal.o sysfs.o cacheinfo.o time.o \
38 prom.o traps.o setup-common.o \ 38 prom.o traps.o setup-common.o \
39 udbg.o misc.o io.o dma.o misc_$(BITS).o \ 39 udbg.o misc.o io.o misc_$(BITS).o \
40 of_platform.o prom_parse.o 40 of_platform.o prom_parse.o
41obj-$(CONFIG_PPC64) += setup_64.o sys_ppc32.o \ 41obj-$(CONFIG_PPC64) += setup_64.o sys_ppc32.o \
42 signal_64.o ptrace32.o \ 42 signal_64.o ptrace32.o \
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index 3a15a7d945e9..132d61c91629 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -10,70 +10,12 @@
10 * option) any later version. 10 * option) any later version.
11 * 11 *
12 */ 12 */
13
14#include <linux/dma-direct.h>
15#include <linux/memblock.h> 13#include <linux/memblock.h>
16#include <linux/pfn.h>
17#include <linux/of_platform.h>
18#include <linux/platform_device.h>
19#include <linux/pci.h>
20
21#include <asm/machdep.h> 14#include <asm/machdep.h>
22#include <asm/swiotlb.h> 15#include <asm/swiotlb.h>
23#include <asm/dma.h>
24 16
25unsigned int ppc_swiotlb_enable; 17unsigned int ppc_swiotlb_enable;
26 18
27/*
28 * At the moment, all platforms that use this code only require
29 * swiotlb to be used if we're operating on HIGHMEM. Since
30 * we don't ever call anything other than map_sg, unmap_sg,
31 * map_page, and unmap_page on highmem, use normal dma_ops
32 * for everything else.
33 */
34const struct dma_map_ops powerpc_swiotlb_dma_ops = {
35 .alloc = dma_direct_alloc,
36 .free = dma_direct_free,
37 .map_sg = dma_direct_map_sg,
38 .unmap_sg = dma_direct_unmap_sg,
39 .dma_supported = dma_direct_supported,
40 .map_page = dma_direct_map_page,
41 .unmap_page = dma_direct_unmap_page,
42 .sync_single_for_cpu = dma_direct_sync_single_for_cpu,
43 .sync_single_for_device = dma_direct_sync_single_for_device,
44 .sync_sg_for_cpu = dma_direct_sync_sg_for_cpu,
45 .sync_sg_for_device = dma_direct_sync_sg_for_device,
46 .get_required_mask = dma_direct_get_required_mask,
47};
48
49static int ppc_swiotlb_bus_notify(struct notifier_block *nb,
50 unsigned long action, void *data)
51{
52 struct device *dev = data;
53
54 /* We are only intereted in device addition */
55 if (action != BUS_NOTIFY_ADD_DEVICE)
56 return 0;
57
58 /* May need to bounce if the device can't address all of DRAM */
59 if ((dma_get_mask(dev) + 1) < memblock_end_of_DRAM())
60 set_dma_ops(dev, &powerpc_swiotlb_dma_ops);
61
62 return NOTIFY_DONE;
63}
64
65static struct notifier_block ppc_swiotlb_plat_bus_notifier = {
66 .notifier_call = ppc_swiotlb_bus_notify,
67 .priority = 0,
68};
69
70int __init swiotlb_setup_bus_notifier(void)
71{
72 bus_register_notifier(&platform_bus_type,
73 &ppc_swiotlb_plat_bus_notifier);
74 return 0;
75}
76
77void __init swiotlb_detect_4g(void) 19void __init swiotlb_detect_4g(void)
78{ 20{
79 if ((memblock_end_of_DRAM() - 1) > 0xffffffff) 21 if ((memblock_end_of_DRAM() - 1) > 0xffffffff)
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
deleted file mode 100644
index b9f7283e7224..000000000000
--- a/arch/powerpc/kernel/dma.c
+++ /dev/null
@@ -1,62 +0,0 @@
1/*
2 * Copyright (C) 2006 Benjamin Herrenschmidt, IBM Corporation
3 *
4 * Provide default implementations of the DMA mapping callbacks for
5 * directly mapped busses.
6 */
7
8#include <linux/device.h>
9#include <linux/dma-direct.h>
10#include <linux/dma-debug.h>
11#include <linux/gfp.h>
12#include <linux/memblock.h>
13#include <linux/export.h>
14#include <linux/pci.h>
15#include <asm/vio.h>
16#include <asm/bug.h>
17#include <asm/machdep.h>
18#include <asm/swiotlb.h>
19#include <asm/iommu.h>
20
21/*
22 * Generic direct DMA implementation
23 *
24 * This implementation supports a per-device offset that can be applied if
25 * the address at which memory is visible to devices is not 0. Platform code
26 * can set archdata.dma_data to an unsigned long holding the offset. By
27 * default the offset is PCI_DRAM_OFFSET.
28 */
29
30const struct dma_map_ops dma_nommu_ops = {
31#ifdef CONFIG_NOT_COHERENT_CACHE
32 .alloc = __dma_nommu_alloc_coherent,
33 .free = __dma_nommu_free_coherent,
34#else
35 .alloc = dma_direct_alloc,
36 .free = dma_direct_free,
37#endif
38 .map_sg = dma_direct_map_sg,
39 .dma_supported = dma_direct_supported,
40 .map_page = dma_direct_map_page,
41 .get_required_mask = dma_direct_get_required_mask,
42#ifdef CONFIG_NOT_COHERENT_CACHE
43 .unmap_sg = dma_direct_unmap_sg,
44 .unmap_page = dma_direct_unmap_page,
45 .sync_single_for_cpu = dma_direct_sync_single_for_cpu,
46 .sync_single_for_device = dma_direct_sync_single_for_device,
47 .sync_sg_for_cpu = dma_direct_sync_sg_for_cpu,
48 .sync_sg_for_device = dma_direct_sync_sg_for_device,
49#endif
50};
51EXPORT_SYMBOL(dma_nommu_ops);
52
53static int __init dma_init(void)
54{
55#ifdef CONFIG_IBMVIO
56 dma_debug_add_bus(&vio_bus_type);
57#endif
58
59 return 0;
60}
61fs_initcall(dma_init);
62
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index a84707680525..23989175349c 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -62,7 +62,7 @@ resource_size_t isa_mem_base;
62EXPORT_SYMBOL(isa_mem_base); 62EXPORT_SYMBOL(isa_mem_base);
63 63
64 64
65static const struct dma_map_ops *pci_dma_ops = &dma_nommu_ops; 65static const struct dma_map_ops *pci_dma_ops;
66 66
67void set_pci_dma_ops(const struct dma_map_ops *dma_ops) 67void set_pci_dma_ops(const struct dma_map_ops *dma_ops)
68{ 68{
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index ca00fbb97cf8..fa606aa98f6d 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -791,7 +791,6 @@ void arch_setup_pdev_archdata(struct platform_device *pdev)
791{ 791{
792 pdev->archdata.dma_mask = DMA_BIT_MASK(32); 792 pdev->archdata.dma_mask = DMA_BIT_MASK(32);
793 pdev->dev.dma_mask = &pdev->archdata.dma_mask; 793 pdev->dev.dma_mask = &pdev->archdata.dma_mask;
794 set_dma_ops(&pdev->dev, &dma_nommu_ops);
795} 794}
796 795
797static __init void print_system_info(void) 796static __init void print_system_info(void)
diff --git a/arch/powerpc/mm/dma-noncoherent.c b/arch/powerpc/mm/dma-noncoherent.c
index c3d15d718a58..b5d2658c26af 100644
--- a/arch/powerpc/mm/dma-noncoherent.c
+++ b/arch/powerpc/mm/dma-noncoherent.c
@@ -152,8 +152,8 @@ static struct ppc_vm_region *ppc_vm_region_find(struct ppc_vm_region *head, unsi
152 * Allocate DMA-coherent memory space and return both the kernel remapped 152 * Allocate DMA-coherent memory space and return both the kernel remapped
153 * virtual and bus address for that space. 153 * virtual and bus address for that space.
154 */ 154 */
155void *__dma_nommu_alloc_coherent(struct device *dev, size_t size, 155void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
156 dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs) 156 gfp_t gfp, unsigned long attrs)
157{ 157{
158 struct page *page; 158 struct page *page;
159 struct ppc_vm_region *c; 159 struct ppc_vm_region *c;
@@ -254,7 +254,7 @@ void *__dma_nommu_alloc_coherent(struct device *dev, size_t size,
254/* 254/*
255 * free a page as defined by the above mapping. 255 * free a page as defined by the above mapping.
256 */ 256 */
257void __dma_nommu_free_coherent(struct device *dev, size_t size, void *vaddr, 257void arch_dma_free(struct device *dev, size_t size, void *vaddr,
258 dma_addr_t dma_handle, unsigned long attrs) 258 dma_addr_t dma_handle, unsigned long attrs)
259{ 259{
260 struct ppc_vm_region *c; 260 struct ppc_vm_region *c;
diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c
index f467247fd1c4..18422dbd061a 100644
--- a/arch/powerpc/platforms/44x/warp.c
+++ b/arch/powerpc/platforms/44x/warp.c
@@ -47,7 +47,7 @@ static int __init warp_probe(void)
47 if (!of_machine_is_compatible("pika,warp")) 47 if (!of_machine_is_compatible("pika,warp"))
48 return 0; 48 return 0;
49 49
50 /* For __dma_nommu_alloc_coherent */ 50 /* For arch_dma_alloc */
51 ISA_DMA_THRESHOLD = ~0L; 51 ISA_DMA_THRESHOLD = ~0L;
52 52
53 return 1; 53 return 1;
diff --git a/arch/powerpc/platforms/85xx/corenet_generic.c b/arch/powerpc/platforms/85xx/corenet_generic.c
index b0dac307bebf..808da1e9c0a7 100644
--- a/arch/powerpc/platforms/85xx/corenet_generic.c
+++ b/arch/powerpc/platforms/85xx/corenet_generic.c
@@ -223,7 +223,3 @@ define_machine(corenet_generic) {
223}; 223};
224 224
225machine_arch_initcall(corenet_generic, corenet_gen_publish_devices); 225machine_arch_initcall(corenet_generic, corenet_gen_publish_devices);
226
227#ifdef CONFIG_SWIOTLB
228machine_arch_initcall(corenet_generic, swiotlb_setup_bus_notifier);
229#endif
diff --git a/arch/powerpc/platforms/85xx/ge_imp3a.c b/arch/powerpc/platforms/85xx/ge_imp3a.c
index f29c6f0909f3..c64fa2483ea9 100644
--- a/arch/powerpc/platforms/85xx/ge_imp3a.c
+++ b/arch/powerpc/platforms/85xx/ge_imp3a.c
@@ -202,8 +202,6 @@ static int __init ge_imp3a_probe(void)
202 202
203machine_arch_initcall(ge_imp3a, mpc85xx_common_publish_devices); 203machine_arch_initcall(ge_imp3a, mpc85xx_common_publish_devices);
204 204
205machine_arch_initcall(ge_imp3a, swiotlb_setup_bus_notifier);
206
207define_machine(ge_imp3a) { 205define_machine(ge_imp3a) {
208 .name = "GE_IMP3A", 206 .name = "GE_IMP3A",
209 .probe = ge_imp3a_probe, 207 .probe = ge_imp3a_probe,
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index 94a7f92c858f..94194bad4954 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -57,8 +57,6 @@ static void __init mpc8536_ds_setup_arch(void)
57 57
58machine_arch_initcall(mpc8536_ds, mpc85xx_common_publish_devices); 58machine_arch_initcall(mpc8536_ds, mpc85xx_common_publish_devices);
59 59
60machine_arch_initcall(mpc8536_ds, swiotlb_setup_bus_notifier);
61
62/* 60/*
63 * Called very early, device-tree isn't unflattened 61 * Called very early, device-tree isn't unflattened
64 */ 62 */
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index dc9e035cc637..b7e29ce1f266 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -174,10 +174,6 @@ machine_arch_initcall(mpc8544_ds, mpc85xx_common_publish_devices);
174machine_arch_initcall(mpc8572_ds, mpc85xx_common_publish_devices); 174machine_arch_initcall(mpc8572_ds, mpc85xx_common_publish_devices);
175machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices); 175machine_arch_initcall(p2020_ds, mpc85xx_common_publish_devices);
176 176
177machine_arch_initcall(mpc8544_ds, swiotlb_setup_bus_notifier);
178machine_arch_initcall(mpc8572_ds, swiotlb_setup_bus_notifier);
179machine_arch_initcall(p2020_ds, swiotlb_setup_bus_notifier);
180
181/* 177/*
182 * Called very early, device-tree isn't unflattened 178 * Called very early, device-tree isn't unflattened
183 */ 179 */
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index d7e440e6dba3..80939a425de5 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -367,10 +367,6 @@ machine_arch_initcall(mpc8568_mds, mpc85xx_publish_devices);
367machine_arch_initcall(mpc8569_mds, mpc85xx_publish_devices); 367machine_arch_initcall(mpc8569_mds, mpc85xx_publish_devices);
368machine_arch_initcall(p1021_mds, mpc85xx_common_publish_devices); 368machine_arch_initcall(p1021_mds, mpc85xx_common_publish_devices);
369 369
370machine_arch_initcall(mpc8568_mds, swiotlb_setup_bus_notifier);
371machine_arch_initcall(mpc8569_mds, swiotlb_setup_bus_notifier);
372machine_arch_initcall(p1021_mds, swiotlb_setup_bus_notifier);
373
374static void __init mpc85xx_mds_pic_init(void) 370static void __init mpc85xx_mds_pic_init(void)
375{ 371{
376 struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN | 372 struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
diff --git a/arch/powerpc/platforms/85xx/p1010rdb.c b/arch/powerpc/platforms/85xx/p1010rdb.c
index 78d13b364cd6..33ca373322e1 100644
--- a/arch/powerpc/platforms/85xx/p1010rdb.c
+++ b/arch/powerpc/platforms/85xx/p1010rdb.c
@@ -55,7 +55,6 @@ static void __init p1010_rdb_setup_arch(void)
55} 55}
56 56
57machine_arch_initcall(p1010_rdb, mpc85xx_common_publish_devices); 57machine_arch_initcall(p1010_rdb, mpc85xx_common_publish_devices);
58machine_arch_initcall(p1010_rdb, swiotlb_setup_bus_notifier);
59 58
60/* 59/*
61 * Called very early, device-tree isn't unflattened 60 * Called very early, device-tree isn't unflattened
diff --git a/arch/powerpc/platforms/85xx/p1022_ds.c b/arch/powerpc/platforms/85xx/p1022_ds.c
index 9fb57f78cdbe..1f1af0557470 100644
--- a/arch/powerpc/platforms/85xx/p1022_ds.c
+++ b/arch/powerpc/platforms/85xx/p1022_ds.c
@@ -548,8 +548,6 @@ static void __init p1022_ds_setup_arch(void)
548 548
549machine_arch_initcall(p1022_ds, mpc85xx_common_publish_devices); 549machine_arch_initcall(p1022_ds, mpc85xx_common_publish_devices);
550 550
551machine_arch_initcall(p1022_ds, swiotlb_setup_bus_notifier);
552
553/* 551/*
554 * Called very early, device-tree isn't unflattened 552 * Called very early, device-tree isn't unflattened
555 */ 553 */
diff --git a/arch/powerpc/platforms/85xx/p1022_rdk.c b/arch/powerpc/platforms/85xx/p1022_rdk.c
index 276e00ab3dde..fd9e3e7ef234 100644
--- a/arch/powerpc/platforms/85xx/p1022_rdk.c
+++ b/arch/powerpc/platforms/85xx/p1022_rdk.c
@@ -128,8 +128,6 @@ static void __init p1022_rdk_setup_arch(void)
128 128
129machine_arch_initcall(p1022_rdk, mpc85xx_common_publish_devices); 129machine_arch_initcall(p1022_rdk, mpc85xx_common_publish_devices);
130 130
131machine_arch_initcall(p1022_rdk, swiotlb_setup_bus_notifier);
132
133/* 131/*
134 * Called very early, device-tree isn't unflattened 132 * Called very early, device-tree isn't unflattened
135 */ 133 */
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index 17c6cd3d02e6..775a92353c83 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -121,7 +121,6 @@ static int __init declare_of_platform_devices(void)
121 return 0; 121 return 0;
122} 122}
123machine_arch_initcall(mpc86xx_hpcn, declare_of_platform_devices); 123machine_arch_initcall(mpc86xx_hpcn, declare_of_platform_devices);
124machine_arch_initcall(mpc86xx_hpcn, swiotlb_setup_bus_notifier);
125 124
126define_machine(mpc86xx_hpcn) { 125define_machine(mpc86xx_hpcn) {
127 .name = "MPC86xx HPCN", 126 .name = "MPC86xx HPCN",
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index a3c4057a8f65..06abd432b830 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -600,8 +600,6 @@ static int cell_of_bus_notify(struct notifier_block *nb, unsigned long action,
600 600
601 if (cell_iommu_enabled) 601 if (cell_iommu_enabled)
602 dev->dma_ops = &dma_iommu_ops; 602 dev->dma_ops = &dma_iommu_ops;
603 else
604 dev->dma_ops = &dma_nommu_ops;
605 cell_dma_dev_setup(dev); 603 cell_dma_dev_setup(dev);
606 return 0; 604 return 0;
607} 605}
@@ -727,7 +725,6 @@ static int __init cell_iommu_init_disabled(void)
727 unsigned long base = 0, size; 725 unsigned long base = 0, size;
728 726
729 /* When no iommu is present, we use direct DMA ops */ 727 /* When no iommu is present, we use direct DMA ops */
730 set_pci_dma_ops(&dma_nommu_ops);
731 728
732 /* First make sure all IOC translation is turned off */ 729 /* First make sure all IOC translation is turned off */
733 cell_disable_iommus(); 730 cell_disable_iommus();
diff --git a/arch/powerpc/platforms/pasemi/iommu.c b/arch/powerpc/platforms/pasemi/iommu.c
index f2971522fb4a..bbeb6a1b0393 100644
--- a/arch/powerpc/platforms/pasemi/iommu.c
+++ b/arch/powerpc/platforms/pasemi/iommu.c
@@ -186,7 +186,7 @@ static void pci_dma_dev_setup_pasemi(struct pci_dev *dev)
186 */ 186 */
187 if (dev->vendor == 0x1959 && dev->device == 0xa007 && 187 if (dev->vendor == 0x1959 && dev->device == 0xa007 &&
188 !firmware_has_feature(FW_FEATURE_LPAR)) { 188 !firmware_has_feature(FW_FEATURE_LPAR)) {
189 dev->dev.dma_ops = &dma_nommu_ops; 189 dev->dev.dma_ops = NULL;
190 /* 190 /*
191 * Set the coherent DMA mask to prevent the iommu 191 * Set the coherent DMA mask to prevent the iommu
192 * being used unnecessarily 192 * being used unnecessarily
diff --git a/arch/powerpc/platforms/pasemi/setup.c b/arch/powerpc/platforms/pasemi/setup.c
index c0532999f854..46dd463faaa7 100644
--- a/arch/powerpc/platforms/pasemi/setup.c
+++ b/arch/powerpc/platforms/pasemi/setup.c
@@ -411,55 +411,6 @@ out:
411 return !!(srr1 & 0x2); 411 return !!(srr1 & 0x2);
412} 412}
413 413
414#ifdef CONFIG_PCMCIA
415static int pcmcia_notify(struct notifier_block *nb, unsigned long action,
416 void *data)
417{
418 struct device *dev = data;
419 struct device *parent;
420 struct pcmcia_device *pdev = to_pcmcia_dev(dev);
421
422 /* We are only intereted in device addition */
423 if (action != BUS_NOTIFY_ADD_DEVICE)
424 return 0;
425
426 parent = pdev->socket->dev.parent;
427
428 /* We know electra_cf devices will always have of_node set, since
429 * electra_cf is an of_platform driver.
430 */
431 if (!parent->of_node)
432 return 0;
433
434 if (!of_device_is_compatible(parent->of_node, "electra-cf"))
435 return 0;
436
437 /* We use the direct ops for localbus */
438 dev->dma_ops = &dma_nommu_ops;
439
440 return 0;
441}
442
443static struct notifier_block pcmcia_notifier = {
444 .notifier_call = pcmcia_notify,
445};
446
447static inline void pasemi_pcmcia_init(void)
448{
449 extern struct bus_type pcmcia_bus_type;
450
451 bus_register_notifier(&pcmcia_bus_type, &pcmcia_notifier);
452}
453
454#else
455
456static inline void pasemi_pcmcia_init(void)
457{
458}
459
460#endif
461
462
463static const struct of_device_id pasemi_bus_ids[] = { 414static const struct of_device_id pasemi_bus_ids[] = {
464 /* Unfortunately needed for legacy firmwares */ 415 /* Unfortunately needed for legacy firmwares */
465 { .type = "localbus", }, 416 { .type = "localbus", },
@@ -472,8 +423,6 @@ static const struct of_device_id pasemi_bus_ids[] = {
472 423
473static int __init pasemi_publish_devices(void) 424static int __init pasemi_publish_devices(void)
474{ 425{
475 pasemi_pcmcia_init();
476
477 /* Publish OF platform devices for SDC and other non-PCI devices */ 426 /* Publish OF platform devices for SDC and other non-PCI devices */
478 of_platform_bus_probe(NULL, pasemi_bus_ids, NULL); 427 of_platform_bus_probe(NULL, pasemi_bus_ids, NULL);
479 428
diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c
index d7f742ed48ba..4e87e13fa0fc 100644
--- a/arch/powerpc/platforms/powernv/npu-dma.c
+++ b/arch/powerpc/platforms/powernv/npu-dma.c
@@ -220,7 +220,7 @@ static void pnv_npu_dma_set_32(struct pnv_ioda_pe *npe)
220 * their parent device so drivers shouldn't be doing DMA 220 * their parent device so drivers shouldn't be doing DMA
221 * operations directly on these devices. 221 * operations directly on these devices.
222 */ 222 */
223 set_dma_ops(&npe->pdev->dev, NULL); 223 set_dma_ops(&npe->pdev->dev, &dma_dummy_ops);
224} 224}
225 225
226/* 226/*
diff --git a/arch/powerpc/platforms/pseries/vio.c b/arch/powerpc/platforms/pseries/vio.c
index b7dc8bd41fd0..141795275ccb 100644
--- a/arch/powerpc/platforms/pseries/vio.c
+++ b/arch/powerpc/platforms/pseries/vio.c
@@ -1699,3 +1699,10 @@ int vio_disable_interrupts(struct vio_dev *dev)
1699} 1699}
1700EXPORT_SYMBOL(vio_disable_interrupts); 1700EXPORT_SYMBOL(vio_disable_interrupts);
1701#endif /* CONFIG_PPC_PSERIES */ 1701#endif /* CONFIG_PPC_PSERIES */
1702
1703static int __init vio_init(void)
1704{
1705 dma_debug_add_bus(&vio_bus_type);
1706 return 0;
1707}
1708fs_initcall(vio_init);
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index 0c6510f340cb..23000ca7f688 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -124,10 +124,8 @@ static void pci_dma_dev_setup_swiotlb(struct pci_dev *pdev)
124 124
125static void setup_swiotlb_ops(struct pci_controller *hose) 125static void setup_swiotlb_ops(struct pci_controller *hose)
126{ 126{
127 if (ppc_swiotlb_enable) { 127 if (ppc_swiotlb_enable)
128 hose->controller_ops.dma_dev_setup = pci_dma_dev_setup_swiotlb; 128 hose->controller_ops.dma_dev_setup = pci_dma_dev_setup_swiotlb;
129 set_pci_dma_ops(&powerpc_swiotlb_dma_ops);
130 }
131} 129}
132#else 130#else
133static inline void setup_swiotlb_ops(struct pci_controller *hose) {} 131static inline void setup_swiotlb_ops(struct pci_controller *hose) {}
@@ -141,7 +139,6 @@ static void fsl_pci_dma_set_mask(struct device *dev, u64 dma_mask)
141 */ 139 */
142 if (dev_is_pci(dev) && dma_mask >= pci64_dma_offset * 2 - 1) { 140 if (dev_is_pci(dev) && dma_mask >= pci64_dma_offset * 2 - 1) {
143 dev->bus_dma_mask = 0; 141 dev->bus_dma_mask = 0;
144 set_dma_ops(dev, &dma_nommu_ops);
145 set_dma_offset(dev, pci64_dma_offset); 142 set_dma_offset(dev, pci64_dma_offset);
146 } 143 }
147} 144}
diff --git a/drivers/misc/cxl/vphb.c b/drivers/misc/cxl/vphb.c
index 49da2f744bbf..b64adc0f0865 100644
--- a/drivers/misc/cxl/vphb.c
+++ b/drivers/misc/cxl/vphb.c
@@ -43,7 +43,6 @@ static bool cxl_pci_enable_device_hook(struct pci_dev *dev)
43 return false; 43 return false;
44 } 44 }
45 45
46 set_dma_ops(&dev->dev, &dma_nommu_ops);
47 set_dma_offset(&dev->dev, PAGE_OFFSET); 46 set_dma_offset(&dev->dev, PAGE_OFFSET);
48 47
49 /* 48 /*