Skip to contentSkip to conversation

powerpc/pci: Default to dma_direct_ops for pci dma_ops

PATCH In review Kumar Gala 2 participants 6 messages Mar 19, 2009 – Mar 20, 2009

Subsystems (2)
lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

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
index 2603f20..9c69e7e 100644
@@ -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
author
#2 lore raw

PATCH v2 3/3 powerpc: expect all devices calling dma ops to have archdata set

In reply to Kumar Gala

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
index 86cef7d..c69f2b5 100644
@@ -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
author
#1 lore raw

PATCH v2 2/3 powerpc: setup default archdata for {of_}platform via bus_register_notifier

In reply to Kumar Gala

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
index 705fc4b..9774f9f 100644
@@ -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
index c75b662..c5ce02e 100644
@@ -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
Acked-by on v2 2/3
#4 lore raw

Re: [PATCH v2 2/3] powerpc: setup default archdata for {of_}platform via bus_register_notifier

In reply to Kumar Gala
Quoted 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_platform devices. We need to hook the archdata to setup proper dma_ops for these devices.

Quoted 8 lines

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.

Tested on QPACE node card.

Acked-by on v2 3/3
#3 lore raw

Re: [PATCH v2 3/3] powerpc: expect all devices calling dma ops to have archdata set

In reply to Kumar Gala
Quoted 6 lines · * Kumar Gala | 2009-03-19 08:40:52 [-0500]:

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.

Tested on QPACE node card.