linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] powerpc/pci: Default to dma_direct_ops for pci dma_ops
@ 2009-02-19 20:49 Kumar Gala
  2009-02-19 20:49 ` [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify Kumar Gala
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Kumar Gala @ 2009-02-19 20:49 UTC (permalink / raw)
  Cc: linuxppc-dev, arnd

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.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 arch/powerpc/kernel/pci-common.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 2ad1731..633e871 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -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)
 {
-- 
1.5.6.6

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify
  2009-02-19 20:49 [PATCH 1/3] powerpc/pci: Default to dma_direct_ops for pci dma_ops Kumar Gala
@ 2009-02-19 20:49 ` Kumar Gala
  2009-02-19 20:49   ` [PATCH 3/3] powerpc: expect all devices calling dma ops to have archdata set Kumar Gala
                     ` (2 more replies)
  2009-02-19 20:58 ` [PATCH 1/3] powerpc/pci: Default to dma_direct_ops for pci dma_ops Kumar Gala
  2009-02-19 22:08 ` Benjamin Krill
  2 siblings, 3 replies; 11+ messages in thread
From: Kumar Gala @ 2009-02-19 20:49 UTC (permalink / raw)
  Cc: linuxppc-dev, arnd

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.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 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(-)

diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 6c34a0d..9a28e5b 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -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);
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 705fc4b..62dfa75 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -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;
+}
diff --git a/arch/powerpc/kernel/setup.h b/arch/powerpc/kernel/setup.h
index 4c67ad7..34899cf 100644
--- a/arch/powerpc/kernel/setup.h
+++ b/arch/powerpc/kernel/setup.h
@@ -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 */
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 9e1ca74..c20a49d 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -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);
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 73e16e2..b22a3d9 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -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();
 
diff --git a/arch/powerpc/platforms/cell/qpace_setup.c b/arch/powerpc/platforms/cell/qpace_setup.c
index be84e6a..775cd80 100644
--- a/arch/powerpc/platforms/cell/qpace_setup.c
+++ b/arch/powerpc/platforms/cell/qpace_setup.c
@@ -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)
-- 
1.5.6.6

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/3] powerpc: expect all devices calling dma ops to have archdata set
  2009-02-19 20:49 ` [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify Kumar Gala
@ 2009-02-19 20:49   ` Kumar Gala
  2009-02-19 22:08     ` Benjamin Krill
  2009-02-19 22:08   ` [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify Benjamin Krill
  2009-03-04  4:56   ` Benjamin Herrenschmidt
  2 siblings, 1 reply; 11+ messages in thread
From: Kumar Gala @ 2009-02-19 20:49 UTC (permalink / raw)
  Cc: linuxppc-dev, arnd

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.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 arch/powerpc/include/asm/dma-mapping.h |   12 +-----------
 1 files changed, 1 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 86cef7d..c69f2b5 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -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;
 }
-- 
1.5.6.6

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] powerpc/pci: Default to dma_direct_ops for pci dma_ops
  2009-02-19 20:49 [PATCH 1/3] powerpc/pci: Default to dma_direct_ops for pci dma_ops Kumar Gala
  2009-02-19 20:49 ` [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify Kumar Gala
@ 2009-02-19 20:58 ` Kumar Gala
  2009-02-19 22:08 ` Benjamin Krill
  2 siblings, 0 replies; 11+ messages in thread
From: Kumar Gala @ 2009-02-19 20:58 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev list, Arnd Bergmann


On Feb 19, 2009, at 2:49 PM, Kumar Gala wrote:

> 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.
>
> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
> ---
> 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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] powerpc/pci: Default to dma_direct_ops for pci dma_ops
  2009-02-19 20:49 [PATCH 1/3] powerpc/pci: Default to dma_direct_ops for pci dma_ops Kumar Gala
  2009-02-19 20:49 ` [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify Kumar Gala
  2009-02-19 20:58 ` [PATCH 1/3] powerpc/pci: Default to dma_direct_ops for pci dma_ops Kumar Gala
@ 2009-02-19 22:08 ` Benjamin Krill
  2009-02-20 20:44   ` Becky Bruce
  2 siblings, 1 reply; 11+ messages in thread
From: Benjamin Krill @ 2009-02-19 22:08 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, arnd

* 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.
>
>Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

Acked-by: Benjamin Krill <ben@codiert.org> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify
  2009-02-19 20:49 ` [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify Kumar Gala
  2009-02-19 20:49   ` [PATCH 3/3] powerpc: expect all devices calling dma ops to have archdata set Kumar Gala
@ 2009-02-19 22:08   ` Benjamin Krill
  2009-02-20 20:44     ` Becky Bruce
  2009-03-04  4:56   ` Benjamin Herrenschmidt
  2 siblings, 1 reply; 11+ messages in thread
From: Benjamin Krill @ 2009-02-19 22:08 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, arnd

* 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.
>
>Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

Acked-by: Benjamin Krill <ben@codiert.org>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/3] powerpc: expect all devices calling dma ops to have archdata set
  2009-02-19 20:49   ` [PATCH 3/3] powerpc: expect all devices calling dma ops to have archdata set Kumar Gala
@ 2009-02-19 22:08     ` Benjamin Krill
  2009-02-20 20:45       ` Becky Bruce
  0 siblings, 1 reply; 11+ messages in thread
From: Benjamin Krill @ 2009-02-19 22:08 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, arnd

* 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.
>
>Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

Acked-by: Benjamin Krill <ben@codiert.org>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/3] powerpc/pci: Default to dma_direct_ops for pci dma_ops
  2009-02-19 22:08 ` Benjamin Krill
@ 2009-02-20 20:44   ` Becky Bruce
  0 siblings, 0 replies; 11+ messages in thread
