Skip to contentSkip to conversation

powerpc/pci: Default to dma_direct_ops for pci dma_ops

PATCH Superseded Kumar Gala 4 participants 11 messages Feb 19, 2009 – Mar 4, 2009

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
author
#1 lore raw

PATCH 2/3 powerpc: setup archdata for {of_}platform via a single platform_notify

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.

In the short term the majority of these devices only need the direct_dma_ops as the platforms don't have any IOMMUs.

In the future to enable >4G DMA support on ppc32 we can hook swiotlb ops.

---
 arch/powerpc/include/asm/machdep.h        |    4 ++++
 arch/powerpc/kernel/setup-common.c        |   22 ++++++++++++++++++++++
 arch/powerpc/kernel/setup.h               |    4 ++++
 arch/powerpc/kernel/setup_32.c            |    3 +++
 arch/powerpc/kernel/setup_64.c            |    3 +++
 arch/powerpc/platforms/cell/qpace_setup.c |   13 -------------
 6 files changed, 36 insertions(+), 13 deletions(-)
arch/powerpc/include/asm/machdep.h +4 -0
index 6c34a0d..9a28e5b 100644
@@ -262,6 +262,10 @@ struct machdep_calls {
 	void (*suspend_disable_irqs)(void);
 	void (*suspend_enable_irqs)(void);
 #endif
+	/* These are called via the driver core.  They mainly exist
+	 * for setting up archdata properly */
+	int (*platform_notify)(struct device *dev);
+	int (*platform_notify_remove)(struct device *dev);
 };
 
 extern void e500_idle(void);
arch/powerpc/kernel/setup-common.c +22 -0
index 705fc4b..62dfa75 100644
@@ -669,3 +669,25 @@ static int powerpc_debugfs_init(void)
 }
 arch_initcall(powerpc_debugfs_init);
 #endif
+
+int ppc_platform_notify(struct device *dev)
+{
+	if (ppc_md.platform_notify)
+		return ppc_md.platform_notify(dev);
+
+	/* set dma_ops for platform or of_platform bus */
+	if (dev->bus && dev->bus->name &&
+			(!strcmp(dev->bus->name, "platform") ||
+			 !strcmp(dev->bus->name, "of_platform")))
+		set_dma_ops(dev, &dma_direct_ops);
+
+	return 0;
+}
+
+int ppc_platform_notify_remove(struct device *dev)
+{
+	if (ppc_md.platform_notify_remove)
+		return ppc_md.platform_notify_remove(dev);
+
+	return 0;
+}
arch/powerpc/kernel/setup.h +4 -0
index 4c67ad7..34899cf 100644
@@ -1,9 +1,13 @@
 #ifndef _POWERPC_KERNEL_SETUP_H
 #define _POWERPC_KERNEL_SETUP_H
 
+#include <linux/device.h>
+
 void check_for_initrd(void);
 void do_init_bootmem(void);
 void setup_panic(void);
+int ppc_platform_notify(struct device *dev);
+int ppc_platform_notify_remove(struct device *dev);
 extern int do_early_xmon;
 
 #endif /* _POWERPC_KERNEL_SETUP_H */
arch/powerpc/kernel/setup_32.c +3 -0
index 9e1ca74..c20a49d 100644
@@ -328,6 +328,9 @@ void __init setup_arch(char **cmdline_p)
 	conswitchp = &dummy_con;
 #endif
 
+	platform_notify = &ppc_platform_notify;
+	platform_notify_remove = &ppc_platform_notify_remove;
+
 	if (ppc_md.setup_arch)
 		ppc_md.setup_arch();
 	if ( ppc_md.progress ) ppc_md.progress("arch: exit", 0x3eab);
arch/powerpc/kernel/setup_64.c +3 -0
index 73e16e2..b22a3d9 100644
@@ -546,6 +546,9 @@ void __init setup_arch(char **cmdline_p)
 	conswitchp = &dummy_con;
 #endif
 
+	platform_notify = &ppc_platform_notify;
+	platform_notify_remove = &ppc_platform_notify_remove;
+
 	if (ppc_md.setup_arch)
 		ppc_md.setup_arch();
 
arch/powerpc/platforms/cell/qpace_setup.c +0 -13
index be84e6a..775cd80 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

Kumar Gala

author
#0 lore raw

PATCH 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 2ad1731..633e871 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 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
#8 lore raw
In reply to Kumar Gala
Quoted 8 lines · Kumar Gala

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(-)

Ben,

If you can look at putting these in testing that would be great.

I'd like to see of Josh can get some 4xx/44x runs to see if we break anything there. I don't expect it but good to see.

- k

Acked-by on v1 2/3
#5 lore raw

Re: [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify

In reply to Kumar Gala
Quoted 10 lines · * Kumar Gala | 2009-02-19 14:49:16 [-0600]:

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.

In the short term the majority of these devices only need the direct_dma_ops as the platforms don't have any IOMMUs.

In the future to enable >4G DMA support on ppc32 we can hook swiotlb ops.

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

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

In reply to Kumar Gala
Quoted 6 lines · * Kumar Gala | 2009-02-19 14:49:17 [-0600]:

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.

Acked-by
#10 lore raw
In reply to Benjamin Krill
Quoted 9 lines · Benjamin Krill
Quoted 5 lines · * Kumar Gala | 2009-02-19 14:49:15 [-0600]:

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.

Tested on ppc 86xx, looks good.

-B

Acked-by
#6 lore raw

Re: [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify

In reply to Benjamin Krill
Quoted 6 lines · Benjamin Krill
Quoted 4 lines · * Kumar Gala | 2009-02-19 14:49:16 [-0600]:

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
Quoted 6 lines

In the short term the majority of these devices only need the direct_dma_ops as the platforms don't have any IOMMUs.

In the future to enable >4G DMA support on ppc32 we can hook swiotlb ops.

Tested on ppc 86xx, looks good.

-B

Acked-by
#4 lore raw

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

In reply to Benjamin Krill
Quoted 10 lines · Benjamin Krill
Quoted 6 lines · * Kumar Gala | 2009-02-19 14:49:17 [-0600]:

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 ppc 86xx, looks good.

-B

#7 lore raw

Re: [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify

In reply to Kumar Gala
Quoted 8 lines · 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.

In the short term the majority of these devices only need the direct_dma_ops as the platforms don't have any IOMMUs.

In the future to enable >4G DMA support on ppc32 we can hook swiotlb ops.

I'm trying to figure out why I didn't use platform_notify back when I did cell blades support and instead added the per-bus type notifier support. I think I wanted to avoid the compare with bus types thingy which somewhat suck.

Can't we do something akin to what the Cell IOMMU code does and just have the platform code register a notifier for those bus types that fill things up ?

IE. With this patch, if I'm not mistaken, on Cell blades, things will start with a dma_direct_ops (which is bogus) and then end up being hopefully "fixed up" by the iommu code. A bit weird.

Cheers,
Ben.