linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] driver core: Add ability for arch code to setup pdev_archdata
@ 2011-06-22 12:02 Kumar Gala
  2011-06-22 12:02 ` [PATCH 2/3] powerpc: implement arch_setup_pdev_archdata Kumar Gala
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Kumar Gala @ 2011-06-22 12:02 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, linuxppc-dev

On some architectures we need to setup pdev_archdata before we add the
device.  Waiting til a bus_notifier is too late since we might need the
pdev_archdata in the bus notifier.  One example is setting up of dma_mask
pointers such that it can be used in a bus_notifier.

We add noop version of arch_setup_pdev_archdata() in
<asm-generic/platform_device.h> and allow the arch code to override with
access the full definitions of struct device, struct platform_device, and
struct pdev_archdata.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 arch/alpha/include/asm/platform_device.h      |    1 +
 arch/arm/include/asm/platform_device.h        |    1 +
 arch/avr32/include/asm/platform_device.h      |    1 +
 arch/blackfin/include/asm/platform_device.h   |    1 +
 arch/cris/include/asm/platform_device.h       |    1 +
 arch/frv/include/asm/platform_device.h        |    1 +
 arch/h8300/include/asm/platform_device.h      |    1 +
 arch/ia64/include/asm/platform_device.h       |    1 +
 arch/m32r/include/asm/platform_device.h       |    1 +
 arch/m68k/include/asm/platform_device.h       |    1 +
 arch/microblaze/include/asm/platform_device.h |    1 +
 arch/mips/include/asm/platform_device.h       |    1 +
 arch/mn10300/include/asm/platform_device.h    |    1 +
 arch/parisc/include/asm/platform_device.h     |    1 +
 arch/powerpc/include/asm/platform_device.h    |    1 +
 arch/s390/include/asm/platform_device.h       |    1 +
 arch/score/include/asm/platform_device.h      |    1 +
 arch/sh/include/asm/platform_device.h         |    1 +
 arch/sparc/include/asm/platform_device.h      |    1 +
 arch/tile/include/asm/platform_device.h       |    1 +
 arch/unicore32/include/asm/platform_device.h  |    1 +
 arch/x86/include/asm/platform_device.h        |    1 +
 arch/xtensa/include/asm/platform_device.h     |    1 +
 drivers/base/platform.c                       |    2 ++
 include/asm-generic/platform_device.h         |   11 +++++++++++
 25 files changed, 36 insertions(+), 0 deletions(-)
 create mode 100644 arch/alpha/include/asm/platform_device.h
 create mode 100644 arch/arm/include/asm/platform_device.h
 create mode 100644 arch/avr32/include/asm/platform_device.h
 create mode 100644 arch/blackfin/include/asm/platform_device.h
 create mode 100644 arch/cris/include/asm/platform_device.h
 create mode 100644 arch/frv/include/asm/platform_device.h
 create mode 100644 arch/h8300/include/asm/platform_device.h
 create mode 100644 arch/ia64/include/asm/platform_device.h
 create mode 100644 arch/m32r/include/asm/platform_device.h
 create mode 100644 arch/m68k/include/asm/platform_device.h
 create mode 100644 arch/microblaze/include/asm/platform_device.h
 create mode 100644 arch/mips/include/asm/platform_device.h
 create mode 100644 arch/mn10300/include/asm/platform_device.h
 create mode 100644 arch/parisc/include/asm/platform_device.h
 create mode 100644 arch/powerpc/include/asm/platform_device.h
 create mode 100644 arch/s390/include/asm/platform_device.h
 create mode 100644 arch/score/include/asm/platform_device.h
 create mode 100644 arch/sh/include/asm/platform_device.h
 create mode 100644 arch/sparc/include/asm/platform_device.h
 create mode 100644 arch/tile/include/asm/platform_device.h
 create mode 100644 arch/unicore32/include/asm/platform_device.h
 create mode 100644 arch/x86/include/asm/platform_device.h
 create mode 100644 arch/xtensa/include/asm/platform_device.h
 create mode 100644 include/asm-generic/platform_device.h

diff --git a/arch/alpha/include/asm/platform_device.h b/arch/alpha/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/alpha/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/arm/include/asm/platform_device.h b/arch/arm/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/arm/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/avr32/include/asm/platform_device.h b/arch/avr32/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/avr32/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/blackfin/include/asm/platform_device.h b/arch/blackfin/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/blackfin/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/cris/include/asm/platform_device.h b/arch/cris/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/cris/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/frv/include/asm/platform_device.h b/arch/frv/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/frv/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/h8300/include/asm/platform_device.h b/arch/h8300/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/h8300/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/ia64/include/asm/platform_device.h b/arch/ia64/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/ia64/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/m32r/include/asm/platform_device.h b/arch/m32r/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/m32r/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/m68k/include/asm/platform_device.h b/arch/m68k/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/m68k/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/microblaze/include/asm/platform_device.h b/arch/microblaze/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/microblaze/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/mips/include/asm/platform_device.h b/arch/mips/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/mips/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/mn10300/include/asm/platform_device.h b/arch/mn10300/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/mn10300/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/parisc/include/asm/platform_device.h b/arch/parisc/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/parisc/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/powerpc/include/asm/platform_device.h b/arch/powerpc/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/powerpc/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/s390/include/asm/platform_device.h b/arch/s390/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/s390/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/score/include/asm/platform_device.h b/arch/score/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/score/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/sh/include/asm/platform_device.h b/arch/sh/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/sh/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/sparc/include/asm/platform_device.h b/arch/sparc/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/sparc/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/tile/include/asm/platform_device.h b/arch/tile/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/tile/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/unicore32/include/asm/platform_device.h b/arch/unicore32/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/unicore32/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/x86/include/asm/platform_device.h b/arch/x86/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/x86/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/xtensa/include/asm/platform_device.h b/arch/xtensa/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/xtensa/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 1c291af..c25e0c0 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -20,6 +20,7 @@
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/pm_runtime.h>
+#include <asm/platform_device.h>
 
 #include "base.h"
 
@@ -173,6 +174,7 @@ struct platform_device *platform_device_alloc(const char *name, int id)
 		pa->pdev.id = id;
 		device_initialize(&pa->pdev.dev);
 		pa->pdev.dev.release = platform_device_release;
+		arch_setup_pdev_archdata(&pa->pdev);
 	}
 
 	return pa ? &pa->pdev : NULL;
diff --git a/include/asm-generic/platform_device.h b/include/asm-generic/platform_device.h
new file mode 100644
index 0000000..4a3f6a9
--- /dev/null
+++ b/include/asm-generic/platform_device.h
@@ -0,0 +1,11 @@
+#ifndef __ASM_GENERIC_PLATFORM_DEVICE_H_
+#define __ASM_GENERIC_PLATFORM_DEVICE_H_
+
+/*
+ * an architecture can override to define arch_setup_pdev_archdata
+ */
+#ifndef arch_setup_pdev_archdata
+static inline void arch_setup_pdev_archdata(struct platform_device *pdev) { }
+#endif
+
+#endif /* __ASM_GENERIC_PLATFORM_DEVICE_H_ */
-- 
1.7.3.4


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

* [PATCH 2/3] powerpc: implement arch_setup_pdev_archdata
  2011-06-22 12:02 [PATCH 1/3] driver core: Add ability for arch code to setup pdev_archdata Kumar Gala
@ 2011-06-22 12:02 ` Kumar Gala
  2011-06-22 12:02   ` [PATCH 3/3] powerpc: Dont require a dma_ops struct to set dma mask Kumar Gala
  2011-06-22 14:37 ` [PATCH 1/3] driver core: Add ability for arch code to setup pdev_archdata Mike Frysinger
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 14+ messages in thread
From: Kumar Gala @ 2011-06-22 12:02 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, linuxppc-dev