From: Becky Bruce @ 2009-02-20 20:44 UTC (permalink / raw)
  To: Benjamin Krill; +Cc: linuxppc-dev, arnd


On Feb 19, 2009, at 4:08 PM, Benjamin Krill wrote:

> * 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.
>>
>> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
>
> Acked-by: Benjamin Krill <ben@codiert.org>

Tested on ppc 86xx, looks good.

Acked-by: Becky Bruce <beckyb@kernel.crashing.org>

-B

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify
  2009-02-19 22:08   ` [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify Benjamin Krill
@ 2009-02-20 20:44     ` Becky Bruce
  0 siblings, 0 replies; 11+ messages in thread
From: Becky Bruce @ 2009-02-20 20:44 UTC (permalink / raw)
  To: Benjamin Krill; +Cc: linuxppc-dev, arnd


On Feb 19, 2009, at 4:08 PM, Benjamin Krill wrote:

> * 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.
>>
>> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
>
> Acked-by: Benjamin Krill <ben@codiert.org>

Tested on ppc 86xx, looks good.

Acked-by: Becky Bruce <beckyb@kernel.crashing.org>

-B

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/3] powerpc: expect all devices calling dma ops to have archdata set
  2009-02-19 22:08     ` Benjamin Krill
@ 2009-02-20 20:45       ` Becky Bruce
  0 siblings, 0 replies; 11+ messages in thread
From: Becky Bruce @ 2009-02-20 20:45 UTC (permalink / raw)
  To: Benjamin Krill; +Cc: linuxppc-dev, arnd


On Feb 19, 2009, at 4:08 PM, Benjamin Krill wrote:

> * 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.
>>
>> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
>
> Acked-by: Benjamin Krill <ben@codiert.org>

Tested on ppc 86xx, looks good.

Acked-by: Becky Bruce <beckyb@kernel.crashing.org>

-B

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify
  2009-02-19 20:49 ` [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify Kumar Gala
  2009-02-19 20:49   ` [PATCH 3/3] powerpc: expect all devices calling dma ops to have archdata set Kumar Gala
  2009-02-19 22:08   ` [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify Benjamin Krill
@ 2009-03-04  4:56   ` Benjamin Herrenschmidt
  2 siblings, 0 replies; 11+ messages in thread
From: Benjamin Herrenschmidt @ 2009-03-04  4:56 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, arnd

On Thu, 2009-02-19 at 14:49 -0600, Kumar Gala wrote:
> 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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2009-03-04  4:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-19 20:49 [PATCH 1/3] powerpc/pci: Default to dma_direct_ops for pci dma_ops Kumar Gala
2009-02-19 20:49 ` [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify Kumar Gala
2009-02-19 20:49   ` [PATCH 3/3] powerpc: expect all devices calling dma ops to have archdata set Kumar Gala
2009-02-19 22:08     ` Benjamin Krill
2009-02-20 20:45       ` Becky Bruce
2009-02-19 22:08   ` [PATCH 2/3] powerpc: setup archdata for {of_}platform via a single platform_notify Benjamin Krill
2009-02-20 20:44     ` Becky Bruce
2009-03-04  4:56   ` Benjamin Herrenschmidt
2009-02-19 20:58 ` [PATCH 1/3] powerpc/pci: Default to dma_direct_ops for pci dma_ops Kumar Gala
2009-02-19 22:08 ` Benjamin Krill
2009-02-20 20:44   ` Becky Bruce

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).