driver core: Add ability for arch code to setup pdev_archdata
Subsystems (15)
PATCH 1/3 driver core: Add ability for arch code to setup pdev_archdata
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.
--- 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
arch/alpha/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/arm/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/avr32/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/blackfin/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/cris/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/frv/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/h8300/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/ia64/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/m32r/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/m68k/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/microblaze/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/mips/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/mn10300/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/parisc/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/powerpc/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/s390/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/score/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/sh/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/sparc/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/tile/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/unicore32/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/x86/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/xtensa/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
drivers/base/platform.c +2 -0
@@ -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 ;
include/asm-generic/platform_device.h new file +11 -0
@@ -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_ */
Signature · 1 line
1.7.3.4
PATCH 2/3 powerpc: implement arch_setup_pdev_archdata
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.
--- 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(-)
arch/powerpc/include/asm/platform_device.h +16 -1
@@ -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_ */
arch/powerpc/kernel/setup-common.c +0 -27
@@ -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);
drivers/of/platform.c +3 -2
@@ -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 );
Signature · 1 line
1.7.3.4
PATCH 3/3 powerpc: Dont require a dma_ops struct to set dma mask
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.
--- arch/powerpc/kernel/dma.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
arch/powerpc/kernel/dma.c +1 -3
@@ -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 ;
Signature · 1 line
1.7.3.4
Re: [PATCH 3/3] powerpc: Dont require a dma_ops struct to set dma mask
Quoted 9 lines · On Wed, 22 Jun 2011 07:02:56 -0500 Kumar Gala <[email protected]> wrote:
The only reason to require a
dma_opsstruct is to see if it has implementedset_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).
Quoted 5 lines
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
include/asm-generic/platform_device.h
Quoted 3 lines · Kumar Gala
include/asm-generic/platform_device.h new file +0
-0@@ -0,0 +1,11 @@
missing header blob with explanation/copyright/license
include/asm-generic/platform_device.h line 9
Quoted 6 lines
include/asm-generic/platform_device.h new file +6
-0+/* +* 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
PATCH v2 1/3 driver core: Add ability for arch code to setup pdev_archdata
In reply to Kumar GalaOn 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.
---
* 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
arch/alpha/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/arm/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/avr32/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/blackfin/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/cris/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/frv/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/h8300/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/ia64/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/m32r/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/m68k/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/microblaze/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/mips/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/mn10300/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/parisc/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/powerpc/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/s390/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/score/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/sh/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/sparc/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/tile/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/unicore32/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/x86/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/xtensa/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
drivers/base/platform.c +2 -0
@@ -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 ;
include/asm-generic/platform_device.h new file +30 -0
@@ -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_ */
Signature · 1 line
1.7.3.4
Quoted 13 lines · On Wed, 22 Jun 2011 10:09:56 -0500 Kumar Gala <[email protected]> wrote:
drivers/base/platform.c +1
-0@@ -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"
drivers/base/platform.c struct platform_device *platform_device_alloc(const char *name, int id) · line 180
Quoted 7 lines
drivers/base/platform.c +1
-0@@ -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.
drivers/base/platform.c
Quoted 6 lines
drivers/base/platform.c +6
-0+/* +* 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
PATCH v3 1/3 driver core: Add ability for arch code to setup pdev_archdata
In reply to Kumar GalaOn 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.
---
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
arch/alpha/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/arm/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/avr32/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/blackfin/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/cris/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/frv/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/h8300/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/ia64/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/m32r/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/m68k/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/microblaze/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/mips/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/mn10300/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/parisc/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/powerpc/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/s390/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/score/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/sh/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/sparc/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/tile/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/unicore32/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/x86/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
arch/xtensa/include/asm/platform_device.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-generic/platform_device.h>
drivers/base/platform.c +3 -0
@@ -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);
include/asm-generic/platform_device.h new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
1.7.3.4
PATCH v3 2/3 powerpc: implement arch_setup_pdev_archdata
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.
--- 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(-)
arch/powerpc/include/asm/platform_device.h +16 -1
@@ -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_ */
arch/powerpc/kernel/setup-common.c +0 -27
@@ -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);
drivers/of/platform.c +3 -2
@@ -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 );
Signature · 1 line
1.7.3.4
PATCH v3 3/3 powerpc: Dont require a dma_ops struct to set dma mask
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.
---
v3: Fixed commit comment to use platform_device_add()
arch/powerpc/kernel/dma.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-)
arch/powerpc/kernel/dma.c +1 -3
@@ -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 ;
Signature · 1 line
1.7.3.4
Quoted 9 lines · Kumar Gala
On some architectures we need to setup
pdev_archdatabefore we add the device. Waiting til abus_notifieris too late since we might need thepdev_archdatain the bus notifier. One example is setting up ofdma_maskpointers such that it can be used in abus_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, structplatform_device, and structpdev_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
Quoted 2 lines · Greg KH
Quoted 1 line · Kumar Gala
On some architectures we need to setup
pdev_archdatabefore we add =
the
Quoted 1 line
Quoted 1 line
device. Waiting til a
bus_notifieris too late since we might need =
the
Quoted 1 line
Quoted 1 line
pdev_archdatain the bus notifier. One example is setting up of =
dma_mask
Quoted 4 lines
Quoted 4 lines
pointers such that it can be used in a
bus_notifier.
=20
We add noop version ofarch_setup_pdev_archdata()in <asm-generic/platform_device.h> and allow the arch code to override =
with
Quoted 1 line
Quoted 1 line
access the full definitions of struct device, struct
platform_device, =
and
Quoted 11 lines
Quoted 1 line
struct
pdev_archdata.=20
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?
=20
That should make this patch simpler, right?
=20
thanks,
=20
greg k-h
Changing to weak should be doable if we are ok with the additional = function call always happening.
- k
Quoted 18 lines · Kumar Gala
Quoted 15 lines · Greg KH
Quoted 9 lines · Kumar Gala
On some architectures we need to setup
pdev_archdatabefore we add the device. Waiting til abus_notifieris too late since we might need thepdev_archdatain the bus notifier. One example is setting up ofdma_maskpointers such that it can be used in abus_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, structplatform_device, and structpdev_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?
Quoted 8 lines
Quoted 5 lines
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
Quoted 6 lines · Greg KH
Quoted 5 lines · Kumar Gala
=20
On Jul 1, 2011, at 5:09 PM, Greg KH wrote:
=20Quoted 2 lines · Kumar Gala
Quoted 1 line
On some architectures we need to setup
pdev_archdatabefore we add =
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
device. Waiting til a
bus_notifieris too late since we might need =
the
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
pdev_archdatain the bus notifier. One example is setting up of =
dma_mask
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
pointers such that it can be used in a
bus_notifier.
=20
We add noop version ofarch_setup_pdev_archdata()in <asm-generic/platform_device.h> and allow the arch code to override =
with
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
access the full definitions of struct device, struct =
platform_device, and
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
struct
pdev_archdata.=20
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
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
define it, it does so?
=20
That should make this patch simpler, right?
=20
thanks,
=20
greg k-h
Quoted 8 lines
Quoted 3 lines
=20
Changing to weak should be doable if we are ok with the additional function call always happening.=20
Given that this is not a fast path, and the function call for the "normal" case would do nothing, it should be fine, right? =20
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