We have a long standing issues with platform devices not have a valid
dma_mask pointer.  This hasn't been an issue to date as no platform
device has tried to set its dma_mask value to a non-default value.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 arch/powerpc/include/asm/platform_device.h |   17 ++++++++++++++++-
 arch/powerpc/kernel/setup-common.c         |   27 ---------------------------
 drivers/of/platform.c                      |    5 +++--
 3 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/arch/powerpc/include/asm/platform_device.h b/arch/powerpc/include/asm/platform_device.h
index 01452c3..137b183 100644
--- a/arch/powerpc/include/asm/platform_device.h
+++ b/arch/powerpc/include/asm/platform_device.h
@@ -1 +1,16 @@
-#include <asm-generic/platform_device.h>
+#ifndef __ASM_PLATFORM_DEVICE_H_
+#define __ASM_PLATFORM_DEVICE_H_
+
+#include <linux/platform_device.h>
+#include <asm/dma-mapping.h>
+
+#define ARCH_HAS_PDEV_ARCHDATA_SETUP
+
+static inline void arch_setup_pdev_archdata(struct platform_device *pdev)
+{
+	pdev->archdata.dma_mask = DMA_BIT_MASK(32);
+	pdev->dev.dma_mask = &pdev->archdata.dma_mask;
+ 	set_dma_ops(&pdev->dev, &dma_direct_ops);
+}
+
+#endif /* __ASM_GENERIC_PLATFORM_DEVICE_H_ */
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 79fca26..eb5229e 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -703,30 +703,3 @@ 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 int __init setup_bus_notifier(void)
-{
-	bus_register_notifier(&platform_bus_type, &ppc_dflt_plat_bus_notifier);
-	return 0;
-}
-
-arch_initcall(setup_bus_notifier);
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 63d3cb7..5ba8f48 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -21,6 +21,7 @@
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
+#include <asm/platform_device.h>
 
 static int of_dev_node_match(struct device *dev, void *data)
 {
@@ -153,7 +154,7 @@ struct platform_device *of_device_alloc(struct device_node *np,
 	}
 
 	dev->dev.of_node = of_node_get(np);
-#if defined(CONFIG_PPC) || defined(CONFIG_MICROBLAZE)
+#if defined(CONFIG_MICROBLAZE)
 	dev->dev.dma_mask = &dev->archdata.dma_mask;
 #endif
 	dev->dev.parent = parent;
@@ -189,7 +190,7 @@ struct platform_device *of_platform_device_create(struct device_node *np,
 	if (!dev)
 		return NULL;
 
-#if defined(CONFIG_PPC) || defined(CONFIG_MICROBLAZE)
+#if defined(CONFIG_MICROBLAZE)
 	dev->archdata.dma_mask = 0xffffffffUL;
 #endif
 	dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
-- 
1.7.3.4


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

* [PATCH 3/3] powerpc: Dont require a dma_ops struct to set dma mask
  2011-06-22 12:02 ` [PATCH 2/3] powerpc: implement arch_setup_pdev_archdata Kumar Gala
@ 2011-06-22 12:02   ` Kumar Gala
  2011-06-22 17:53     ` Scott Wood
  0 siblings, 1 reply; 14+ messages in thread
From: Kumar Gala @ 2011-06-22 12:02 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, linuxppc-dev

The only reason to require a dma_ops struct is to see if it has
implemented set_dma_mask.  If not we can fall back to setting the mask
directly.

This resolves an issue with how to sequence the setting of a DMA mask
for platform devices.  Before we had an issue in that we have no way of
setting the DMA mask before the various low level bus notifiers get
called that might check it (swiotlb).

So now we can do:

	pdev = platform_device_alloc("foobar", 0);
	dma_set_mask(&pdev->dev, DMA_BIT_MASK(37));
	platform_device_register(pdev);

And expect the right thing to happen with the bus notifiers get called
via platform_device_register.

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

diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index d238c08..4f0959f 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -161,9 +161,7 @@ int dma_set_mask(struct device *dev, u64 dma_mask)
 
 	if (ppc_md.dma_set_mask)
 		return ppc_md.dma_set_mask(dev, dma_mask);
-	if (unlikely(dma_ops == NULL))
-		return -EIO;
-	if (dma_ops->set_dma_mask != NULL)
+	if ((dma_ops != NULL) && (dma_ops->set_dma_mask != NULL))
 		return dma_ops->set_dma_mask(dev, dma_mask);
 	if (!dev->dma_mask || !dma_supported(dev, dma_mask))
 		return -EIO;
-- 
1.7.3.4


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

* Re: [PATCH 1/3] driver core: Add ability for arch code to setup pdev_archdata
  2011-06-22 12:02 [PATCH 1/3] driver core: Add ability for arch code to setup pdev_archdata Kumar Gala
  2011-06-22 12:02 ` [PATCH 2/3] powerpc: implement arch_setup_pdev_archdata Kumar Gala
@ 2011-06-22 14:37 ` Mike Frysinger
  2011-06-22 15:09 ` [PATCH v2 " Kumar Gala
  2011-06-23 11:33 ` [PATCH v3 " Kumar Gala
  3 siblings, 0 replies; 14+ messages in thread
From: Mike Frysinger @ 2011-06-22 14:37 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Greg KH, linux-kernel, linuxppc-dev

On Wed, Jun 22, 2011 at 08:02, Kumar Gala wrote:
> --- /dev/null
> +++ b/include/asm-generic/platform_device.h
> @@ -0,0 +1,11 @@

missing header blob with explanation/copyright/license

> +/*
> + * an architecture can override to define arch_setup_pdev_archdata
> + */
> +#ifndef arch_setup_pdev_archdata
> +static inline void arch_setup_pdev_archdata(struct platform_device *pdev) { }
> +#endif

missing explanation of what the func actually does, and this header
lacks a forward struct decl for platform_device
-mike

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

* [PATCH v2 1/3] driver core: Add ability for arch code to setup pdev_archdata
  2011-06-22 12:02 [PATCH 1/3] driver core: Add ability for arch code to setup pdev_archdata Kumar Gala
  2011-06-22 12:02 ` [PATCH 2/3] powerpc: implement arch_setup_pdev_archdata Kumar Gala
  2011-06-22 14:37 ` [PATCH 1/3] driver core: Add ability for arch code to setup pdev_archdata Mike Frysinger
@ 2011-06-22 15:09 ` Kumar Gala
  2011-06-22 17:52   ` Scott Wood
  2011-06-23 11:33 ` [PATCH v3 " Kumar Gala
  3 siblings, 1 reply; 14+ messages in thread
From: Kumar Gala @ 2011-06-22 15:09 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, linuxppc-dev

On some architectures we need to setup pdev_archdata before we add the
device.  Waiting til a bus_notifier is too late since we might need the
pdev_archdata in the bus notifier.  One example is setting up of dma_mask
pointers such that it can be used in a bus_notifier.

We add noop version of arch_setup_pdev_archdata() in
<asm-generic/platform_device.h> and allow the arch code to override with
access the full definitions of struct device, struct platform_device, and
struct pdev_archdata.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
* Added license, and comments about arch_setup_pdev_archdata()
  per Mike's comments

 arch/alpha/include/asm/platform_device.h      |    1 +
 arch/arm/include/asm/platform_device.h        |    1 +
 arch/avr32/include/asm/platform_device.h      |    1 +
 arch/blackfin/include/asm/platform_device.h   |    1 +
 arch/cris/include/asm/platform_device.h       |    1 +
 arch/frv/include/asm/platform_device.h        |    1 +
 arch/h8300/include/asm/platform_device.h      |    1 +
 arch/ia64/include/asm/platform_device.h       |    1 +
 arch/m32r/include/asm/platform_device.h       |    1 +
 arch/m68k/include/asm/platform_device.h       |    1 +
 arch/microblaze/include/asm/platform_device.h |    1 +
 arch/mips/include/asm/platform_device.h       |    1 +
 arch/mn10300/include/asm/platform_device.h    |    1 +
 arch/parisc/include/asm/platform_device.h     |    1 +
 arch/powerpc/include/asm/platform_device.h    |    1 +
 arch/s390/include/asm/platform_device.h       |    1 +
 arch/score/include/asm/platform_device.h      |    1 +
 arch/sh/include/asm/platform_device.h         |    1 +
 arch/sparc/include/asm/platform_device.h      |    1 +
 arch/tile/include/asm/platform_device.h       |    1 +
 arch/unicore32/include/asm/platform_device.h  |    1 +
 arch/x86/include/asm/platform_device.h        |    1 +
 arch/xtensa/include/asm/platform_device.h     |    1 +
 drivers/base/platform.c                       |    2 +
 include/asm-generic/platform_device.h         |   30 +++++++++++++++++++++++++
 25 files changed, 55 insertions(+), 0 deletions(-)
 create mode 100644 arch/alpha/include/asm/platform_device.h
 create mode 100644 arch/arm/include/asm/platform_device.h
 create mode 100644 arch/avr32/include/asm/platform_device.h
 create mode 100644 arch/blackfin/include/asm/platform_device.h
 create mode 100644 arch/cris/include/asm/platform_device.h
 create mode 100644 arch/frv/include/asm/platform_device.h
 create mode 100644 arch/h8300/include/asm/platform_device.h
 create mode 100644 arch/ia64/include/asm/platform_device.h
 create mode 100644 arch/m32r/include/asm/platform_device.h
 create mode 100644 arch/m68k/include/asm/platform_device.h
 create mode 100644 arch/microblaze/include/asm/platform_device.h
 create mode 100644 arch/mips/include/asm/platform_device.h
 create mode 100644 arch/mn10300/include/asm/platform_device.h
 create mode 100644 arch/parisc/include/asm/platform_device.h
 create mode 100644 arch/powerpc/include/asm/platform_device.h
 create mode 100644 arch/s390/include/asm/platform_device.h
 create mode 100644 arch/score/include/asm/platform_device.h
 create mode 100644 arch/sh/include/asm/platform_device.h
 create mode 100644 arch/sparc/include/asm/platform_device.h
 create mode 100644 arch/tile/include/asm/platform_device.h
 create mode 100644 arch/unicore32/include/asm/platform_device.h
 create mode 100644 arch/x86/include/asm/platform_device.h
 create mode 100644 arch/xtensa/include/asm/platform_device.h
 create mode 100644 include/asm-generic/platform_device.h

diff --git a/arch/alpha/include/asm/platform_device.h b/arch/alpha/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/alpha/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/arm/include/asm/platform_device.h b/arch/arm/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/arm/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/avr32/include/asm/platform_device.h b/arch/avr32/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/avr32/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/blackfin/include/asm/platform_device.h b/arch/blackfin/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/blackfin/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/cris/include/asm/platform_device.h b/arch/cris/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/cris/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/frv/include/asm/platform_device.h b/arch/frv/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/frv/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/h8300/include/asm/platform_device.h b/arch/h8300/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/h8300/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/ia64/include/asm/platform_device.h b/arch/ia64/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/ia64/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/m32r/include/asm/platform_device.h b/arch/m32r/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/m32r/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/m68k/include/asm/platform_device.h b/arch/m68k/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/m68k/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/microblaze/include/asm/platform_device.h b/arch/microblaze/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/microblaze/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/mips/include/asm/platform_device.h b/arch/mips/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/mips/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/mn10300/include/asm/platform_device.h b/arch/mn10300/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/mn10300/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/parisc/include/asm/platform_device.h b/arch/parisc/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/parisc/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/powerpc/include/asm/platform_device.h b/arch/powerpc/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/powerpc/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/s390/include/asm/platform_device.h b/arch/s390/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/s390/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/score/include/asm/platform_device.h b/arch/score/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/score/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/sh/include/asm/platform_device.h b/arch/sh/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/sh/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/sparc/include/asm/platform_device.h b/arch/sparc/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/sparc/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/tile/include/asm/platform_device.h b/arch/tile/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/tile/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/unicore32/include/asm/platform_device.h b/arch/unicore32/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/unicore32/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/x86/include/asm/platform_device.h b/arch/x86/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/x86/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/xtensa/include/asm/platform_device.h b/arch/xtensa/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/xtensa/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 1c291af..c25e0c0 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -20,6 +20,7 @@
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/pm_runtime.h>
+#include <asm/platform_device.h>
 
 #include "base.h"
 
@@ -173,6 +174,7 @@ struct platform_device *platform_device_alloc(const char *name, int id)
 		pa->pdev.id = id;
 		device_initialize(&pa->pdev.dev);
 		pa->pdev.dev.release = platform_device_release;
+		arch_setup_pdev_archdata(&pa->pdev);
 	}
 
 	return pa ? &pa->pdev : NULL;
diff --git a/include/asm-generic/platform_device.h b/include/asm-generic/platform_device.h
new file mode 100644
index 0000000..c543add
--- /dev/null
+++ b/include/asm-generic/platform_device.h
@@ -0,0 +1,30 @@
+/*
+ * include/asm-generic/platform_device.h
+ *
+ * Provides a callout when we allocate a platform device to architecture code
+ * to update archdata.
+ *
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * You should have received a copy of the GNU General Public License
+ * (for example /usr/src/linux/COPYING); if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#ifndef __ASM_GENERIC_PLATFORM_DEVICE_H_
+#define __ASM_GENERIC_PLATFORM_DEVICE_H_
+
+struct platform_device;
+
+/*
+ * an architecture can override to define arch_setup_pdev_archdata
+ */
+#ifndef arch_setup_pdev_archdata
+static inline void arch_setup_pdev_archdata(struct platform_device *pdev) { }
+#endif
+
+#endif /* __ASM_GENERIC_PLATFORM_DEVICE_H_ */
-- 
1.7.3.4


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

* Re: [PATCH v2 1/3] driver core: Add ability for arch code to setup pdev_archdata
  2011-06-22 15:09 ` [PATCH v2 " Kumar Gala
@ 2011-06-22 17:52   ` Scott Wood
  0 siblings, 0 replies; 14+ messages in thread
From: Scott Wood @ 2011-06-22 17:52 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Greg KH, linuxppc-dev, linux-kernel

On Wed, 22 Jun 2011 10:09:56 -0500
Kumar Gala <galak@kernel.crashing.org> wrote:

> diff --git a/drivers/base/platform.c b/drivers/base/platform.c
> index 1c291af..c25e0c0 100644
> --- a/drivers/base/platform.c
> +++ b/drivers/base/platform.c
> @@ -20,6 +20,7 @@
>  #include <linux/err.h>
>  #include <linux/slab.h>
>  #include <linux/pm_runtime.h>
> +#include <asm/platform_device.h>
>  
>  #include "base.h"
>  
> @@ -173,6 +174,7 @@ struct platform_device *platform_device_alloc(const char *name, int id)
>  		pa->pdev.id = id;
>  		device_initialize(&pa->pdev.dev);
>  		pa->pdev.dev.release = platform_device_release;
> +		arch_setup_pdev_archdata(&pa->pdev);
>  	}
>  
>  	return pa ? &pa->pdev : NULL;

Need to call this from platform_device_register() as well, for devices
which are not dynamically allocated.

> +/*
> + * an architecture can override to define arch_setup_pdev_archdata
> + */
> +#ifndef arch_setup_pdev_archdata
> +static inline void arch_setup_pdev_archdata(struct platform_device *pdev) { }
> +#endif

That's not a particularly useful comment.  More useful would be a statement
of when this hook is called, examples of what it's meant to be used for,
etc.

-Scott


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

* Re: [PATCH 3/3] powerpc: Dont require a dma_ops struct to set dma mask
  2011-06-22 12:02   ` [PATCH 3/3] powerpc: Dont require a dma_ops struct to set dma mask Kumar Gala
@ 2011-06-22 17:53     ` Scott Wood
  0 siblings, 0 replies; 14+ messages in thread
From: Scott Wood @ 2011-06-22 17:53 UTC (permalink / raw)
  To: Kumar Gala; +Cc: Greg KH, linuxppc-dev, linux-kernel

On Wed, 22 Jun 2011 07:02:56 -0500
Kumar Gala <galak@kernel.crashing.org> wrote:

> The only reason to require a dma_ops struct is to see if it has
> implemented set_dma_mask.  If not we can fall back to setting the mask
> directly.
> 
> This resolves an issue with how to sequence the setting of a DMA mask
> for platform devices.  Before we had an issue in that we have no way of
> setting the DMA mask before the various low level bus notifiers get
> called that might check it (swiotlb).
> 
> So now we can do:
> 
> 	pdev = platform_device_alloc("foobar", 0);
> 	dma_set_mask(&pdev->dev, DMA_BIT_MASK(37));
> 	platform_device_register(pdev);

Despite what Documentation/driver-model/platform.txt says, it looks like
platform_device_add() is what you want after platform_device_alloc().
Otherwise device_initialize() gets called twice, as would a call to the
archdata hook if one is added to platform_device_register().

-Scott


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

* [PATCH v3 1/3] driver core: Add ability for arch code to setup pdev_archdata
  2011-06-22 12:02 [PATCH 1/3] driver core: Add ability for arch code to setup pdev_archdata Kumar Gala
                   ` (2 preceding siblings ...)
  2011-06-22 15:09 ` [PATCH v2 " Kumar Gala
@ 2011-06-23 11:33 ` Kumar Gala
  2011-06-23 11:33   ` [PATCH v3 2/3] powerpc: implement arch_setup_pdev_archdata Kumar Gala
  2011-07-01 22:09   ` [PATCH v3 1/3] driver core: Add ability for arch code to setup pdev_archdata Greg KH
  3 siblings, 2 replies; 14+ messages in thread
From: Kumar Gala @ 2011-06-23 11:33 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, linuxppc-dev

On some architectures we need to setup pdev_archdata before we add the
device.  Waiting til a bus_notifier is too late since we might need the
pdev_archdata in the bus notifier.  One example is setting up of dma_mask
pointers such that it can be used in a bus_notifier.

We add noop version of arch_setup_pdev_archdata() in
<asm-generic/platform_device.h> and allow the arch code to override with
access the full definitions of struct device, struct platform_device, and
struct pdev_archdata.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
v3:
* Add more comments and add missing call to arch_setup_pdev_archdata in
  platform_device_register
v2:
* Added license, and comments about arch_setup_pdev_archdata()
  per Mike's comments

 arch/alpha/include/asm/platform_device.h      |    1 +
 arch/arm/include/asm/platform_device.h        |    1 +
 arch/avr32/include/asm/platform_device.h      |    1 +
 arch/blackfin/include/asm/platform_device.h   |    1 +
 arch/cris/include/asm/platform_device.h       |    1 +
 arch/frv/include/asm/platform_device.h        |    1 +
 arch/h8300/include/asm/platform_device.h      |    1 +
 arch/ia64/include/asm/platform_device.h       |    1 +
 arch/m32r/include/asm/platform_device.h       |    1 +
 arch/m68k/include/asm/platform_device.h       |    1 +
 arch/microblaze/include/asm/platform_device.h |    1 +
 arch/mips/include/asm/platform_device.h       |    1 +
 arch/mn10300/include/asm/platform_device.h    |    1 +
 arch/parisc/include/asm/platform_device.h     |    1 +
 arch/powerpc/include/asm/platform_device.h    |    1 +
 arch/s390/include/asm/platform_device.h       |    1 +
 arch/score/include/asm/platform_device.h      |    1 +
 arch/sh/include/asm/platform_device.h         |    1 +
 arch/sparc/include/asm/platform_device.h      |    1 +
 arch/tile/include/asm/platform_device.h       |    1 +
 arch/unicore32/include/asm/platform_device.h  |    1 +
 arch/x86/include/asm/platform_device.h        |    1 +
 arch/xtensa/include/asm/platform_device.h     |    1 +
 drivers/base/platform.c                       |    3 ++
 include/asm-generic/platform_device.h         |   41 +++++++++++++++++++++++++
 25 files changed, 67 insertions(+), 0 deletions(-)
 create mode 100644 arch/alpha/include/asm/platform_device.h
 create mode 100644 arch/arm/include/asm/platform_device.h
 create mode 100644 arch/avr32/include/asm/platform_device.h
 create mode 100644 arch/blackfin/include/asm/platform_device.h
 create mode 100644 arch/cris/include/asm/platform_device.h
 create mode 100644 arch/frv/include/asm/platform_device.h
 create mode 100644 arch/h8300/include/asm/platform_device.h
 create mode 100644 arch/ia64/include/asm/platform_device.h
 create mode 100644 arch/m32r/include/asm/platform_device.h
 create mode 100644 arch/m68k/include/asm/platform_device.h
 create mode 100644 arch/microblaze/include/asm/platform_device.h
 create mode 100644 arch/mips/include/asm/platform_device.h
 create mode 100644 arch/mn10300/include/asm/platform_device.h
 create mode 100644 arch/parisc/include/asm/platform_device.h
 create mode 100644 arch/powerpc/include/asm/platform_device.h
 create mode 100644 arch/s390/include/asm/platform_device.h
 create mode 100644 arch/score/include/asm/platform_device.h
 create mode 100644 arch/sh/include/asm/platform_device.h
 create mode 100644 arch/sparc/include/asm/platform_device.h
 create mode 100644 arch/tile/include/asm/platform_device.h
 create mode 100644 arch/unicore32/include/asm/platform_device.h
 create mode 100644 arch/x86/include/asm/platform_device.h
 create mode 100644 arch/xtensa/include/asm/platform_device.h
 create mode 100644 include/asm-generic/platform_device.h

diff --git a/arch/alpha/include/asm/platform_device.h b/arch/alpha/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/alpha/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/arm/include/asm/platform_device.h b/arch/arm/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/arm/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/avr32/include/asm/platform_device.h b/arch/avr32/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/avr32/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/blackfin/include/asm/platform_device.h b/arch/blackfin/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/blackfin/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/cris/include/asm/platform_device.h b/arch/cris/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/cris/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/frv/include/asm/platform_device.h b/arch/frv/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/frv/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/h8300/include/asm/platform_device.h b/arch/h8300/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/h8300/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/ia64/include/asm/platform_device.h b/arch/ia64/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/ia64/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/m32r/include/asm/platform_device.h b/arch/m32r/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/m32r/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/m68k/include/asm/platform_device.h b/arch/m68k/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/m68k/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/microblaze/include/asm/platform_device.h b/arch/microblaze/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/microblaze/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/mips/include/asm/platform_device.h b/arch/mips/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/mips/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/mn10300/include/asm/platform_device.h b/arch/mn10300/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/mn10300/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/parisc/include/asm/platform_device.h b/arch/parisc/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/parisc/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/powerpc/include/asm/platform_device.h b/arch/powerpc/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/powerpc/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/s390/include/asm/platform_device.h b/arch/s390/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/s390/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/score/include/asm/platform_device.h b/arch/score/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/score/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/sh/include/asm/platform_device.h b/arch/sh/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/sh/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/sparc/include/asm/platform_device.h b/arch/sparc/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/sparc/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/tile/include/asm/platform_device.h b/arch/tile/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/tile/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/unicore32/include/asm/platform_device.h b/arch/unicore32/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/unicore32/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/x86/include/asm/platform_device.h b/arch/x86/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/x86/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/arch/xtensa/include/asm/platform_device.h b/arch/xtensa/include/asm/platform_device.h
new file mode 100644
index 0000000..01452c3
--- /dev/null
+++ b/arch/xtensa/include/asm/platform_device.h
@@ -0,0 +1 @@
+#include <asm-generic/platform_device.h>
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 1c291af..f554045 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -20,6 +20,7 @@
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/pm_runtime.h>
+#include <asm/platform_device.h>
 
 #include "base.h"
 
@@ -173,6 +174,7 @@ struct platform_device *platform_device_alloc(const char *name, int id)
 		pa->pdev.id = id;
 		device_initialize(&pa->pdev.dev);
 		pa->pdev.dev.release = platform_device_release;
+		arch_setup_pdev_archdata(&pa->pdev);
 	}
 
 	return pa ? &pa->pdev : NULL;
@@ -334,6 +336,7 @@ EXPORT_SYMBOL_GPL(platform_device_del);
 int platform_device_register(struct platform_device *pdev)
 {
 	device_initialize(&pdev->dev);
+	arch_setup_pdev_archdata(pdev);
 	return platform_device_add(pdev);
 }
 EXPORT_SYMBOL_GPL(platform_device_register);
diff --git a/include/asm-generic/platform_device.h b/include/asm-generic/platform_device.h
new file mode 100644
index 0000000..c03570c
--- /dev/null
+++ b/include/asm-generic/platform_device.h
@@ -0,0 +1,41 @@
+/*
+ * include/asm-generic/platform_device.h
+ *
+ * Provides a callout when we allocate a platform device to architecture code
+ * to update archdata.
+ *
+ * Copyright 2011 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * You should have received a copy of the GNU General Public License
+ * (for example /usr/src/linux/COPYING); if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#ifndef __ASM_GENERIC_PLATFORM_DEVICE_H_
+#define __ASM_GENERIC_PLATFORM_DEVICE_H_
+
+struct platform_device;
+
+/*
+ * an architecture can override to define arch_setup_pdev_archdata
+ * 
+ * This is called before platform_device_add() such that any pdev_archdata may
+ * be setup before the platform_notifier is called.  So if a user needs to
+ * manipulate any relevant information in the pdev_archdata they can do:
+ *
+ * 	platform_devic_alloc()
+ * 	... manipulate ...
+ * 	platform_device_add()
+ *
+ * And if they don't care they can just call platform_device_register() and
+ * everything will just work out.
+ */
+#ifndef arch_setup_pdev_archdata
+static inline void arch_setup_pdev_archdata(struct platform_device *pdev) { }
+#endif
+
+#endif /* __ASM_GENERIC_PLATFORM_DEVICE_H_ */
-- 
1.7.3.4


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

* [PATCH v3 2/3] powerpc: implement arch_setup_pdev_archdata
  2011-06-23 11:33 ` [PATCH v3 " Kumar Gala
@ 2011-06-23 11:33   ` Kumar Gala
  2011-06-23 11:33     ` [PATCH v3 3/3] powerpc: Dont require a dma_ops struct to set dma mask Kumar Gala
  2011-07-01 22:09   ` [PATCH v3 1/3] driver core: Add ability for arch code to setup pdev_archdata Greg KH
  1 sibling, 1 reply; 14+ messages in thread
From: Kumar Gala @ 2011-06-23 11:33 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, linuxppc-dev

We have a long standing issues with platform devices not have a valid
dma_mask pointer.  This hasn't been an issue to date as no platform
device has tried to set its dma_mask value to a non-default value.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
 arch/powerpc/include/asm/platform_device.h |   17 ++++++++++++++++-
 arch/powerpc/kernel/setup-common.c         |   27 ---------------------------
 drivers/of/platform.c                      |    5 +++--
 3 files changed, 19 insertions(+), 30 deletions(-)

diff --git a/arch/powerpc/include/asm/platform_device.h b/arch/powerpc/include/asm/platform_device.h
index 01452c3..137b183 100644
--- a/arch/powerpc/include/asm/platform_device.h
+++ b/arch/powerpc/include/asm/platform_device.h
@@ -1 +1,16 @@
-#include <asm-generic/platform_device.h>
+#ifndef __ASM_PLATFORM_DEVICE_H_
+#define __ASM_PLATFORM_DEVICE_H_
+
+#include <linux/platform_device.h>
+#include <asm/dma-mapping.h>
+
+#define ARCH_HAS_PDEV_ARCHDATA_SETUP
+
+static inline void arch_setup_pdev_archdata(struct platform_device *pdev)
+{
+	pdev->archdata.dma_mask = DMA_BIT_MASK(32);
+	pdev->dev.dma_mask = &pdev->archdata.dma_mask;
+ 	set_dma_ops(&pdev->dev, &dma_direct_ops);
+}
+
+#endif /* __ASM_GENERIC_PLATFORM_DEVICE_H_ */
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 79fca26..eb5229e 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -703,30 +703,3 @@ 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 int __init setup_bus_notifier(void)
-{
-	bus_register_notifier(&platform_bus_type, &ppc_dflt_plat_bus_notifier);
-	return 0;
-}
-
-arch_initcall(setup_bus_notifier);
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 63d3cb7..5ba8f48 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -21,6 +21,7 @@
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
+#include <asm/platform_device.h>
 
 static int of_dev_node_match(struct device *dev, void *data)
 {
@@ -153,7 +154,7 @@ struct platform_device *of_device_alloc(struct device_node *np,
 	}
 
 	dev->dev.of_node = of_node_get(np);
-#if defined(CONFIG_PPC) || defined(CONFIG_MICROBLAZE)
+#if defined(CONFIG_MICROBLAZE)
 	dev->dev.dma_mask = &dev->archdata.dma_mask;
 #endif
 	dev->dev.parent = parent;
@@ -189,7 +190,7 @@ struct platform_device *of_platform_device_create(struct device_node *np,
 	if (!dev)
 		return NULL;
 
-#if defined(CONFIG_PPC) || defined(CONFIG_MICROBLAZE)
+#if defined(CONFIG_MICROBLAZE)
 	dev->archdata.dma_mask = 0xffffffffUL;
 #endif
 	dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
-- 
1.7.3.4


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

* [PATCH v3 3/3] powerpc: Dont require a dma_ops struct to set dma mask
  2011-06-23 11:33   ` [PATCH v3 2/3] powerpc: implement arch_setup_pdev_archdata Kumar Gala
@ 2011-06-23 11:33     ` Kumar Gala
  0 siblings, 0 replies; 14+ messages in thread
From: Kumar Gala @ 2011-06-23 11:33 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, linuxppc-dev

The only reason to require a dma_ops struct is to see if it has
implemented set_dma_mask.  If not we can fall back to setting the mask
directly.

This resolves an issue with how to sequence the setting of a DMA mask
for platform devices.  Before we had an issue in that we have no way of
setting the DMA mask before the various low level bus notifiers get
called that might check it (swiotlb).

So now we can do:

	pdev = platform_device_alloc("foobar", 0);
	dma_set_mask(&pdev->dev, DMA_BIT_MASK(37));
	platform_device_add(pdev);

And expect the right thing to happen with the bus notifiers get called
via platform_device_add.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
---
v3: Fixed commit comment to use platform_device_add()
 arch/powerpc/kernel/dma.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index d238c08..4f0959f 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -161,9 +161,7 @@ int dma_set_mask(struct device *dev, u64 dma_mask)
 
 	if (ppc_md.dma_set_mask)
 		return ppc_md.dma_set_mask(dev, dma_mask);
-	if (unlikely(dma_ops == NULL))
-		return -EIO;
-	if (dma_ops->set_dma_mask != NULL)
+	if ((dma_ops != NULL) && (dma_ops->set_dma_mask != NULL))
 		return dma_ops->set_dma_mask(dev, dma_mask);
 	if (!dev->dma_mask || !dma_supported(dev, dma_mask))
 		return -EIO;
-- 
1.7.3.4


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

* Re: [PATCH v3 1/3] driver core: Add ability for arch code to setup pdev_archdata
  2011-06-23 11:33 ` [PATCH v3 " Kumar Gala
  2011-06-23 11:33   ` [PATCH v3 2/3] powerpc: implement arch_setup_pdev_archdata Kumar Gala
@ 2011-07-01 22:09   ` Greg KH
  2011-07-07 13:55     ` Kumar Gala
  1 sibling, 1 reply; 14+ messages in thread
From: Greg KH @ 2011-07-01 22:09 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linux-kernel, linuxppc-dev

On Thu, Jun 23, 2011 at 06:33:57AM -0500, Kumar Gala wrote:
> On some architectures we need to setup pdev_archdata before we add the
> device.  Waiting til a bus_notifier is too late since we might need the
> pdev_archdata in the bus notifier.  One example is setting up of dma_mask
> pointers such that it can be used in a bus_notifier.
> 
> We add noop version of arch_setup_pdev_archdata() in
> <asm-generic/platform_device.h> and allow the arch code to override with
> access the full definitions of struct device, struct platform_device, and
> struct pdev_archdata.

Isn't there some way to use "weak" symbols to keep us from having to
create this .h file in every single arch and then if the arch wants to
define it, it does so?

That should make this patch simpler, right?

thanks,

greg k-h

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

* Re: [PATCH v3 1/3] driver core: Add ability for arch code to setup pdev_archdata
  2011-07-01 22:09   ` [PATCH v3 1/3] driver core: Add ability for arch code to setup pdev_archdata Greg KH
@ 2011-07-07 13:55     ` Kumar Gala
  2011-07-07 14:11       ` Greg KH
  0 siblings, 1 reply; 14+ messages in thread
From: Kumar Gala @ 2011-07-07 13:55 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, linuxppc-dev


On Jul 1, 2011, at 5:09 PM, Greg KH wrote:

> On Thu, Jun 23, 2011 at 06:33:57AM -0500, Kumar Gala wrote:
>> On some architectures we need to setup pdev_archdata before we add the
>> device.  Waiting til a bus_notifier is too late since we might need the
>> pdev_archdata in the bus notifier.  One example is setting up of dma_mask
>> pointers such that it can be used in a bus_notifier.
>> 
>> We add noop version of arch_setup_pdev_archdata() in
>> <asm-generic/platform_device.h> and allow the arch code to override with
>> access the full definitions of struct device, struct platform_device, and
>> struct pdev_archdata.
> 
> Isn't there some way to use "weak" symbols to keep us from having to
> create this .h file in every single arch and then if the arch wants to
> define it, it does so?
> 
> That should make this patch simpler, right?
> 
> thanks,
> 
> greg k-h

Changing to weak should be doable if we are ok with the additional function call always happening.

- k


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

* Re: [PATCH v3 1/3] driver core: Add ability for arch code to setup pdev_archdata
  2011-07-07 13:55     ` Kumar Gala
@ 2011-07-07 14:11       ` Greg KH
  2011-07-08  4:03         ` Kumar Gala
  0 siblings, 1 reply; 14+ messages in thread
From: Greg KH @ 2011-07-07 14:11 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linux-kernel, linuxppc-dev

On Thu, Jul 07, 2011 at 08:55:44AM -0500, Kumar Gala wrote:
> 
> On Jul 1, 2011, at 5:09 PM, Greg KH wrote:
> 
> > On Thu, Jun 23, 2011 at 06:33:57AM -0500, Kumar Gala wrote:
> >> On some architectures we need to setup pdev_archdata before we add the
> >> device.  Waiting til a bus_notifier is too late since we might need the
> >> pdev_archdata in the bus notifier.  One example is setting up of dma_mask
> >> pointers such that it can be used in a bus_notifier.
> >> 
> >> We add noop version of arch_setup_pdev_archdata() in
> >> <asm-generic/platform_device.h> and allow the arch code to override with
> >> access the full definitions of struct device, struct platform_device, and
> >> struct pdev_archdata.
> > 
> > Isn't there some way to use "weak" symbols to keep us from having to
> > create this .h file in every single arch and then if the arch wants to
> > define it, it does so?
> > 
> > That should make this patch simpler, right?
> > 
> > thanks,
> > 
> > greg k-h
> 
> Changing to weak should be doable if we are ok with the additional
> function call always happening.

Given that this is not a fast path, and the function call for the
"normal" case would do nothing, it should be fine, right?

greg k-h

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

* Re: [PATCH v3 1/3] driver core: Add ability for arch code to setup pdev_archdata
  2011-07-07 14:11       ` Greg KH
@ 2011-07-08  4:03         ` Kumar Gala
  0 siblings, 0 replies; 14+ messages in thread
From: Kumar Gala @ 2011-07-08  4:03 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, linuxppc-dev


On Jul 7, 2011, at 9:11 AM, Greg KH wrote:

> On Thu, Jul 07, 2011 at 08:55:44AM -0500, Kumar Gala wrote:
>> 
>> On Jul 1, 2011, at 5:09 PM, Greg KH wrote:
>> 
>>> On Thu, Jun 23, 2011 at 06:33:57AM -0500, Kumar Gala wrote:
>>>> On some architectures we need to setup pdev_archdata before we add the
>>>> device.  Waiting til a bus_notifier is too late since we might need the
>>>> pdev_archdata in the bus notifier.  One example is setting up of dma_mask
>>>> pointers such that it can be used in a bus_notifier.
>>>> 
>>>> We add noop version of arch_setup_pdev_archdata() in
>>>> <asm-generic/platform_device.h> and allow the arch code to override with
>>>> access the full definitions of struct device, struct platform_device, and
>>>> struct pdev_archdata.
>>> 
>>> Isn't there some way to use "weak" symbols to keep us from having to
>>> create this .h file in every single arch and then if the arch wants to
>>> define it, it does so?
>>> 
>>> That should make this patch simpler, right?
>>> 
>>> thanks,
>>> 
>>> greg k-h
>> 
>> Changing to weak should be doable if we are ok with the additional
>> function call always happening.
> 
> Given that this is not a fast path, and the function call for the
> "normal" case would do nothing, it should be fine, right?
> 
> greg k-h

Sounds good, new version sent that uses weak instead.  If this looks good let me know if you just want to ACK and send via powerpc.git tree or if you'll pick these up.

- k



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

end of thread, other threads:[~2011-07-08  4:03 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-22 12:02 [PATCH 1/3] driver core: Add ability for arch code to setup pdev_archdata Kumar Gala
2011-06-22 12:02 ` [PATCH 2/3] powerpc: implement arch_setup_pdev_archdata Kumar Gala
2011-06-22 12:02   ` [PATCH 3/3] powerpc: Dont require a dma_ops struct to set dma mask Kumar Gala
2011-06-22 17:53     ` Scott Wood
2011-06-22 14:37 ` [PATCH 1/3] driver core: Add ability for arch code to setup pdev_archdata Mike Frysinger
2011-06-22 15:09 ` [PATCH v2 " Kumar Gala
2011-06-22 17:52   ` Scott Wood
2011-06-23 11:33 ` [PATCH v3 " Kumar Gala
2011-06-23 11:33   ` [PATCH v3 2/3] powerpc: implement arch_setup_pdev_archdata Kumar Gala
2011-06-23 11:33     ` [PATCH v3 3/3] powerpc: Dont require a dma_ops struct to set dma mask Kumar Gala
2011-07-01 22:09   ` [PATCH v3 1/3] driver core: Add ability for arch code to setup pdev_archdata Greg KH
2011-07-07 13:55     ` Kumar Gala
2011-07-07 14:11       ` Greg KH
2011-07-08  4:03         ` Kumar Gala

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