populate platform device at late init
PATCH 1/1 populate platform device at late init
This patch enables to populate platform devices from device tree at late-init As of now linux kernel has late-init call infrastructure which make a driver/module init call at late-init.it is not specific to a platform device.
This patch make a platform device to be probe at late-init,
without making its driver a late-init call.
This will be useful in certain scenario when we have multiple instances of similar platform devices and it is ok to defer specific device to late-init among the multiple instance of similar devices.
Currently ARM based SOC has multiple instance of similar modules/controller (i2c,uart,mmc controller), so for each module/controller device will get probe and initialized at early boot, but for some instances of device it may not be needful to be initialized it at early boot-up. If we can defer these device probe/initialization at post init, it can improve boot up time with respect to other system component.It can be useful in Linux based automotive infotainment platform, where we need camera functionality (reverse view camera) as early as possible.
Example: if we have 4 i2c controller(i2c0~i2c3) and i2c0 controller is being used by a camera driver,if camera driver is required at early boot then i2c controller driver can not be initialized at late-init and i2c0 controller need to probe before camera driver, but this force other i2c controller devices also to be probe at early boot-up itself, which may not be really required.
This patch tested on freescale imx6 udoo quad board with kernel version 3.14.56.
Patch is made against 4.7 kernel.
In order to probe a platform device at late-init, we need to declare a late_init property at desired device tree node, and invoke of_platform_populate_late_nodes exported function call from desired board file init_late machine descriptor function.
Following files has been changed for this patch
drivers/of/Kconfig
drivers/of/base.c
drivers/of/platform.c
include/linux/of.h
include/linux/of_platform.h
--- drivers/of/Kconfig | 7 +++ drivers/of/base.c | 21 +++++++++ drivers/of/platform.c | 109 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/of.h | 3 ++ include/linux/of_platform.h | 14 ++++++ 5 files changed, 154 insertions(+)
drivers/of/Kconfig +7 -0
@@ -63,6 +63,13 @@ config OF_ADDRESS config OF_ADDRESS_PCI bool +config OF_LATE_NODES + def_bool n + depends on OF_ADDRESS + help + This option makes probe of certain device nodes at late init, + whichever device nodes have a late_init property true. + config OF_IRQ def_bool y depends on !SPARC && IRQ_DOMAIN
drivers/of/base.c +21 -0
@@ -304,6 +304,7 @@ const void *__of_get_property(const struct device_node *np,return pp ? pp->value :NULL ; } +/* * Find a property with a given name for a given node * and return the value.
@@ -317,6 +318,26 @@ const void *of_get_property(const struct device_node *np, const char *name, }EXPORT_SYMBOL (of_get_property); +int of_set_property (const struct device_node *np,const char *name, +const void *val,int len) +{ +struct property *pp; +int lenp; + +if (!np) +return -ENOENT ; + + pp =of_find_property (np, name, &lenp); +if (pp) { +memcpy (pp->value, val, len); + pp->length = len; + } +else +return -ENOENT ; +return 0 ; + +} +EXPORT_SYMBOL (of_set_property);/* * arch_match_cpu_phys_id - Match the given logical CPU and physical id *
drivers/of/platform.c +109 -0
125 lines not on this page · raw message
include/linux/of.h +3 -0
@@ -324,6 +324,9 @@ extern bool of_device_is_big_endian(const struct device_node *device);extern const void *of_get_property (const struct device_node *node,const char *name,int *lenp); +extern int of_set_property (const struct device_node *node, +const char *name,const void *val, +int len);extern struct device_node *of_get_cpu_node (int cpu,unsigned int *thread);#define for_each_property_of_node (dn, pp) \ for (pp = dn->properties; pp != NULL; pp = pp->next)
include/linux/of_platform.h +14 -0
@@ -51,6 +51,13 @@ struct of_dev_auxdata { { .compatible = _compat, .phys_addr = _phys, .name = _name, \ .platform_data = _pdata } +#ifdef CONFIG_OF_LATE_NODES +struct of_late_device_node { +struct device_node *late_device_node; +struct device *late_node_parent; +struct list_head late_node; +}; +#endif extern const struct of_device_id of_default_bus_match_table[];/* Platform drivers register/unregister */
@@ -76,6 +83,13 @@ extern int of_platform_default_populate(struct device_node *root,const struct of_dev_auxdata *lookup, struct device *parent);extern void of_platform_depopulate (struct device *parent); +#ifdef CONFIG_OF_LATE_NODES +extern int of_platform_populate_late_nodes (struct device_node *root, +const struct of_device_id *matches, +const struct of_dev_auxdata *lookup); + +extern int of_device_is_late_node (const struct device_node *device); +#endif #else static inline int of_platform_populate(struct device_node *root, const struct of_device_id *matches,
Signature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 18 lines · Anshuman Gupta
This patch enables to populate platform devices from device tree at late-init As of now linux kernel has late-init call infrastructure which make a driver/module init call at late-init.it is not specific to a platform device.
This patch make a platform device to be probe at late-init,
without making its driver a late-init call.This will be useful in certain scenario when we have multiple instances of similar platform devices and it is ok to defer specific device to late-init among the multiple instance of similar devices.
Currently ARM based SOC has multiple instance of similar modules/controller (i2c,uart,mmc controller), so for each module/controller device will get probe and initialized at early boot, but for some instances of device it may not be needful to be initialized it at early boot-up. If we can defer these device probe/initialization at post init, it can improve boot up time with respect to other system component.It can be useful in Linux based automotive infotainment platform, where we need camera functionality (reverse view camera) as early as possible.
Quoted 6 lines
Example: if we have 4 i2c controller(i2c0~i2c3) and i2c0 controller is being used by a camera driver,if camera driver is required at early boot then i2c controller driver can not be initialized at late-init and i2c0 controller need to probe before camera driver, but this force other i2c controller devices also to be probe at early boot-up itself, which may not be really required.
This patch tested on freescale imx6 udoo quad board with kernel version 3.14.56.
You should generally test with something not ancient, but...
Quoted 5 lines
Patch is made against 4.7 kernel.
In order to probe a platform device at late-init, we need to declare a
late_initproperty at desired device tree node, and invokeof_platform_populate_late_nodesexported function call from desired board fileinit_latemachine descriptor function.
Sorry, but this approach is never going to be accepted. Similar things have come up for boot time optimizations. This needs to be part of more general tracking of functional dependencies (e.g. camera depends on i2c). Once we have that, then we can prioritize what to init first (e.g. camera).
Quoted 6 lines
Following files has been changed for this patch
drivers/of/Kconfig
drivers/of/base.c
drivers/of/platform.c
include/linux/of.h
include/linux/of_platform.h
Not useful information in the commit msg because it is generated right here:
Quoted 6 lines
drivers/of/Kconfig | 7 +++ drivers/of/base.c | 21 +++++++++ drivers/of/platform.c | 109 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/of.h | 3 ++ include/linux/of_platform.h | 14 ++++++ 5 files changed, 154 insertions(+)
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/Anshuman-Gupta/populate-platform-device-at-late-init/20160819-124221 config: sparc64-allyesconfig (attached as .config) compiler: sparc64-linux-gnu-gcc…
Hi Anshuman,
[auto build test ERROR on v4.8-rc2]
[also build test ERROR on next-20160819]
[cannot apply to glikely/devicetree/next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]
url: https://github.com/0day-ci/linux/commits/Anshuman-Gupta/populate-platform-device-at-late-init/20160819-124221
config: sparc64-allyesconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 5.4.0-6) 5.4.0 20160609
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64
All error/warnings (new ones prefixed by >>):
In file included from arch/sparc/include/asm/openprom.h:14:0,
from arch/sparc/include/asm/device.h:9,
from include/linux/device.h:30,
from include/linux/node.h:17,
from include/linux/cpu.h:16,
from drivers/of/base.c:25:
>> include/linux/of.h:327:12: error: conflicting types for 'of_set_property'
extern int of_set_property(const struct device_node *node,
^
In file included from include/linux/of.h:232:0,
from arch/sparc/include/asm/openprom.h:14,
from arch/sparc/include/asm/device.h:9,
from include/linux/device.h:30,
from include/linux/node.h:17,
from include/linux/cpu.h:16,
from drivers/of/base.c:25:
arch/sparc/include/asm/prom.h:40:5: note: previous declaration of 'of_set_property' was here
int of_set_property(struct device_node *node, const char *name, void *val, int len);
^
>> drivers/of/base.c:321:5: error: conflicting types for 'of_set_property'
int of_set_property(const struct device_node *np, const char *name,
^
In file included from include/linux/of.h:232:0,
from arch/sparc/include/asm/openprom.h:14,
from arch/sparc/include/asm/device.h:9,
from include/linux/device.h:30,
from include/linux/node.h:17,
from include/linux/cpu.h:16,
from drivers/of/base.c:25:
arch/sparc/include/asm/prom.h:40:5: note: previous declaration of 'of_set_property' was here
int of_set_property(struct device_node *node, const char *name, void *val, int len);
^
In file included from include/linux/linkage.h:6:0,
from include/linux/kernel.h:6,
from include/linux/list.h:8,
from include/linux/kobject.h:20,
from include/linux/device.h:17,
from include/linux/node.h:17,
from include/linux/cpu.h:16,
from drivers/of/base.c:25:
drivers/of/base.c:340:15: error: conflicting types for 'of_set_property'
EXPORT_SYMBOL(of_set_property);
^
include/linux/export.h:57:21: note: in definition of macro '___EXPORT_SYMBOL'
extern typeof(sym) sym; \
^
>> drivers/of/base.c:340:1: note: in expansion of macro 'EXPORT_SYMBOL'
EXPORT_SYMBOL(of_set_property);
^
In file included from include/linux/of.h:232:0,
from arch/sparc/include/asm/openprom.h:14,
from arch/sparc/include/asm/device.h:9,
from include/linux/device.h:30,
from include/linux/node.h:17,
from include/linux/cpu.h:16,
from drivers/of/base.c:25:
arch/sparc/include/asm/prom.h:40:5: note: previous declaration of 'of_set_property' was here
int of_set_property(struct device_node *node, const char *name, void *val, int len);
^
--
In file included from drivers/of/device.c:3:0:
>> include/linux/of.h:327:12: error: conflicting types for 'of_set_property'
extern int of_set_property(const struct device_node *node,
^
In file included from include/linux/of.h:232:0,
from drivers/of/device.c:3:
arch/sparc/include/asm/prom.h:40:5: note: previous declaration of 'of_set_property' was here
int of_set_property(struct device_node *node, const char *name, void *val, int len);
^vim +/of_set_property +327 include/linux/of.h
321 const char *const *compat);
322 extern bool of_device_is_available(const struct device_node *device);
323 extern bool of_device_is_big_endian(const struct device_node *device);
324 extern const void *of_get_property(const struct device_node *node,
325 const char *name,
326 int *lenp);
> 327 extern int of_set_property(const struct device_node *node,
328 const char *name, const void *val,
329 int len);
330 extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/Anshuman-Gupta/populate-platform-device-at-late-init/20160819-124221 config: sparc64-allmodconfig (attached as .config) compiler: sparc64-linux-gnu-gcc…
Hi Anshuman,
[auto build test ERROR on v4.8-rc2]
[also build test ERROR on next-20160822]
[cannot apply to glikely/devicetree/next]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on] [Check https://git-scm.com/docs/git-format-patch for more information]
url: https://github.com/0day-ci/linux/commits/Anshuman-Gupta/populate-platform-device-at-late-init/20160819-124221
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 5.4.0-6) 5.4.0 20160609
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64
All errors (new ones prefixed by >>):
In file included from arch/sparc/include/asm/openprom.h:14:0,
from arch/sparc/include/asm/oplib_64.h:11,
from arch/sparc/include/asm/oplib.h:4,
from arch/sparc/kernel/traps_64.c:28:
>> include/linux/of.h:327:12: error: conflicting types for 'of_set_property'
extern int of_set_property(const struct device_node *node,
^
In file included from include/linux/of.h:232:0,
from arch/sparc/include/asm/openprom.h:14,
from arch/sparc/include/asm/oplib_64.h:11,
from arch/sparc/include/asm/oplib.h:4,
from arch/sparc/kernel/traps_64.c:28:
arch/sparc/include/asm/prom.h:40:5: note: previous declaration of 'of_set_property' was here
int of_set_property(struct device_node *node, const char *name, void *val, int len);
^
--
In file included from arch/sparc/kernel/prom_common.c:22:0:
>> include/linux/of.h:327:12: error: conflicting types for 'of_set_property'
extern int of_set_property(const struct device_node *node,
^
In file included from include/linux/of.h:232:0,
from arch/sparc/kernel/prom_common.c:22:
arch/sparc/include/asm/prom.h:40:5: note: previous declaration of 'of_set_property' was here
int of_set_property(struct device_node *node, const char *name, void *val, int len);
^
In file included from include/linux/linkage.h:6:0,
from include/linux/kernel.h:6,
from arch/sparc/kernel/prom_common.c:17:
>> arch/sparc/kernel/prom_common.c:102:15: error: conflicting types for 'of_set_property'
EXPORT_SYMBOL(of_set_property);
^
include/linux/export.h:57:21: note: in definition of macro '___EXPORT_SYMBOL'
extern typeof(sym) sym; \
^
arch/sparc/kernel/prom_common.c:102:1: note: in expansion of macro 'EXPORT_SYMBOL'
EXPORT_SYMBOL(of_set_property);
^ arch/sparc/kernel/prom_common.c:54:5: note: previous definition of 'of_set_property' was here
int of_set_property(struct device_node *dp, const char *name, void *val, int len)
^
--
In file included from arch/sparc/include/asm/openprom.h:14:0,
from arch/sparc/include/asm/device.h:9,
from include/linux/device.h:30,
from include/linux/node.h:17,
from include/linux/cpu.h:16,
from drivers/of/base.c:25:
>> include/linux/of.h:327:12: error: conflicting types for 'of_set_property'
extern int of_set_property(const struct device_node *node,
^
In file included from include/linux/of.h:232:0,
from arch/sparc/include/asm/openprom.h:14,
from arch/sparc/include/asm/device.h:9,
from include/linux/device.h:30,
from include/linux/node.h:17,
from include/linux/cpu.h:16,
from drivers/of/base.c:25:
arch/sparc/include/asm/prom.h:40:5: note: previous declaration of 'of_set_property' was here
int of_set_property(struct device_node *node, const char *name, void *val, int len);
^
>> drivers/of/base.c:321:5: error: conflicting types for 'of_set_property'
int of_set_property(const struct device_node *np, const char *name,
^
In file included from include/linux/of.h:232:0,
from arch/sparc/include/asm/openprom.h:14,
from arch/sparc/include/asm/device.h:9,
from include/linux/device.h:30,
from include/linux/node.h:17,
from include/linux/cpu.h:16,
from drivers/of/base.c:25:
arch/sparc/include/asm/prom.h:40:5: note: previous declaration of 'of_set_property' was here
int of_set_property(struct device_node *node, const char *name, void *val, int len);
^
In file included from include/linux/linkage.h:6:0,
from include/linux/kernel.h:6,
from include/linux/list.h:8,
from include/linux/kobject.h:20,
from include/linux/device.h:17,
from include/linux/node.h:17,
from include/linux/cpu.h:16,
from drivers/of/base.c:25:
drivers/of/base.c:340:15: error: conflicting types for 'of_set_property'
EXPORT_SYMBOL(of_set_property);
^
include/linux/export.h:57:21: note: in definition of macro '___EXPORT_SYMBOL'
extern typeof(sym) sym; \
^
drivers/of/base.c:340:1: note: in expansion of macro 'EXPORT_SYMBOL'
EXPORT_SYMBOL(of_set_property);
^
In file included from include/linux/of.h:232:0,
from arch/sparc/include/asm/openprom.h:14,
from arch/sparc/include/asm/device.h:9,
from include/linux/device.h:30,
from include/linux/node.h:17,
from include/linux/cpu.h:16,
from drivers/of/base.c:25:
arch/sparc/include/asm/prom.h:40:5: note: previous declaration of 'of_set_property' was here
int of_set_property(struct device_node *node, const char *name, void *val, int len);
^vim +/of_set_property +327 include/linux/of.h
321 const char *const *compat);
322 extern bool of_device_is_available(const struct device_node *device);
323 extern bool of_device_is_big_endian(const struct device_node *device);
324 extern const void *of_get_property(const struct device_node *node,
325 const char *name,
326 int *lenp);
> 327 extern int of_set_property(const struct device_node *node,
328 const char *name, const void *val,
329 int len);
330 extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Quoted 1 line
You should generally test with something not ancient,
It has been tested with 4.7 kernel too, board was booted but it can not verified further as 4.7 vanilla kernel does not launched shell prompt with udoo board, well this can be done.
Quoted 5 lines
Sorry, but this approach is never going to be accepted. Similar things have come up for boot time optimizations. This needs to be part of more general tracking of functional dependencies (e.g. camera depends on i2c). Once we have that, then we can prioritize what to init first (e.g. camera).
I understands that approach is not correct but can you please elaborate or give any pointer to the approach mention by you ,"This needs to be part of more general tracking of functional dependencies". As there is scope of boot up time optimization.
Thanks,
Anshuman Gupta
Quoted 55 lines · Rob Herring
Quoted 18 lines · Anshuman Gupta
This patch enables to populate platform devices from device tree at late-init As of now linux kernel has late-init call infrastructure which make a driver/module init call at late-init.it is not specific to a platform device.
This patch make a platform device to be probe at late-init,
without making its driver a late-init call.This will be useful in certain scenario when we have multiple instances of similar platform devices and it is ok to defer specific device to late-init among the multiple instance of similar devices.
Currently ARM based SOC has multiple instance of similar modules/controller (i2c,uart,mmc controller), so for each module/controller device will get probe and initialized at early boot, but for some instances of device it may not be needful to be initialized it at early boot-up. If we can defer these device probe/initialization at post init, it can improve boot up time with respect to other system component.It can be useful in Linux based automotive infotainment platform, where we need camera functionality (reverse view camera) as early as possible.
Quoted 6 lines
Example: if we have 4 i2c controller(i2c0~i2c3) and i2c0 controller is being used by a camera driver,if camera driver is required at early boot then i2c controller driver can not be initialized at late-init and i2c0 controller need to probe before camera driver, but this force other i2c controller devices also to be probe at early boot-up itself, which may not be really required.
This patch tested on freescale imx6 udoo quad board with kernel version 3.14.56.You should generally test with something not ancient, but...
Quoted 5 lines
Patch is made against 4.7 kernel.
In order to probe a platform device at late-init, we need to declare a
late_initproperty at desired device tree node, and invokeof_platform_populate_late_nodesexported function call from desired board fileinit_latemachine descriptor function.Sorry, but this approach is never going to be accepted. Similar things have come up for boot time optimizations. This needs to be part of more general tracking of functional dependencies (e.g. camera depends on i2c). Once we have that, then we can prioritize what to init first (e.g. camera).
Quoted 6 lines
Following files has been changed for this patch
drivers/of/Kconfig
drivers/of/base.c
drivers/of/platform.c
include/linux/of.h
include/linux/of_platform.hNot useful information in the commit msg because it is generated right here:
Quoted 6 lines
drivers/of/Kconfig | 7 +++ drivers/of/base.c | 21 +++++++++ drivers/of/platform.c | 109 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/of.h | 3 ++ include/linux/of_platform.h | 14 ++++++ 5 files changed, 154 insertions(+)