powerpc/pci: Default to dma_direct_ops for pci dma_ops
Subsystems (2)
PATCH v2 1/3 powerpc/pci: Default to dma_direct_ops for pci dma_ops
This will allow us to remove the ppc32 specific checks in get_dma_ops() that defaults to dma_direct_ops if the archdata is NULL. We really should always have archdata set to something going forward.
--- arch/powerpc/kernel/pci-common.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/powerpc/kernel/pci-common.c +1 -1
@@ -50,7 +50,7 @@ resource_size_t isa_mem_base;unsigned int ppc_pci_flags =0 ; -static struct dma_mapping_ops *pci_dma_ops; +static struct dma_mapping_ops *pci_dma_ops = &dma_direct_ops;void set_pci_dma_ops (struct dma_mapping_ops *dma_ops) {
Signature · 1 line
1.5.6.6
PATCH v2 2/3 powerpc: setup default archdata for {of_}platform via bus_register_notifier
Since a number of powerpc chips are SoCs we end up having dma-able devices that are registered as platform or of_platform devices. We need to hook the archdata to setup proper dma_ops for these devices.
Rather than having to add a bus_notify to each platform we add a default one at the highest priority (called first) to set the default dma_ops for of_platform and platform devices to dma_direct_ops. This allows platform code to override the ops by providing their own notifier call back.
In the future to enable >4G DMA support on ppc32 we can hook swiotlb ops.
---
* Use bus notifiers instead of platform_notify
arch/powerpc/kernel/setup-common.c | 36 +++++++++++++++++++++++++++++ arch/powerpc/platforms/cell/qpace_setup.c | 13 ---------- 2 files changed, 36 insertions(+), 13 deletions(-)
arch/powerpc/kernel/setup-common.c +36 -0
@@ -35,6 +35,8 @@#include <linux/debugfs.h> #include <linux/percpu.h> #include <linux/lmb.h> +#include <linux/of_platform.h> +#include <linux/platform_device.h> #include <asm/io.h> #include <asm/prom.h> #include <asm/processor.h>
@@ -669,3 +671,37 @@ static int powerpc_debugfs_init(void) }arch_initcall (powerpc_debugfs_init);#endif + +static int ppc_dflt_bus_notify (struct notifier_block *nb, +unsigned long action,void *data) +{ +struct device *dev = data; + +/* We are only intereted in device addition */ +if (action !=BUS_NOTIFY_ADD_DEVICE ) +return 0 ; + +set_dma_ops (dev, &dma_direct_ops); + +return NOTIFY_DONE ; +} + +static struct notifier_block ppc_dflt_plat_bus_notifier = { + .notifier_call = ppc_dflt_bus_notify, + .priority =INT_MAX , +}; + +static struct notifier_block ppc_dflt_of_bus_notifier = { + .notifier_call = ppc_dflt_bus_notify, + .priority =INT_MAX , +}; + +static int __init setup_bus_notifier (void ) +{ +bus_register_notifier (&platform_bus_type, &ppc_dflt_plat_bus_notifier); +bus_register_notifier (&of_platform_bus_type, &ppc_dflt_of_bus_notifier); + +return 0 ; +} + +arch_initcall (setup_bus_notifier);
arch/powerpc/platforms/cell/qpace_setup.c +0 -13
@@ -81,16 +81,6 @@ static int __init qpace_publish_devices(void) }machine_subsys_initcall (qpace, qpace_publish_devices); -extern int qpace_notify (struct device *dev) -{ -/* set dma_ops for of_platform bus */ -if (dev->bus && dev->bus->name - && !strcmp (dev->bus->name,"of_platform" )) -set_dma_ops (dev, &dma_direct_ops); - -return 0 ; -} -static void __init qpace_setup_arch (void ) {#ifdef CONFIG_SPU_BASE
@@ -115,9 +105,6 @@ static void __init qpace_setup_arch(void)#ifdef CONFIG_DUMMY_CONSOLE conswitchp = &dummy_con;#endif - -/* set notifier function */ - platform_notify = &qpace_notify; }static int __init qpace_probe (void )
Signature · 1 line
1.5.6.6
PATCH v2 3/3 powerpc: expect all devices calling dma ops to have archdata set
Now that we set archdata for of_platform and platform devices via platform_notify() we no longer need to special case having a NULL device pointer or NULL archdata. It should be a driver error if this condition shows up and the driver should be fixed.
--- arch/powerpc/include/asm/dma-mapping.h | 12 +----------- 1 files changed, 1 insertions(+), 11 deletions(-)
arch/powerpc/include/asm/dma-mapping.h +1 -11
@@ -109,18 +109,8 @@ static inline struct dma_mapping_ops *get_dma_ops(struct device *dev)* only ISA DMA device we support is the floppy and we have a hack * in the floppy driver directly to get a device for us. */ - -if (unlikely (dev ==NULL ) || dev->archdata.dma_ops ==NULL ) { -#ifdef CONFIG_PPC64 +if (unlikely (dev ==NULL ))return NULL ; -#else -/* Use default on 32-bit if dma_ops is not set up */ -/* TODO: Long term, we should fix drivers so that dev and -* archdata dma_ops are set up for all buses. -*/ -return &dma_direct_ops; -#endif - }return dev->archdata.dma_ops; }
Signature · 1 line
1.5.6.6
Re: [PATCH v2 3/3] powerpc: expect all devices calling dma ops to have archdata set
Quoted 6 lines · * Kumar Gala | 2009-03-19 08:40:52 [-0500]:
Now that we set archdata for
of_platformand platform devices viaplatform_notify()we no longer need to special case having a NULL device pointer or NULL archdata. It should be a driver error if this condition shows up and the driver should be fixed.Signed-off-by Kumar Gala <[email protected]>
Tested on QPACE node card.
Re: [PATCH v2 2/3] powerpc: setup default archdata for {of_}platform via bus_register_notifier
In reply to Kumar GalaQuoted 4 lines · * Kumar Gala | 2009-03-19 08:40:51 [-0500]:
Since a number of powerpc chips are SoCs we end up having dma-able devices that are registered as platform or
of_platformdevices. We need to hook the archdata to setup properdma_opsfor these devices.
Quoted 8 lines
Rather than having to add a
bus_notifyto each platform we add a default one at the highest priority (called first) to set the defaultdma_opsforof_platformand platform devices todma_direct_ops. This allows platform code to override the ops by providing their own notifier call back.In the future to enable >4G DMA support on ppc32 we can hook swiotlb ops.
Signed-off-by Kumar Gala <[email protected]>
Tested on QPACE node card.
Quoted 5 lines · * Kumar Gala | 2009-03-19 08:40:50 [-0500]:
This will allow us to remove the ppc32 specific checks in
get_dma_ops()that defaults todma_direct_opsif the archdata is NULL. We really should always have archdata set to something going forward.Signed-off-by Kumar Gala <[email protected]>
Tested on QPACE node card.