Yet another series of OF merge patches.
Subsystems (6)
cover Yet another series of OF merge patches.
Nothing much to say here other than mostly mechanical merging of OF support code. Some of it remains a little ugly, but I'm taking the approach of merging the code first, and refactoring it second.
I've pushed this series out to my test-devicetree branch on my git server if anyone wants to test. That branch also includes the previous 2 patch series that I've sent out.
git://git.secretlab.ca/git/linux-2.6 test-devicetree
Compile tested on: ppc64, ppc32, microblaze, sparc64, sparc32. Boot tested on mpc5200 (ppc32) platform.
---
Grant Likely (11):
of: unify phandle name in struct device_node
microblaze: gut implementation of early_init_dt_scan_cpus()
of: merge of_attach_node() & of_detach_node()
of: Merge of_node_get() and of_node_put()
of: merge machine_is_compatible()
of/flattree: merge early_init_devtree() and early_init_move_devtree() of/flattree: merge early_init_dt_scan_chosen() of/flattree: eliminate cell_t typedef
of/flattree: merge dt_mem_next_cell
of/flattree: Merge earlyinit_dt_scan_root()
of/flattree: Merge early_init_dt_check_for_initrd()
arch/microblaze/include/asm/prom.h | 4 arch/microblaze/kernel/prom.c | 375 +------------------------- arch/powerpc/include/asm/prom.h | 4 arch/powerpc/kernel/prom.c | 366 ++----------------------- arch/powerpc/platforms/powermac/pfunc_core.c | 2 arch/sparc/kernel/devices.c | 2 arch/sparc/kernel/of_device_32.c | 2 arch/sparc/kernel/of_device_64.c | 2 arch/sparc/kernel/prom_common.c | 8 - arch/sparc/kernel/smp_64.c | 2 drivers/of/base.c | 153 +++++++++++ drivers/of/fdt.c | 204 ++++++++++++++ drivers/sbus/char/openprom.c | 10 - drivers/video/aty/atyfb_base.c | 2 include/linux/of.h | 7 include/linux/of_fdt.h | 18 + 16 files changed, 430 insertions(+), 731 deletions(-)
Signature · 1 line
Signature
PATCH 1/11 of/flattree: Merge early_init_dt_check_for_initrd()
Merge common code between PowerPC and Microblaze
---
arch/microblaze/kernel/prom.c | 32 -------------------------------- arch/powerpc/kernel/prom.c | 30 ------------------------------ drivers/of/fdt.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/of_fdt.h | 1 + 4 files changed, 38 insertions(+), 62 deletions(-)
arch/microblaze/kernel/prom.c +0 -32
@@ -113,38 +113,6 @@ static int __init early_init_dt_scan_cpus(unsigned long node,return 0 ; } -#ifdef CONFIG_BLK_DEV_INITRD -static void __init early_init_dt_check_for_initrd (unsigned long node) -{ -unsigned long l; -u32 *prop; - -pr_debug ("Looking for initrd properties... " ); - - prop =of_get_flat_dt_prop (node,"linux,initrd-start" , &l); -if (prop) { - initrd_start = (unsigned long ) -__va ((u32 )of_read_ulong (prop, l/4 )); - - prop =of_get_flat_dt_prop (node,"linux,initrd-end" , &l); -if (prop) { - initrd_end = (unsigned long ) -__va ((u32 )of_read_ulong (prop,1 /4 )); - initrd_below_start_ok =1 ; - }else { - initrd_start =0 ; - } - } - -pr_debug ("initrd_start=0x%lx initrd_end=0x%lx\n" , - initrd_start, initrd_end); -} -#else -static inline void early_init_dt_check_for_initrd (unsigned long node) -{ -} -#endif /* CONFIG_BLK_DEV_INITRD */ -static int __init early_init_dt_scan_chosen (unsigned long node,const char *uname,int depth,void *data) {
arch/powerpc/kernel/prom.c +0 -30
@@ -373,36 +373,6 @@ static int __init early_init_dt_scan_cpus(unsigned long node,return 0 ; } -#ifdef CONFIG_BLK_DEV_INITRD -static void __init early_init_dt_check_for_initrd (unsigned long node) -{ -unsigned long l; -u32 *prop; - -DBG ("Looking for initrd properties... " ); - - prop =of_get_flat_dt_prop (node,"linux,initrd-start" , &l); -if (prop) { - initrd_start = (unsigned long )__va (of_read_ulong (prop, l/4 )); - - prop =of_get_flat_dt_prop (node,"linux,initrd-end" , &l); -if (prop) { - initrd_end = (unsigned long ) -__va (of_read_ulong (prop, l/4 )); - initrd_below_start_ok =1 ; - }else { - initrd_start =0 ; - } - } - -DBG ("initrd_start=0x%lx initrd_end=0x%lx\n" , initrd_start, initrd_end); -} -#else -static inline void early_init_dt_check_for_initrd (unsigned long node) -{ -} -#endif /* CONFIG_BLK_DEV_INITRD */ -static int __init early_init_dt_scan_chosen (unsigned long node,const char *uname,int depth,void *data) {
drivers/of/fdt.c +37 -0
@@ -11,6 +11,7 @@#include <linux/kernel.h> #include <linux/lmb.h> +#include <linux/initrd.h> #include <linux/of.h> #include <linux/of_fdt.h>
@@ -369,6 +370,42 @@ unsigned long __init unflatten_dt_node(unsigned long mem,return mem; } +#ifdef CONFIG_BLK_DEV_INITRD +/** +* early_init_dt_check_for_initrd - Decode initrd location from flat tree +* @node: reference to node containing initrd location ('chosen') +*/ +void __init early_init_dt_check_for_initrd (unsigned long node) +{ +unsigned long len; +u32 *prop; + +pr_debug ("Looking for initrd properties... " ); + + prop =of_get_flat_dt_prop (node,"linux,initrd-start" , &len); +if (prop) { + initrd_start = (unsigned long ) +__va (of_read_ulong (prop, len/4 )); + + prop =of_get_flat_dt_prop (node,"linux,initrd-end" , &len); +if (prop) { + initrd_end = (unsigned long ) +__va (of_read_ulong (prop, len/4 )); + initrd_below_start_ok =1 ; + }else { + initrd_start =0 ; + } + } + +pr_debug ("initrd_start=0x%lx initrd_end=0x%lx\n" , + initrd_start, initrd_end); +} +#else +inline void early_init_dt_check_for_initrd (unsigned long node) +{ +} +#endif /* CONFIG_BLK_DEV_INITRD */ +/** * unflatten_device_tree - create tree of device_nodes from flat blob *
include/linux/of_fdt.h +1 -0
@@ -69,6 +69,7 @@ extern void *of_get_flat_dt_prop(unsigned long node, const char *name, unsigned long *size);extern int of_flat_dt_is_compatible (unsigned long node,const char *name);extern unsigned long of_get_flat_dt_root (void ); +extern void early_init_dt_check_for_initrd (unsigned long node);/* Other Prototypes */ extern void finish_device_tree (void );
Re: [PATCH 01/11] of/flattree: Merge early_init_dt_check_for_initrd()
Quoted 5 lines · Grant Likely
Merge common code between PowerPC and Microblaze
Signed-off-by Grant Likely <[email protected]>Reviewed-by Wolfram Sang <[email protected]>Tested-by Michal Simek <[email protected]>
Remind me how you want to merge that ? via my tree ?
Cheers,
Ben.
Quoted 159 lines
---
arch/microblaze/kernel/prom.c | 32 -------------------------------- arch/powerpc/kernel/prom.c | 30 ------------------------------ drivers/of/fdt.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/of_fdt.h | 1 + 4 files changed, 38 insertions(+), 62 deletions(-)arch/microblaze/kernel/prom.c +0
-32@@ -113,38 +113,6 @@ static int __init early_init_dt_scan_cpus(unsigned long node,return 0 ; } -#ifdef CONFIG_BLK_DEV_INITRD -static void __init early_init_dt_check_for_initrd (unsigned long node) -{ -unsigned long l; -u32 *prop; - -pr_debug ("Looking for initrd properties... " ); - - prop =of_get_flat_dt_prop (node,"linux,initrd-start" , &l); -if (prop) { - initrd_start = (unsigned long ) -__va ((u32 )of_read_ulong (prop, l/4 )); - - prop =of_get_flat_dt_prop (node,"linux,initrd-end" , &l); -if (prop) { - initrd_end = (unsigned long ) -__va ((u32 )of_read_ulong (prop,1 /4 )); - initrd_below_start_ok =1 ; - }else { - initrd_start =0 ; - } - } - -pr_debug ("initrd_start=0x%lx initrd_end=0x%lx\n" , - initrd_start, initrd_end); -} -#else -static inline void early_init_dt_check_for_initrd (unsigned long node) -{ -} -#endif /* CONFIG_BLK_DEV_INITRD */ -static int __init early_init_dt_scan_chosen (unsigned long node,const char *uname,int depth,void *data) {arch/powerpc/kernel/prom.c +0
-30@@ -373,36 +373,6 @@ static int __init early_init_dt_scan_cpus(unsigned long node,return 0 ; } -#ifdef CONFIG_BLK_DEV_INITRD -static void __init early_init_dt_check_for_initrd (unsigned long node) -{ -unsigned long l; -u32 *prop; - -DBG ("Looking for initrd properties... " ); - - prop =of_get_flat_dt_prop (node,"linux,initrd-start" , &l); -if (prop) { - initrd_start = (unsigned long )__va (of_read_ulong (prop, l/4 )); - - prop =of_get_flat_dt_prop (node,"linux,initrd-end" , &l); -if (prop) { - initrd_end = (unsigned long ) -__va (of_read_ulong (prop, l/4 )); - initrd_below_start_ok =1 ; - }else { - initrd_start =0 ; - } - } - -DBG ("initrd_start=0x%lx initrd_end=0x%lx\n" , initrd_start, initrd_end); -} -#else -static inline void early_init_dt_check_for_initrd (unsigned long node) -{ -} -#endif /* CONFIG_BLK_DEV_INITRD */ -static int __init early_init_dt_scan_chosen (unsigned long node,const char *uname,int depth,void *data) {drivers/of/fdt.c +37
-0@@ -11,6 +11,7 @@#include <linux/kernel.h> #include <linux/lmb.h> +#include <linux/initrd.h> #include <linux/of.h> #include <linux/of_fdt.h> @@ -369,6 +370,42 @@ unsigned long __init unflatten_dt_node(unsigned long mem,return mem; } +#ifdef CONFIG_BLK_DEV_INITRD +/** +* early_init_dt_check_for_initrd - Decode initrd location from flat tree +* @node: reference to node containing initrd location ('chosen') +*/ +void __init early_init_dt_check_for_initrd (unsigned long node) +{ +unsigned long len; +u32 *prop; + +pr_debug ("Looking for initrd properties... " ); + + prop =of_get_flat_dt_prop (node,"linux,initrd-start" , &len); +if (prop) { + initrd_start = (unsigned long ) +__va (of_read_ulong (prop, len/4 )); + + prop =of_get_flat_dt_prop (node,"linux,initrd-end" , &len); +if (prop) { + initrd_end = (unsigned long ) +__va (of_read_ulong (prop, len/4 )); + initrd_below_start_ok =1 ; + }else { + initrd_start =0 ; + } + } + +pr_debug ("initrd_start=0x%lx initrd_end=0x%lx\n" , + initrd_start, initrd_end); +} +#else +inline void early_init_dt_check_for_initrd (unsigned long node) +{ +} +#endif /* CONFIG_BLK_DEV_INITRD */ +/** * unflatten_device_tree - create tree of device_nodes from flat blob * include/linux/of_fdt.h +1
-0@@ -69,6 +69,7 @@ extern void *of_get_flat_dt_prop(unsigned long node, const char *name, unsigned long *size);extern int of_flat_dt_is_compatible (unsigned long node,const char *name);extern unsigned long of_get_flat_dt_root (void ); +extern void early_init_dt_check_for_initrd (unsigned long node);/* Other Prototypes */ extern void finish_device_tree (void );
Re: [PATCH 01/11] of/flattree: Merge early_init_dt_check_for_initrd()
Quoted 10 lines · Benjamin Herrenschmidt
Quoted 5 lines · Grant Likely
Merge common code between PowerPC and Microblaze
Signed-off-by Grant Likely <grant.likely-s3s/[email protected]>Reviewed-by Wolfram Sang <[email protected]>Tested-by Michal Simek <[email protected]>Remind me how you want to merge that ? via my tree ?
Since it is cross-arch, I'll ask Linus to pull directly. We'll see if that takes.
g.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
PATCH 2/11 of/flattree: Merge earlyinit_dt_scan_root()
In reply to Grant LikelyMerge common code between PowerPC and Microblaze
---
arch/microblaze/kernel/prom.c | 23 ----------------------- arch/powerpc/kernel/prom.c | 24 ------------------------ drivers/of/fdt.c | 26 ++++++++++++++++++++++++++ include/linux/of_fdt.h | 6 ++++++ 4 files changed, 32 insertions(+), 47 deletions(-)
arch/microblaze/kernel/prom.c +0 -23
@@ -42,9 +42,6 @@#include <asm/sections.h> #include <asm/pci-bridge.h> -static int __initdata dt_root_addr_cells; -static int __initdata dt_root_size_cells; -typedef u32 cell_t ;/* export that to outside world */
@@ -158,26 +155,6 @@ static int __init early_init_dt_scan_chosen(unsigned long node,return 1 ; } -static int __init early_init_dt_scan_root (unsigned long node, -const char *uname,int depth,void *data) -{ -u32 *prop; - -if (depth !=0 ) -return 0 ; - - prop =of_get_flat_dt_prop (node,"#size-cells" ,NULL ); - dt_root_size_cells = (prop ==NULL ) ?1 : *prop; -pr_debug ("dt_root_size_cells = %x\n" , dt_root_size_cells); - - prop =of_get_flat_dt_prop (node,"#address-cells" ,NULL ); - dt_root_addr_cells = (prop ==NULL ) ?2 : *prop; -pr_debug ("dt_root_addr_cells = %x\n" , dt_root_addr_cells); - -/* break now */ -return 1 ; -} -static u64 __init dt_mem_next_cell (int s,cell_t **cellp) {cell_t *p = *cellp;
arch/powerpc/kernel/prom.c +0 -24
@@ -61,10 +61,6 @@ #define DBG(fmt...)#endif - -static int __initdata dt_root_addr_cells; -static int __initdata dt_root_size_cells; -#ifdef CONFIG_PPC64 int __initdata iommu_is_off;int __initdata iommu_force_on;
@@ -436,26 +432,6 @@ static int __init early_init_dt_scan_chosen(unsigned long node,return 1 ; } -static int __init early_init_dt_scan_root (unsigned long node, -const char *uname,int depth,void *data) -{ -u32 *prop; - -if (depth !=0 ) -return 0 ; - - prop =of_get_flat_dt_prop (node,"#size-cells" ,NULL ); - dt_root_size_cells = (prop ==NULL ) ?1 : *prop; -DBG ("dt_root_size_cells = %x\n" , dt_root_size_cells); - - prop =of_get_flat_dt_prop (node,"#address-cells" ,NULL ); - dt_root_addr_cells = (prop ==NULL ) ?2 : *prop; -DBG ("dt_root_addr_cells = %x\n" , dt_root_addr_cells); - -/* break now */ -return 1 ; -} -static u64 __init dt_mem_next_cell (int s,cell_t **cellp) {cell_t *p = *cellp;
drivers/of/fdt.c +26 -0
@@ -15,6 +15,9 @@#include <linux/of.h> #include <linux/of_fdt.h> +int __initdata dt_root_addr_cells; +int __initdata dt_root_size_cells; +struct boot_param_header *initial_boot_params;char *find_flat_dt_string (u32 offset)
@@ -407,6 +410,29 @@ inline void early_init_dt_check_for_initrd(unsigned long node)#endif /* CONFIG_BLK_DEV_INITRD */ /** +* early_init_dt_scan_root - fetch the top level address and size cells +*/ +int __init early_init_dt_scan_root (unsigned long node,const char *uname, +int depth,void *data) +{ +u32 *prop; + +if (depth !=0 ) +return 0 ; + + prop =of_get_flat_dt_prop (node,"#size-cells" ,NULL ); + dt_root_size_cells = (prop ==NULL ) ?1 : *prop; +pr_debug ("dt_root_size_cells = %x\n" , dt_root_size_cells); + + prop =of_get_flat_dt_prop (node,"#address-cells" ,NULL ); + dt_root_addr_cells = (prop ==NULL ) ?2 : *prop; +pr_debug ("dt_root_addr_cells = %x\n" , dt_root_addr_cells); + +/* break now */ +return 1 ; +} + +/** * unflatten_device_tree - create tree of device_nodes from flat blob * * unflattens the device-tree passed by the firmware, creating the
include/linux/of_fdt.h +6 -0
@@ -58,6 +58,8 @@ struct boot_param_header { };/* TBD: Temporary export of fdt globals - remove when code fully merged */ +extern int __initdata dt_root_addr_cells; +extern int __initdata dt_root_size_cells;extern struct boot_param_header *initial_boot_params;/* For scanning the flat device-tree at boot time */
@@ -71,6 +73,10 @@ extern int of_flat_dt_is_compatible(unsigned long node, const char *name);extern unsigned long of_get_flat_dt_root (void );extern void early_init_dt_check_for_initrd (unsigned long node); +/* Early flat tree scan hooks */ +extern int early_init_dt_scan_root (unsigned long node,const char *uname, +int depth,void *data); +/* Other Prototypes */ extern void finish_device_tree (void );extern void unflatten_device_tree (void );
Re: [PATCH 02/11] of/flattree: Merge earlyinit_dt_scan_root()
Quoted 4 lines · Grant Likely
Merge common code between PowerPC and Microblaze
Signed-off-by Grant Likely <grant.likely-s3s/[email protected]>---
Ok with that, like the precendent, however you are making global some symbols that were previously static which sucks a bit... But then they can be made static again I suppose once more has been merged.
Ben.
Quoted 157 lines
arch/microblaze/kernel/prom.c | 23 ----------------------- arch/powerpc/kernel/prom.c | 24 ------------------------ drivers/of/fdt.c | 26 ++++++++++++++++++++++++++ include/linux/of_fdt.h | 6 ++++++ 4 files changed, 32 insertions(+), 47 deletions(-)arch/microblaze/kernel/prom.c +0
-23@@ -42,9 +42,6 @@#include <asm/sections.h> #include <asm/pci-bridge.h> -static int __initdata dt_root_addr_cells; -static int __initdata dt_root_size_cells; -typedef u32 cell_t ;/* export that to outside world */ @@ -158,26 +155,6 @@ static int __init early_init_dt_scan_chosen(unsigned long node,return 1 ; } -static int __init early_init_dt_scan_root (unsigned long node, -const char *uname,int depth,void *data) -{ -u32 *prop; - -if (depth !=0 ) -return 0 ; - - prop =of_get_flat_dt_prop (node,"#size-cells" ,NULL ); - dt_root_size_cells = (prop ==NULL ) ?1 : *prop; -pr_debug ("dt_root_size_cells = %x\n" , dt_root_size_cells); - - prop =of_get_flat_dt_prop (node,"#address-cells" ,NULL ); - dt_root_addr_cells = (prop ==NULL ) ?2 : *prop; -pr_debug ("dt_root_addr_cells = %x\n" , dt_root_addr_cells); - -/* break now */ -return 1 ; -} -static u64 __init dt_mem_next_cell (int s,cell_t **cellp) {cell_t *p = *cellp;arch/powerpc/kernel/prom.c +0
-24@@ -61,10 +61,6 @@ #define DBG(fmt...)#endif - -static int __initdata dt_root_addr_cells; -static int __initdata dt_root_size_cells; -#ifdef CONFIG_PPC64 int __initdata iommu_is_off;int __initdata iommu_force_on;@@ -436,26 +432,6 @@ static int __init early_init_dt_scan_chosen(unsigned long node,return 1 ; } -static int __init early_init_dt_scan_root (unsigned long node, -const char *uname,int depth,void *data) -{ -u32 *prop; - -if (depth !=0 ) -return 0 ; - - prop =of_get_flat_dt_prop (node,"#size-cells" ,NULL ); - dt_root_size_cells = (prop ==NULL ) ?1 : *prop; -DBG ("dt_root_size_cells = %x\n" , dt_root_size_cells); - - prop =of_get_flat_dt_prop (node,"#address-cells" ,NULL ); - dt_root_addr_cells = (prop ==NULL ) ?2 : *prop; -DBG ("dt_root_addr_cells = %x\n" , dt_root_addr_cells); - -/* break now */ -return 1 ; -} -static u64 __init dt_mem_next_cell (int s,cell_t **cellp) {cell_t *p = *cellp;drivers/of/fdt.c +26
-0@@ -15,6 +15,9 @@#include <linux/of.h> #include <linux/of_fdt.h> +int __initdata dt_root_addr_cells; +int __initdata dt_root_size_cells; +struct boot_param_header *initial_boot_params;char *find_flat_dt_string (u32 offset)@@ -407,6 +410,29 @@ inline void early_init_dt_check_for_initrd(unsigned long node)#endif /* CONFIG_BLK_DEV_INITRD */ /** +* early_init_dt_scan_root - fetch the top level address and size cells +*/ +int __init early_init_dt_scan_root (unsigned long node,const char *uname, +int depth,void *data) +{ +u32 *prop; + +if (depth !=0 ) +return 0 ; + + prop =of_get_flat_dt_prop (node,"#size-cells" ,NULL ); + dt_root_size_cells = (prop ==NULL ) ?1 : *prop; +pr_debug ("dt_root_size_cells = %x\n" , dt_root_size_cells); + + prop =of_get_flat_dt_prop (node,"#address-cells" ,NULL ); + dt_root_addr_cells = (prop ==NULL ) ?2 : *prop; +pr_debug ("dt_root_addr_cells = %x\n" , dt_root_addr_cells); + +/* break now */ +return 1 ; +} + +/** * unflatten_device_tree - create tree of device_nodes from flat blob * * unflattens the device-tree passed by the firmware, creating the include/linux/of_fdt.h +6
-0@@ -58,6 +58,8 @@ struct boot_param_header { };/* TBD: Temporary export of fdt globals - remove when code fully merged */ +extern int __initdata dt_root_addr_cells; +extern int __initdata dt_root_size_cells;extern struct boot_param_header *initial_boot_params;/* For scanning the flat device-tree at boot time */ @@ -71,6 +73,10 @@ extern int of_flat_dt_is_compatible(unsigned long node, const char *name);extern unsigned long of_get_flat_dt_root (void );extern void early_init_dt_check_for_initrd (unsigned long node); +/* Early flat tree scan hooks */ +extern int early_init_dt_scan_root (unsigned long node,const char *uname, +int depth,void *data); +/* Other Prototypes */ extern void finish_device_tree (void );extern void unflatten_device_tree (void );
Re: [PATCH 02/11] of/flattree: Merge earlyinit_dt_scan_root()
Quoted 9 lines · Benjamin Herrenschmidt
Quoted 4 lines · Grant Likely
Merge common code between PowerPC and Microblaze
Signed-off-by Grant Likely <[email protected]>---
Ok with that, like the precendent, however you are making global some symbols that were previously static which sucks a bit... But then they can be made static again I suppose once more has been merged.
exactly. My plan is: 1) merge. 2) refactor (and make things static again) 3) port to ARM 4) ???? 5) profit.
g.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
PATCH 3/11 of/flattree: merge dt_mem_next_cell
In reply to Grant LikelyMerge common code between PowerPC and Microblaze
---
arch/microblaze/kernel/prom.c | 8 -------- arch/powerpc/kernel/prom.c | 8 -------- drivers/of/fdt.c | 8 ++++++++ include/linux/of_fdt.h | 1 + 4 files changed, 9 insertions(+), 16 deletions(-)
arch/microblaze/kernel/prom.c +0 -8
@@ -155,14 +155,6 @@ static int __init early_init_dt_scan_chosen(unsigned long node,return 1 ; } -static u64 __init dt_mem_next_cell (int s,cell_t **cellp) -{ -cell_t *p = *cellp; - - *cellp = p + s; -return of_read_number (p, s); -} -static int __init early_init_dt_scan_memory (unsigned long node,const char *uname,int depth,void *data) {
arch/powerpc/kernel/prom.c +0 -8
@@ -432,14 +432,6 @@ static int __init early_init_dt_scan_chosen(unsigned long node,return 1 ; } -static u64 __init dt_mem_next_cell (int s,cell_t **cellp) -{ -cell_t *p = *cellp; - - *cellp = p + s; -return of_read_number (p, s); -} -#ifdef CONFIG_PPC_PSERIES /* * Interpret the ibm,dynamic-memory property in the
drivers/of/fdt.c +8 -0
@@ -432,6 +432,14 @@ int __init early_init_dt_scan_root(unsigned long node, const char *uname,return 1 ; } +u64 __init dt_mem_next_cell (int s,u32 **cellp) +{ +u32 *p = *cellp; + + *cellp = p + s; +return of_read_number (p, s); +} +/** * unflatten_device_tree - create tree of device_nodes from flat blob *
include/linux/of_fdt.h +1 -0
@@ -72,6 +72,7 @@ extern void *of_get_flat_dt_prop(unsigned long node, const char *name,extern int of_flat_dt_is_compatible (unsigned long node,const char *name);extern unsigned long of_get_flat_dt_root (void );extern void early_init_dt_check_for_initrd (unsigned long node); +extern u64 dt_mem_next_cell (int s,u32 **cellp);/* Early flat tree scan hooks */ extern int early_init_dt_scan_root(unsigned long node, const char *uname,
Re: [PATCH 03/11] of/flattree: merge dt_mem_next_cell
Quoted 10 lines · Grant Likely
Merge common code between PowerPC and Microblaze
Signed-off-by Grant Likely <[email protected]>---
arch/microblaze/kernel/prom.c | 8 -------- arch/powerpc/kernel/prom.c | 8 -------- drivers/of/fdt.c | 8 ++++++++ include/linux/of_fdt.h | 1 + 4 files changed, 9 insertions(+), 16 deletions(-)
Same comment here, something goes from static to global... do you plan to make things back to static in the end ?
Ben.
Quoted 69 lines
arch/microblaze/kernel/prom.c +0
-8@@ -155,14 +155,6 @@ static int __init early_init_dt_scan_chosen(unsigned long node,return 1 ; } -static u64 __init dt_mem_next_cell (int s,cell_t **cellp) -{ -cell_t *p = *cellp; - - *cellp = p + s; -return of_read_number (p, s); -} -static int __init early_init_dt_scan_memory (unsigned long node,const char *uname,int depth,void *data) {arch/powerpc/kernel/prom.c +0
-8@@ -432,14 +432,6 @@ static int __init early_init_dt_scan_chosen(unsigned long node,return 1 ; } -static u64 __init dt_mem_next_cell (int s,cell_t **cellp) -{ -cell_t *p = *cellp; - - *cellp = p + s; -return of_read_number (p, s); -} -#ifdef CONFIG_PPC_PSERIES /* * Interpret the ibm,dynamic-memory property in the drivers/of/fdt.c +8
-0@@ -432,6 +432,14 @@ int __init early_init_dt_scan_root(unsigned long node, const char *uname,return 1 ; } +u64 __init dt_mem_next_cell (int s,u32 **cellp) +{ +u32 *p = *cellp; + + *cellp = p + s; +return of_read_number (p, s); +} +/** * unflatten_device_tree - create tree of device_nodes from flat blob * include/linux/of_fdt.h +1
-0@@ -72,6 +72,7 @@ extern void *of_get_flat_dt_prop(unsigned long node, const char *name,extern int of_flat_dt_is_compatible (unsigned long node,const char *name);extern unsigned long of_get_flat_dt_root (void );extern void early_init_dt_check_for_initrd (unsigned long node); +extern u64 dt_mem_next_cell (int s,u32 **cellp);/* Early flat tree scan hooks */ extern int early_init_dt_scan_root(unsigned long node, const char *uname,
PATCH 4/11 of/flattree: eliminate cell_t typedef
In reply to Grant LikelyA cell is firmly established as a u32. No need to do an ugly typedef to redefine it to cell_t. Eliminate the unnecessary typedef so that it doesn't have to be added to the of_fdt header file
---
arch/microblaze/kernel/prom.c | 10 ++++------ arch/powerpc/kernel/prom.c | 14 ++++++-------- 2 files changed, 10 insertions(+), 14 deletions(-)
arch/microblaze/kernel/prom.c +4 -6
@@ -42,8 +42,6 @@#include <asm/sections.h> #include <asm/pci-bridge.h> -typedef u32 cell_t ; -/* export that to outside world */ struct device_node *of_chosen;
@@ -159,7 +157,7 @@ static int __init early_init_dt_scan_memory(unsigned long node, const char *uname, int depth, void *data) { char *type = of_get_flat_dt_prop(node, "device_type", NULL); -cell_t *reg, *endp; +u32 *reg, *endp;unsigned long l;/* Look for the ibm,dynamic-reconfiguration-memory node */
@@ -178,13 +176,13 @@ static int __init early_init_dt_scan_memory(unsigned long node, }else if (strcmp (type,"memory" ) !=0 )return 0 ; - reg = (cell_t *)of_get_flat_dt_prop (node,"linux,usable-memory" , &l); + reg = (u32 *)of_get_flat_dt_prop (node,"linux,usable-memory" , &l);if (reg ==NULL ) - reg = (cell_t *)of_get_flat_dt_prop (node,"reg" , &l); + reg = (u32 *)of_get_flat_dt_prop (node,"reg" , &l);if (reg ==NULL )return 0 ; - endp = reg + (l /sizeof (cell_t)); + endp = reg + (l /sizeof (u32));pr_debug ("memory scan node %s, reg size %ld, data: %x %x %x %x,\n" , uname, l, reg[0 ], reg[1 ], reg[2 ], reg[3 ]);
arch/powerpc/kernel/prom.c +6 -8
@@ -67,8 +67,6 @@ int __initdata iommu_force_on;unsigned long tce_alloc_start, tce_alloc_end;#endif -typedef u32 cell_t ; -extern rwlock_t devtree_lock;/* temporary while merging */ /* export that to outside world */
@@ -441,22 +439,22 @@ static int __init early_init_dt_scan_chosen(unsigned long node,*/ static int __init early_init_dt_scan_drconf_memory (unsigned long node) { -cell_t *dm, *ls, *usm; +u32 *dm, *ls, *usm;unsigned long l, n, flags;u64 base, size, lmb_size;unsigned int is_kexec_kdump =0 , rngs; ls =of_get_flat_dt_prop (node,"ibm,lmb-size" , &l); -if (ls ==NULL || l < dt_root_size_cells *sizeof (cell_t)) +if (ls ==NULL || l < dt_root_size_cells *sizeof (u32))return 0 ; lmb_size =dt_mem_next_cell (dt_root_size_cells, &ls); dm =of_get_flat_dt_prop (node,"ibm,dynamic-memory" , &l); -if (dm ==NULL || l <sizeof (cell_t)) +if (dm ==NULL || l <sizeof (u32))return 0 ; n = *dm++;/* number of entries */ -if (l < (n * (dt_root_addr_cells +4 ) +1 ) *sizeof (cell_t)) +if (l < (n * (dt_root_addr_cells +4 ) +1 ) *sizeof (u32))return 0 ;/* check if this is a kexec/kdump kernel. */
@@ -515,7 +513,7 @@ static int __init early_init_dt_scan_memory(unsigned long node, const char *uname, int depth, void *data) { char *type = of_get_flat_dt_prop(node, "device_type", NULL); -cell_t *reg, *endp; +u32 *reg, *endp;unsigned long l;/* Look for the ibm,dynamic-reconfiguration-memory node */
@@ -540,7 +538,7 @@ static int __init early_init_dt_scan_memory(unsigned long node,if (reg ==NULL )return 0 ; - endp = reg + (l /sizeof (cell_t)); + endp = reg + (l /sizeof (u32));DBG ("memory scan node %s, reg size %ld, data: %x %x %x %x,\n" , uname, l, reg[0 ], reg[1 ], reg[2 ], reg[3 ]);
Re: [PATCH 04/11] of/flattree: eliminate cell_t typedef
Quoted 6 lines · Grant Likely
A cell is firmly established as a u32. No need to do an ugly typedef to redefine it to
cell_t. Eliminate the unnecessary typedef so that it doesn't have to be added to theof_fdtheader fileSigned-off-by Grant Likely <grant.likely-s3s/[email protected]>---
I'm not sure about that one. Yes, we do use u32 a lot and cell_t rarely, so it would seem logical to switch.... On the other hand, we have that pesky endianness issue we have never fully solved. So we need accessors to sort that out, which means directly tapping things as u32 * is not a good idea if we're going to enforce the use of such accessors.
I believe we should probably just enforce that properties are big endian for flat device-trees. In which case we could just use __be32 or on of thoes sparse-friendly types. I know x86 people won't like that much and to be honest I don't know what 1295 specifies for real OFs but there aren't enough real OFs around on LE machines for us to care much about it, is there ?
The reason I prefer a fixed endianness is that allowing "LE" trees becomes really nasty when a number is expressed using multiple cells. That brings the question as to whether the two cells need to be flipped as well or only the bytes within each cell. And that's the easy bit (probably flip the whole thing). What about something like a PCI "reg" property which is made of 3 cells, two of them forming a 64-bit address and one containing additional data & attributes ? What is flipped and where ?
So yes, cell_t might not be the right approach and by far to generic a name, but u32 isn't the answer neither.
Cheers,
Ben.
Quoted 101 lines
arch/microblaze/kernel/prom.c | 10 ++++------ arch/powerpc/kernel/prom.c | 14 ++++++-------- 2 files changed, 10 insertions(+), 14 deletions(-)arch/microblaze/kernel/prom.c +4
-6@@ -42,8 +42,6 @@#include <asm/sections.h> #include <asm/pci-bridge.h> -typedef u32 cell_t ; -/* export that to outside world */ struct device_node *of_chosen;@@ -159,7 +157,7 @@ static int __init early_init_dt_scan_memory(unsigned long node, const char *uname, int depth, void *data) { char *type = of_get_flat_dt_prop(node, "device_type", NULL); -cell_t *reg, *endp; +u32 *reg, *endp;unsigned long l;/* Look for the ibm,dynamic-reconfiguration-memory node */ @@ -178,13 +176,13 @@ static int __init early_init_dt_scan_memory(unsigned long node, }else if (strcmp (type,"memory" ) !=0 )return 0 ; - reg = (cell_t *)of_get_flat_dt_prop (node,"linux,usable-memory" , &l); + reg = (u32 *)of_get_flat_dt_prop (node,"linux,usable-memory" , &l);if (reg ==NULL ) - reg = (cell_t *)of_get_flat_dt_prop (node,"reg" , &l); + reg = (u32 *)of_get_flat_dt_prop (node,"reg" , &l);if (reg ==NULL )return 0 ; - endp = reg + (l /sizeof (cell_t)); + endp = reg + (l /sizeof (u32));pr_debug ("memory scan node %s, reg size %ld, data: %x %x %x %x,\n" , uname, l, reg[0 ], reg[1 ], reg[2 ], reg[3 ]);arch/powerpc/kernel/prom.c +6
-8@@ -67,8 +67,6 @@ int __initdata iommu_force_on;unsigned long tce_alloc_start, tce_alloc_end;#endif -typedef u32 cell_t ; -extern rwlock_t devtree_lock;/* temporary while merging */ /* export that to outside world */ @@ -441,22 +439,22 @@ static int __init early_init_dt_scan_chosen(unsigned long node,*/ static int __init early_init_dt_scan_drconf_memory (unsigned long node) { -cell_t *dm, *ls, *usm; +u32 *dm, *ls, *usm;unsigned long l, n, flags;u64 base, size, lmb_size;unsigned int is_kexec_kdump =0 , rngs; ls =of_get_flat_dt_prop (node,"ibm,lmb-size" , &l); -if (ls ==NULL || l < dt_root_size_cells *sizeof (cell_t)) +if (ls ==NULL || l < dt_root_size_cells *sizeof (u32))return 0 ; lmb_size =dt_mem_next_cell (dt_root_size_cells, &ls); dm =of_get_flat_dt_prop (node,"ibm,dynamic-memory" , &l); -if (dm ==NULL || l <sizeof (cell_t)) +if (dm ==NULL || l <sizeof (u32))return 0 ; n = *dm++;/* number of entries */ -if (l < (n * (dt_root_addr_cells +4 ) +1 ) *sizeof (cell_t)) +if (l < (n * (dt_root_addr_cells +4 ) +1 ) *sizeof (u32))return 0 ;/* check if this is a kexec/kdump kernel. */ @@ -515,7 +513,7 @@ static int __init early_init_dt_scan_memory(unsigned long node, const char *uname, int depth, void *data) { char *type = of_get_flat_dt_prop(node, "device_type", NULL); -cell_t *reg, *endp; +u32 *reg, *endp;unsigned long l;/* Look for the ibm,dynamic-reconfiguration-memory node */ @@ -540,7 +538,7 @@ static int __init early_init_dt_scan_memory(unsigned long node,if (reg ==NULL )return 0 ; - endp = reg + (l /sizeof (cell_t)); + endp = reg + (l /sizeof (u32));DBG ("memory scan node %s, reg size %ld, data: %x %x %x %x,\n" , uname, l, reg[0 ], reg[1 ], reg[2 ], reg[3 ]);
Re: [PATCH 04/11] of/flattree: eliminate cell_t typedef
Quoted 14 lines · Benjamin Herrenschmidt
Quoted 6 lines · Grant Likely
A cell is firmly established as a u32. No need to do an ugly typedef to redefine it to
cell_t. Eliminate the unnecessary typedef so that it doesn't have to be added to theof_fdtheader fileSigned-off-by Grant Likely <[email protected]>---
I'm not sure about that one. Yes, we do use u32 a lot and
cell_trarely, so it would seem logical to switch.... On the other hand, we have that pesky endianness issue we have never fully solved. So we need accessors to sort that out, which means directly tapping things as u32 * is not a good idea if we're going to enforce the use of such accessors.
Quoted 6 lines
I believe we should probably just enforce that properties are big endian for flat device-trees. In which case we could just use
__be32or on of thoes sparse-friendly types. I know x86 people won't like that much and to be honest I don't know what 1295 specifies for real OFs but there aren't enough real OFs around on LE machines for us to care much about it, is there ?
Word from Mitch is the device tree is network byte order. period.
Quoted 8 lines
The reason I prefer a fixed endianness is that allowing "LE" trees becomes really nasty when a number is expressed using multiple cells. That brings the question as to whether the two cells need to be flipped as well or only the bytes within each cell. And that's the easy bit (probably flip the whole thing). What about something like a PCI "reg" property which is made of 3 cells, two of them forming a 64-bit address and one containing additional data & attributes ? What is flipped and where ?
exactly.
Quoted 2 lines
So yes,
cell_tmight not be the right approach and by far to generic a name, but u32 isn't the answer neither.
You're right, it's not, but makes merging less complex, and then I can refactor properly.
g.
Signature · 6 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 04/11] of/flattree: eliminate cell_t typedef
Quoted 3 lines · Grant Likely
You're right, it's not, but makes merging less complex, and then I can refactor properly.
Still, make them __be32 at least
Cheers,
Ben.
Re: [PATCH 04/11] of/flattree: eliminate cell_t typedef
Quoted 4 lines
Quoted 2 lines
You're right, it's not, but makes merging less complex, and then I can refactor properly.
Still, make them
__be32at least
There is no alignment guarantee at all either, better make it all u8 and use accessor functions everywhere.
Segher
Re: [PATCH 04/11] of/flattree: eliminate cell_t typedef
Quoted 8 lines · Segher Boessenkool
Quoted 5 lines
Quoted 3 lines
You're right, it's not, but makes merging less complex, and then I can
refactor properly.Still, make them
__be32at leastThere is no alignment guarantee at all either, better make it all u8 and use accessor functions everywhere.
Well... if you want to force using an accessor, then make it an opaque type. But __be32 is fine. It doesn't necessarily convey alignment and besides, there happens to -be- aligned in almost all cases so far :-) The flat tree format guarantees 32-bit alignment for the start of a property, so we are good here I think.
Cheers,
Ben.
David Miller
maintainerRe: [PATCH 04/11] of/flattree: eliminate cell_t typedef
In reply to Segher BoessenkoolFrom: Segher Boessenkool <[email protected]>
Date: Thu, 26 Nov 2009 22:36:41 +0100
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
You're right, it's not, but makes merging less complex, and then I can refactor properly.
Still, make them
__be32at leastThere is no alignment guarantee at all either, better make it all u8 and use accessor functions everywhere.
I think that might be overkill.
Re: [PATCH 04/11] of/flattree: eliminate cell_t typedef
In reply to Benjamin HerrenschmidtQuoted 6 lines · Benjamin Herrenschmidt
Quoted 3 lines · Grant Likely
You're right, it's not, but makes merging less complex, and then I can refactor properly.
Still, make them
__be32at least
Okay. Done.
g.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
A message that is not in the archive (sent off-list or not yet received): fa686aa40911252005o2db85dfk3d9acc61c12ca5e5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 04/11] of/flattree: eliminate cell_t typedef
In message: <fa686aa40911252005o2db85dfk3d9acc61c12ca5e5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
Grant Likely <grant.likely-s3s/[email protected]> writes:
: Word from Mitch is the device tree is network byte order. period.
OpenFirmware defines the order to be big endian always, even on little endian processors.
Warner
A message that is not in the archive (sent off-list or not yet received): 20091125.232818.-1350498258.imp-uzTCJ5RojNnQT0dZR+AlfA@public.gmane.org
Re: [PATCH 04/11] of/flattree: eliminate cell_t typedef
Quoted 7 lines · M. Warner Losh
In message:
<fa686aa40911252005o2db85dfk3d9acc61c12ca5e5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
Grant Likely <grant.likely-s3s/[email protected]> writes:
: Word from Mitch is the device tree is network byte order. period.OpenFirmware defines the order to be big endian always, even on little endian processors.
Right, that's the only sane way to do it, I just didn't remember off hand what was said in the OF spec :-)
Cheers,
Ben.
Re: [PATCH 04/11] of/flattree: eliminate cell_t typedef
Quoted 3 lines
Right, that's the only sane way to do it, I just didn't remember off hand what was said in the OF spec :-)
3.2.2.1.2 Property values
The property-encoding format is independent of hardware byte order and alignment characteristics. The encoded byte order is well-defined (in particular, it is big endian). ...
...
-- 32-bit integer. A 32-bit integer is encoded into a property value byte array by storing the most significant byte at the next available address, followed (at address+1) by the high middle byte, the low middle byte, and (at address+3) the least significant byte.
PATCH 5/11 of/flattree: merge early_init_dt_scan_chosen()
In reply to Grant LikelyMerge common code between PowerPC and Microblaze. This patch splits the arch-specific stuff out into a new function, early_init_dt_scan_chosen_arch().
---
arch/microblaze/kernel/prom.c | 44 ++------------------------------------- arch/powerpc/kernel/prom.c | 46 +++++++++-------------------------------- drivers/of/fdt.c | 38 ++++++++++++++++++++++++++++++++++ include/linux/of_fdt.h | 3 +++ 4 files changed, 53 insertions(+), 78 deletions(-)
arch/microblaze/kernel/prom.c +2 -42
@@ -108,49 +108,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node,return 0 ; } -static int __init early_init_dt_scan_chosen (unsigned long node, -const char *uname,int depth,void *data) +void __init early_init_dt_scan_chosen_arch (unsigned long node) { -unsigned long l; -char *p; - -pr_debug ("search \"chosen\", depth: %d, uname: %s\n" , depth, uname); - -if (depth !=1 || - (strcmp (uname,"chosen" ) !=0 && -strcmp (uname,"chosen@0" ) !=0 )) -return 0 ; - -#ifdef CONFIG_KEXEC - lprop = (u64 *)of_get_flat_dt_prop (node, -"linux,crashkernel-base" ,NULL ); -if (lprop) - crashk_res.start = *lprop; - - lprop = (u64 *)of_get_flat_dt_prop (node, -"linux,crashkernel-size" ,NULL ); -if (lprop) - crashk_res.end = crashk_res.start + *lprop -1 ; -#endif - -early_init_dt_check_for_initrd (node); - -/* Retreive command line */ - p =of_get_flat_dt_prop (node,"bootargs" , &l); -if (p !=NULL && l >0 ) -strlcpy (cmd_line, p,min ((int )l,COMMAND_LINE_SIZE )); - -#ifdef CONFIG_CMDLINE -#ifndef CONFIG_CMDLINE_FORCE - if (p == NULL || l == 0 || (l == 1 && (*p) == 0)) -#endif -strlcpy (cmd_line,CONFIG_CMDLINE ,COMMAND_LINE_SIZE ); -#endif /* CONFIG_CMDLINE */ - -pr_debug ("Command line is: %s\n" , cmd_line); - -/* break now */ -return 1 ; +/* No Microblaze specific code here */ } static int __init early_init_dt_scan_memory(unsigned long node,
arch/powerpc/kernel/prom.c +10 -36
68 lines not on this page · raw message
drivers/of/fdt.c +38 -0
@@ -15,6 +15,10 @@#include <linux/of.h> #include <linux/of_fdt.h> +#ifdef CONFIG_PPC +#include <asm/machdep.h> +#endif /* CONFIG_PPC */ +int __initdata dt_root_addr_cells;int __initdata dt_root_size_cells;
@@ -440,6 +444,40 @@ u64 __init dt_mem_next_cell(int s, u32 **cellp)return of_read_number (p, s); } +int __init early_init_dt_scan_chosen (unsigned long node,const char *uname, +int depth,void *data) +{ +unsigned long l; +char *p; + +pr_debug ("search \"chosen\", depth: %d, uname: %s\n" , depth, uname); + +if (depth !=1 || + (strcmp (uname,"chosen" ) !=0 &&strcmp (uname,"chosen@0" ) !=0 )) +return 0 ; + +early_init_dt_check_for_initrd (node); + +/* Retreive command line */ + p =of_get_flat_dt_prop (node,"bootargs" , &l); +if (p !=NULL && l >0 ) +strlcpy (cmd_line, p,min ((int )l,COMMAND_LINE_SIZE )); + +#ifdef CONFIG_CMDLINE +#ifndef CONFIG_CMDLINE_FORCE + if (p == NULL || l == 0 || (l == 1 && (*p) == 0)) +#endif +strlcpy (cmd_line,CONFIG_CMDLINE ,COMMAND_LINE_SIZE ); +#endif /* CONFIG_CMDLINE */ + +early_init_dt_scan_chosen_arch (node); + +pr_debug ("Command line is: %s\n" , cmd_line); + +/* break now */ +return 1 ; +} +/** * unflatten_device_tree - create tree of device_nodes from flat blob *
include/linux/of_fdt.h +3 -0
@@ -71,6 +71,9 @@ extern void *of_get_flat_dt_prop(unsigned long node, const char *name, unsigned long *size);extern int of_flat_dt_is_compatible (unsigned long node,const char *name);extern unsigned long of_get_flat_dt_root (void ); +extern void early_init_dt_scan_chosen_arch (unsigned long node); +extern int early_init_dt_scan_chosen (unsigned long node,const char *uname, +int depth,void *data);extern void early_init_dt_check_for_initrd (unsigned long node);extern u64 dt_mem_next_cell (int s,u32 **cellp);
PATCH 6/11 of/flattree: merge early_init_devtree() and early_init_move_devtree()
In reply to Grant LikelyMerge common code between Microblaze and PowerPC
---
arch/microblaze/kernel/prom.c | 53 +++-------------------- arch/powerpc/kernel/prom.c | 94 +++-------------------------------------- drivers/of/fdt.c | 92 ++++++++++++++++++++++++++++++++++++++++ include/linux/of_fdt.h | 7 +++ 4 files changed, 115 insertions(+), 131 deletions(-)
arch/microblaze/kernel/prom.c +8 -45
@@ -47,9 +47,8 @@ struct device_node *of_chosen;#define early_init_dt_scan_drconf_memory (node) 0 -static int __init early_init_dt_scan_cpus (unsigned long node, -const char *uname,int depth, -void *data) +int __init early_init_dt_scan_cpus (unsigned long node,const char *uname, +int depth,void *data) {static int logical_cpuid;char *type =of_get_flat_dt_prop (node,"device_type" ,NULL );
@@ -113,8 +112,8 @@ void __init early_init_dt_scan_chosen_arch(unsigned long node)/* No Microblaze specific code here */ } -static int __init early_init_dt_scan_memory (unsigned long node, -const char *uname,int depth,void *data) +int __init early_init_dt_scan_memory (unsigned long node,const char *uname, +int depth,void *data) {char *type =of_get_flat_dt_prop (node,"device_type" ,NULL );u32 *reg, *endp;
@@ -201,7 +200,7 @@ static inline unsigned long phyp_dump_calculate_reserve_size(void)* without reserving anything. The memory in case of dump being * active is freed when the dump is collected (by userland tools). */ -static void __init phyp_dump_reserve_mem (void ) +void __init phyp_dump_reserve_mem (void ) {unsigned long base, size;unsigned long variable_reserve_size;
@@ -240,7 +239,7 @@ static void __init phyp_dump_reserve_mem(void) } }#else -static inline void __init phyp_dump_reserve_mem (void ) {} +inline void __init phyp_dump_reserve_mem (void ) {}#endif /* CONFIG_PHYP_DUMP && CONFIG_PPC_RTAS */ #ifdef CONFIG_EARLY_PRINTK
@@ -277,45 +276,9 @@ int __init early_uartlite_console(void) }#endif -void __init early_init_devtree (void *params) +void __init early_init_devtree_arch (void ) { -pr_debug (" -> early_init_devtree(%p)\n" , params); - -/* Setup flat device-tree pointer */ - initial_boot_params = params; - -#ifdef CONFIG_PHYP_DUMP -/* scan tree to see if dump occured during last boot */ -of_scan_flat_dt (early_init_dt_scan_phyp_dump,NULL ); -#endif - -/* Retrieve various informations from the /chosen node of the -* device-tree, including the platform type, initrd location and -* size, TCE reserve, and more ... -*/ -of_scan_flat_dt (early_init_dt_scan_chosen,NULL ); - -/* Scan memory nodes and rebuild LMBs */ -lmb_init (); -of_scan_flat_dt (early_init_dt_scan_root,NULL ); -of_scan_flat_dt (early_init_dt_scan_memory,NULL ); - -/* Save command line for /proc/cmdline and then parse parameters */ -strlcpy (boot_command_line, cmd_line,COMMAND_LINE_SIZE ); -parse_early_param (); - -lmb_analyze (); - -pr_debug ("Phys. mem: %lx\n" , (unsigned long )lmb_phys_mem_size ()); - -pr_debug ("Scanning CPUs ...\n" ); - -/* Retreive CPU related informations from the flat tree -* (altivec support, boot CPU ID, ...) -*/ -of_scan_flat_dt (early_init_dt_scan_cpus,NULL ); - -pr_debug (" <- early_init_devtree()\n" ); +/* No Microblaze specific code here */ }/**
arch/powerpc/kernel/prom.c +8 -86
143 lines not on this page · raw message
drivers/of/fdt.c +92 -0
105 lines not on this page · raw message
include/linux/of_fdt.h +7 -0
@@ -75,6 +75,13 @@ extern void early_init_dt_scan_chosen_arch(unsigned long node);extern int early_init_dt_scan_chosen (unsigned long node,const char *uname,int depth,void *data);extern void early_init_dt_check_for_initrd (unsigned long node); +extern int early_init_dt_scan_cpus (unsigned long node,const char *uname, +int depth,void *data); +extern int early_init_dt_scan_memory (unsigned long node,const char *uname, +int depth,void *data); +extern void early_reserve_mem (void ); +extern void early_init_devtree_arch (void ); +extern void phyp_dump_reserve_mem (void );extern u64 dt_mem_next_cell (int s,u32 **cellp);/* Early flat tree scan hooks */
Re: [PATCH 06/11] of/flattree: merge early_init_devtree() and early_init_move_devtree()
arch/microblaze/kernel/prom.c struct device_node *of_chosen; · line 52
Quoted 7 lines · Grant Likely
arch/microblaze/kernel/prom.c +2
-3-static int __init early_init_dt_scan_cpus (unsigned long node, -const char *uname,int depth, -void *data) +int __init early_init_dt_scan_cpus (unsigned long node,const char *uname, +int depth,void *data) {
So now you make this one non-static as well with little hope of making it static ever again
arch/microblaze/kernel/prom.c void __init early_init_dt_scan_chosen_arch(unsigned long node) · line 117
Quoted 11 lines
arch/microblaze/kernel/prom.c +2
-2static int logical_cpuid;char *type =of_get_flat_dt_prop (node,"device_type" ,NULL );@@ -113,8 +112,8 @@ void __init early_init_dt_scan_chosen_arch(unsigned long node)/* No Microblaze specific code here */ } -static int __init early_init_dt_scan_memory (unsigned long node, -const char *uname,int depth,void *data) +int __init early_init_dt_scan_memory (unsigned long node,const char *uname, +int depth,void *data) {
And this one
arch/microblaze/kernel/prom.c static inline unsigned long phyp_dump_calculate_reserve_size(void) · line 204
Quoted 9 lines
arch/microblaze/kernel/prom.c +1
-1char *type =of_get_flat_dt_prop (node,"device_type" ,NULL );u32 *reg, *endp;@@ -201,7 +200,7 @@ static inline unsigned long phyp_dump_calculate_reserve_size(void)* without reserving anything. The memory in case of dump being * active is freed when the dump is collected (by userland tools). */ -static void __init phyp_dump_reserve_mem (void ) +void __init phyp_dump_reserve_mem (void ) {
And this one...
drivers/of/fdt.c int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, · line 493
Quoted 8 lines
drivers/of/fdt.c +7
-0/** +* early_init_move_devtree - move tree to an unused area, if needed. +* +* The device tree may be allocated beyond our memory limit, or inside the +* crash kernel region for kdump. If so, move it out of the way. +*/ +#if defined(CONFIG_PPC ) +static void __init early_init_move_devtree (void )
And you still end up with an ifdef mess in the common code ...
Would it be possible instead to have one common early_init_devtree() that calls into the "common" ones (which you can then make static again, inside the common code) and then calls one arch_early_init_devtree() which regroups the arch specific ones ?
Or there's too many ordering issues ?
Another option then is to call from that early_init_devtree() something like:
arch_early_init_dt_mem()
arch_early_init_dt_cpu()
arch_early_init_move_devtree()
etc... in the right spots in the common code and have the archs who don't do anything there just have them as empty inlines.
Cheers,
Ben.
Re: [PATCH 06/11] of/flattree: merge early_init_devtree() and early_init_move_devtree()
Quoted 11 lines · Benjamin Herrenschmidt
drivers/of/fdt.c int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, · line 493
Quoted 8 lines · Grant Likely
/**
+ *early_init_move_devtree- move tree to an unused area, if needed.
+ *
+ * The device tree may be allocated beyond our memory limit, or inside the
+ * crash kernel region for kdump. If so, move it out of the way.
+ */drivers/of/fdt.c +2
-0+#if defined(CONFIG_PPC ) +static void __init early_init_move_devtree (void )And you still end up with an ifdef mess in the common code ...
The #ifdefs are temporary. I'm leaving them in now exactly because they are ugly and show where the code needs to be refactored and reorganized. Once everything is merged, I'll probably do exactly what you suggest. I just cannot yet tell the exact structure of it until I see the merged version.
g.
Signature · 6 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 06/11] of/flattree: merge early_init_devtree() and early_init_move_devtree()
In reply to Grant LikelyHi Grant,
Quoted 6 lines
drivers/of/fdt.c +6
-0+/* Scan memory nodes and rebuild LMBs */ +lmb_init (); +of_scan_flat_dt (early_init_dt_scan_root,NULL ); +of_scan_flat_dt (early_init_dt_scan_memory,NULL ); + +/* Save command line for /proc/cmdline and then parse parameters */
drivers/of/fdt.c int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, · line 555
Quoted 10 lines
drivers/of/fdt.c +10
-0+strlcpy (boot_command_line, cmd_line,COMMAND_LINE_SIZE ); +parse_early_param (); + +/* This is in an arbitrary spot, but it is temporary. After all +* the common code is merged, the structure of the early init +* code will be reevaluated and refactored */ +early_init_devtree_arch (); + +lmb_analyze (); +lmb_dump_all ();
So we're assuming that the arch has lmb support, or should we make this conditional on CONFIG_HAVE_LMB?
Looks like ARM has its own lmb implementation (struct membank), so for the former case, I'd need to convert that to use lmb instead (which may not be a bad thing overall...)
Cheers,
Jeremy
Re: [PATCH 06/11] of/flattree: merge early_init_devtree() and early_init_move_devtree()
Quoted 13 lines · Jeremy Kerr
Hi Grant,
Quoted 11 lines
+ /* Scan memory nodes and rebuild LMBs */
+lmb_init();
+of_scan_flat_dt(early_init_dt_scan_root, NULL);
+of_scan_flat_dt(early_init_dt_scan_memory, NULL);drivers/of/fdt.c +7
-0+ + /* Save command line for /proc/cmdline and then parse parameters */ + strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE); + parse_early_param(); + + /* This is in an arbitrary spot, but it is temporary. After all +* the common code is merged, the structure of the early init
Quoted 8 lines
Quoted 5 lines
+ * code will be reevaluated and refactored */
+early_init_devtree_arch();
+
+lmb_analyze();
+lmb_dump_all();So we're assuming that the arch has lmb support, or should we make this conditional on
CONFIG_HAVE_LMB?
I'm not making any assumptions yet. I'm just merging the code. A lot of it needs to be refactored after the merge. Feel free to send patches to rework want you need.
g.
Signature · 6 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 7/11 of: merge machine_is_compatible()
In reply to Grant LikelyMerge common code between PowerPC and Microblaze
---
arch/microblaze/kernel/prom.c | 18 ------------------ arch/powerpc/kernel/prom.c | 18 ------------------ drivers/of/base.c | 18 ++++++++++++++++++ 3 files changed, 18 insertions(+), 36 deletions(-)
arch/microblaze/kernel/prom.c +0 -18
@@ -281,24 +281,6 @@ void __init early_init_devtree_arch(void)/* No Microblaze specific code here */ } -/** -* Indicates whether the root node has a given value in its -* compatible property. -*/ -int machine_is_compatible (const char *compat) -{ -struct device_node *root; -int rc =0 ; - - root =of_find_node_by_path ("/" ); -if (root) { - rc =of_device_is_compatible (root, compat); -of_node_put (root); - } -return rc; -} -EXPORT_SYMBOL (machine_is_compatible); -/******* * * New implementation of the OF "find" APIs, return a refcounted
arch/powerpc/kernel/prom.c +0 -18
@@ -677,24 +677,6 @@ void __init early_init_devtree_arch(void)lmb_enforce_memory_limit (limit); } -/** -* Indicates whether the root node has a given value in its -* compatible property. -*/ -int machine_is_compatible (const char *compat) -{ -struct device_node *root; -int rc =0 ; - - root =of_find_node_by_path ("/" ); -if (root) { - rc =of_device_is_compatible (root, compat); -of_node_put (root); - } -return rc; -} -EXPORT_SYMBOL (machine_is_compatible); -/******* * * New implementation of the OF "find" APIs, return a refcounted
drivers/of/base.c +18 -0
@@ -144,6 +144,24 @@ int of_device_is_compatible(const struct device_node *device,EXPORT_SYMBOL (of_device_is_compatible);/** +* Indicates whether the root node has a given value in its +* compatible property. +*/ +int machine_is_compatible (const char *compat) +{ +struct device_node *root; +int rc =0 ; + + root =of_find_node_by_path ("/" ); +if (root) { + rc =of_device_is_compatible (root, compat); +of_node_put (root); + } +return rc; +} +EXPORT_SYMBOL (machine_is_compatible); + +/** * of_device_is_available - check if a device is available for use * * @device: Node to check for availability
Re: [PATCH 07/11] of: merge machine_is_compatible()
Quoted 1 line · Grant Likely
Merge common code between PowerPC and Microblaze
I don't like moving this one to common code without the of_ prefix. I think you should move it with the of_ prefix, and then add a alias in powerpc and microblaze without of_ in a header until we fix all call sites (which you can put on your to-do list :-)
Cheers,
Ben.
Quoted 95 lines
Signed-off-by Grant Likely <[email protected]>---
arch/microblaze/kernel/prom.c | 18 ------------------ arch/powerpc/kernel/prom.c | 18 ------------------ drivers/of/base.c | 18 ++++++++++++++++++ 3 files changed, 18 insertions(+), 36 deletions(-)arch/microblaze/kernel/prom.c +0
-18@@ -281,24 +281,6 @@ void __init early_init_devtree_arch(void)/* No Microblaze specific code here */ } -/** -* Indicates whether the root node has a given value in its -* compatible property. -*/ -int machine_is_compatible (const char *compat) -{ -struct device_node *root; -int rc =0 ; - - root =of_find_node_by_path ("/" ); -if (root) { - rc =of_device_is_compatible (root, compat); -of_node_put (root); - } -return rc; -} -EXPORT_SYMBOL (machine_is_compatible); -/******* * * New implementation of the OF "find" APIs, return a refcounted arch/powerpc/kernel/prom.c +0
-18@@ -677,24 +677,6 @@ void __init early_init_devtree_arch(void)lmb_enforce_memory_limit (limit); } -/** -* Indicates whether the root node has a given value in its -* compatible property. -*/ -int machine_is_compatible (const char *compat) -{ -struct device_node *root; -int rc =0 ; - - root =of_find_node_by_path ("/" ); -if (root) { - rc =of_device_is_compatible (root, compat); -of_node_put (root); - } -return rc; -} -EXPORT_SYMBOL (machine_is_compatible); -/******* * * New implementation of the OF "find" APIs, return a refcounted drivers/of/base.c +18
-0@@ -144,6 +144,24 @@ int of_device_is_compatible(const struct device_node *device,EXPORT_SYMBOL (of_device_is_compatible);/** +* Indicates whether the root node has a given value in its +* compatible property. +*/ +int machine_is_compatible (const char *compat) +{ +struct device_node *root; +int rc =0 ; + + root =of_find_node_by_path ("/" ); +if (root) { + rc =of_device_is_compatible (root, compat); +of_node_put (root); + } +return rc; +} +EXPORT_SYMBOL (machine_is_compatible); + +/** * of_device_is_available - check if a device is available for use * * @device: Node to check for availability
Re: [PATCH 07/11] of: merge machine_is_compatible()
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 1 line · Grant Likely
Merge common code between PowerPC and Microblaze
I don't like moving this one to common code without the
of_prefix. I think you should move it with theof_prefix, and then add a alias in powerpc and microblaze withoutof_in a header until we fix all call sites (which you can put on your to-do list :-)
I've written another patch to rename it.
g.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
PATCH 8/11 of: Merge of_node_get() and of_node_put()
In reply to Grant LikelyMerge common code between PowerPC and MicroBlaze
---
arch/microblaze/kernel/prom.c | 74 ---------------------------------------- arch/powerpc/kernel/prom.c | 73 ---------------------------------------- drivers/of/base.c | 75 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 147 deletions(-)
arch/microblaze/kernel/prom.c +0 -74
@@ -313,80 +313,6 @@ struct device_node *of_find_node_by_phandle(phandle handle) }EXPORT_SYMBOL (of_find_node_by_phandle); -/** -* of_node_get - Increment refcount of a node -* @node: Node to inc refcount, NULL is supported to -* simplify writing of callers -* -* Returns node. -*/ -struct device_node *of_node_get (struct device_node *node) -{ -if (node) -kref_get (&node->kref); -return node; -} -EXPORT_SYMBOL (of_node_get); - -static inline struct device_node *kref_to_device_node (struct kref *kref) -{ - return container_of(kref, struct device_node, kref); -} - -/** -* of_node_release - release a dynamically allocated node -* @kref: kref element of the node to be released -* -* In of_node_put() this function is passed to kref_put() -* as the destructor. -*/ -static void of_node_release (struct kref *kref) -{ -struct device_node *node =kref_to_device_node (kref); -struct property *prop = node->properties; - -/* We should never be releasing nodes that haven't been detached. */ -if (!of_node_check_flag (node,OF_DETACHED )) { -printk (KERN_INFO "WARNING: Bad of_node_put() on %s\n" , - node->full_name); -dump_stack (); -kref_init (&node->kref); -return ; - } - -if (!of_node_check_flag (node,OF_DYNAMIC )) -return ; - -while (prop) { -struct property *next = prop->next; -kfree (prop->name); -kfree (prop->value); -kfree (prop); - prop = next; - -if (!prop) { - prop = node->deadprops; - node->deadprops =NULL ; - } - } -kfree (node->full_name); -kfree (node->data); -kfree (node); -} - -/** -* of_node_put - Decrement refcount of a node -* @node: Node to dec refcount, NULL is supported to -* simplify writing of callers -* -*/ -void of_node_put (struct device_node *node) -{ -if (node) -kref_put (&node->kref, of_node_release); -} -EXPORT_SYMBOL (of_node_put); -/* * Plug a device node into the tree and global list. */
arch/powerpc/kernel/prom.c +0 -73
79 lines not on this page · raw message
drivers/of/base.c +75 -0
81 lines not on this page · raw message
Re: [PATCH 08/11] of: Merge of_node_get() and of_node_put()
Review
Quoted 3 lines · Grant Likely
(quoted diff) +2
-0+#if !defined(CONFIG_SPARC) /* SPARC doesn't do ref counting (yet) */ +/**
Make this a Kconfig symbol, something like CONFIG_OF_DYNAMIC. You need refcounting when you can add/remove nodes dynamically. Some embedded archs might want the option to not enable that and save space.
Cheers,
Ben.
PATCH 9/11 of: merge of_attach_node() & of_detach_node()
In reply to Grant LikelyMerge common code between PowerPC and Microblaze
---
arch/microblaze/include/asm/prom.h | 4 -- arch/microblaze/kernel/prom.c | 59 ----------------------------------- arch/powerpc/include/asm/prom.h | 4 -- arch/powerpc/kernel/prom.c | 59 ----------------------------------- drivers/of/base.c | 60 ++++++++++++++++++++++++++++++++++++ include/linux/of.h | 4 ++ 6 files changed, 64 insertions(+), 126 deletions(-)
arch/microblaze/include/asm/prom.h +0 -4
@@ -39,10 +39,6 @@ extern struct device_node *of_chosen;extern rwlock_t devtree_lock;/* temporary while merging */ -/* For updating the device tree at runtime */ -extern void of_attach_node (struct device_node *); -extern void of_detach_node (struct device_node *); -/* Other Prototypes */ extern int early_uartlite_console (void );
arch/microblaze/kernel/prom.c +0 -59
65 lines not on this page · raw message
arch/powerpc/include/asm/prom.h +0 -4
@@ -34,10 +34,6 @@ extern struct device_node *of_chosen;#define HAVE_ARCH_DEVTREE_FIXUPS -/* For updating the device tree at runtime */ -extern void of_attach_node (struct device_node *); -extern void of_detach_node (struct device_node *); -#ifdef CONFIG_PPC32 /* * PCI <-> OF matching functions
arch/powerpc/kernel/prom.c +0 -59
65 lines not on this page · raw message
drivers/of/base.c +60 -0
66 lines not on this page · raw message
include/linux/of.h +4 -0
@@ -130,6 +130,10 @@ static inline unsigned long of_read_ulong(const u32 *cell, int size)#define OF_BAD_ADDR ((u64)-1) +/* For updating the device tree at runtime */ +extern void of_attach_node (struct device_node *); +extern void of_detach_node (struct device_node *); +extern struct device_node *of_find_node_by_name (struct device_node *from,const char *name);#define for_each_node_by_name (dn, name) \
Re: [PATCH 09/11] of: merge of_attach_node() & of_detach_node()
Quoted 1 line · Grant Likely
Merge common code between PowerPC and Microblaze
Some of those guys might wnat to be in of_dynamic (see previous email)
Remember: We want to keep the footprint low for embedded archs that don't want to do dynamic stuff. Really low.
Cheers,
Ben.
Quoted 267 lines
Signed-off-by Grant Likely <[email protected]>---
arch/microblaze/include/asm/prom.h | 4 -- arch/microblaze/kernel/prom.c | 59 ----------------------------------- arch/powerpc/include/asm/prom.h | 4 -- arch/powerpc/kernel/prom.c | 59 ----------------------------------- drivers/of/base.c | 60 ++++++++++++++++++++++++++++++++++++ include/linux/of.h | 4 ++ 6 files changed, 64 insertions(+), 126 deletions(-)arch/microblaze/include/asm/prom.h +0
-4@@ -39,10 +39,6 @@ extern struct device_node *of_chosen;extern rwlock_t devtree_lock;/* temporary while merging */ -/* For updating the device tree at runtime */ -extern void of_attach_node (struct device_node *); -extern void of_detach_node (struct device_node *); -/* Other Prototypes */ extern int early_uartlite_console (void );arch/microblaze/kernel/prom.c +0
-59@@ -313,65 +313,6 @@ struct device_node *of_find_node_by_phandle(phandle handle) }EXPORT_SYMBOL (of_find_node_by_phandle); -/* -* Plug a device node into the tree and global list. -*/ -void of_attach_node (struct device_node *np) -{ -unsigned long flags; - -write_lock_irqsave (&devtree_lock, flags); - np->sibling = np->parent->child; - np->allnext = allnodes; - np->parent->child = np; - allnodes = np; -write_unlock_irqrestore (&devtree_lock, flags); -} - -/* -* "Unplug" a node from the device tree. The caller must hold -* a reference to the node. The memory associated with the node -* is not freed until its refcount goes to zero. -*/ -void of_detach_node (struct device_node *np) -{ -struct device_node *parent; -unsigned long flags; - -write_lock_irqsave (&devtree_lock, flags); - - parent = np->parent; -if (!parent) - goto out_unlock; - -if (allnodes == np) - allnodes = np->allnext; -else { -struct device_node *prev; -for (prev = allnodes; - prev->allnext != np; - prev = prev->allnext) - ; - prev->allnext = np->allnext; - } - -if (parent->child == np) - parent->child = np->sibling; -else { -struct device_node *prevsib; -for (prevsib = np->parent->child; - prevsib->sibling != np; - prevsib = prevsib->sibling) - ; - prevsib->sibling = np->sibling; - } - -of_node_set_flag (np,OF_DETACHED ); - -out_unlock: -write_unlock_irqrestore (&devtree_lock, flags); -} -#if defined(CONFIG_DEBUG_FS ) && defined(DEBUG )static struct debugfs_blob_wrapper flat_dt_blob;arch/powerpc/include/asm/prom.h +0
-4@@ -34,10 +34,6 @@ extern struct device_node *of_chosen;#define HAVE_ARCH_DEVTREE_FIXUPS -/* For updating the device tree at runtime */ -extern void of_attach_node (struct device_node *); -extern void of_detach_node (struct device_node *); -#ifdef CONFIG_PPC32 /* * PCI <-> OF matching functions arch/powerpc/kernel/prom.c +0
-59@@ -740,65 +740,6 @@ struct device_node *of_find_next_cache_node(struct device_node *np)return NULL ; } -/* -* Plug a device node into the tree and global list. -*/ -void of_attach_node (struct device_node *np) -{ -unsigned long flags; - -write_lock_irqsave (&devtree_lock, flags); - np->sibling = np->parent->child; - np->allnext = allnodes; - np->parent->child = np; - allnodes = np; -write_unlock_irqrestore (&devtree_lock, flags); -} - -/* -* "Unplug" a node from the device tree. The caller must hold -* a reference to the node. The memory associated with the node -* is not freed until its refcount goes to zero. -*/ -void of_detach_node (struct device_node *np) -{ -struct device_node *parent; -unsigned long flags; - -write_lock_irqsave (&devtree_lock, flags); - - parent = np->parent; -if (!parent) - goto out_unlock; - -if (allnodes == np) - allnodes = np->allnext; -else { -struct device_node *prev; -for (prev = allnodes; - prev->allnext != np; - prev = prev->allnext) - ; - prev->allnext = np->allnext; - } - -if (parent->child == np) - parent->child = np->sibling; -else { -struct device_node *prevsib; -for (prevsib = np->parent->child; - prevsib->sibling != np; - prevsib = prevsib->sibling) - ; - prevsib->sibling = np->sibling; - } - -of_node_set_flag (np,OF_DETACHED ); - -out_unlock: -write_unlock_irqrestore (&devtree_lock, flags); -} -#ifdef CONFIG_PPC_PSERIES /* * Fix up the uninitialized fields in a new device node: drivers/of/base.c +60
-0@@ -60,6 +60,66 @@ int of_n_size_cells(struct device_node *np) }EXPORT_SYMBOL (of_n_size_cells); +/** +* of_attach_node - Plug a device node into the tree and global list. +*/ +void of_attach_node (struct device_node *np) +{ +unsigned long flags; + +write_lock_irqsave (&devtree_lock, flags); + np->sibling = np->parent->child; + np->allnext = allnodes; + np->parent->child = np; + allnodes = np; +write_unlock_irqrestore (&devtree_lock, flags); +} + +/** +* of_detach_node - "Unplug" a node from the device tree. +* +* The caller must hold a reference to the node. The memory associated with +* the node is not freed until its refcount goes to zero. +*/ +void of_detach_node (struct device_node *np) +{ +struct device_node *parent; +unsigned long flags; + +write_lock_irqsave (&devtree_lock, flags); + + parent = np->parent; +if (!parent) + goto out_unlock; + +if (allnodes == np) + allnodes = np->allnext; +else { +struct device_node *prev; +for (prev = allnodes; + prev->allnext != np; + prev = prev->allnext) + ; + prev->allnext = np->allnext; + } + +if (parent->child == np) + parent->child = np->sibling; +else { +struct device_node *prevsib; +for (prevsib = np->parent->child; + prevsib->sibling != np; + prevsib = prevsib->sibling) + ; + prevsib->sibling = np->sibling; + } + +of_node_set_flag (np,OF_DETACHED ); + +out_unlock: +write_unlock_irqrestore (&devtree_lock, flags); +} +#if !defined(CONFIG_SPARC )/* SPARC doesn't do ref counting (yet) */ /** * of_node_get - Increment refcount of a node include/linux/of.h +4
-0@@ -130,6 +130,10 @@ static inline unsigned long of_read_ulong(const u32 *cell, int size)#define OF_BAD_ADDR ((u64)-1) +/* For updating the device tree at runtime */ +extern void of_attach_node (struct device_node *); +extern void of_detach_node (struct device_node *); +extern struct device_node *of_find_node_by_name (struct device_node *from,const char *name);#define for_each_node_by_name (dn, name) \
Re: [PATCH 09/11] of: merge of_attach_node() & of_detach_node()
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 1 line · Grant Likely
Merge common code between PowerPC and Microblaze
Some of those guys might wnat to be in
of_dynamic(see previous email)Remember: We want to keep the footprint low for embedded archs that don't want to do dynamic stuff. Really low.
I agree. If it is okay by you I'll update this in a subsequent patch.
Once the code is merge, then I'm going to do a bunch of refactoring
patches.
g.
Signature · 2 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd.
PATCH 10/11 microblaze: gut implementation of early_init_dt_scan_cpus()
In reply to Grant LikelyMicroblaze only has one CPU, it isn't SMP at all. This function is effectively just a no-op, so remove it.
---
arch/microblaze/kernel/prom.c | 54 ----------------------------------------- 1 files changed, 0 insertions(+), 54 deletions(-)
arch/microblaze/kernel/prom.c +0 -54
@@ -50,60 +50,6 @@ struct device_node *of_chosen;int __init early_init_dt_scan_cpus (unsigned long node,const char *uname,int depth,void *data) { -static int logical_cpuid; -char *type =of_get_flat_dt_prop (node,"device_type" ,NULL ); -const u32 *intserv; -int i, nthreads; -int found =0 ; - -/* We are scanning "cpu" nodes only */ -if (type ==NULL ||strcmp (type,"cpu" ) !=0 ) -return 0 ; - -/* Get physical cpuid */ - intserv =of_get_flat_dt_prop (node,"reg" ,NULL ); - nthreads =1 ; - -/* -* Now see if any of these threads match our boot cpu. -* NOTE: This must match the parsing done in smp_setup_cpu_maps. -*/ -for (i =0 ; i < nthreads; i++) { -/* -* version 2 of the kexec param format adds the phys cpuid of -* booted proc. -*/ -if (initial_boot_params && initial_boot_params->version >=2 ) { -if (intserv[i] == - initial_boot_params->boot_cpuid_phys) { - found =1 ; -break ; - } - }else { -/* -* Check if it's the boot-cpu, set it's hw index now, -* unfortunately this format did not support booting -* off secondary threads. -*/ -if (of_get_flat_dt_prop (node, -"linux,boot-cpu" ,NULL ) !=NULL ) { - found =1 ; -break ; - } - } - -#ifdef CONFIG_SMP -/* logical cpu id is always 0 on UP kernels */ - logical_cpuid++; -#endif - } - -if (found) { -pr_debug ("boot cpu: logical %d physical %d\n" , logical_cpuid, - intserv[i]); - boot_cpuid = logical_cpuid; - } -return 0 ; }
PATCH 11/11 of: unify phandle name in struct device_node
In reply to Grant LikelyIn struct device_node, the phandle is named 'linux_phandle' for PowerPC and MicroBlaze, and 'node' for SPARC. There is no good reason for the difference, it is just an artifact of the code diverging over a couple of years. This patch renames .node to .linux_phandle for SPARC.
Note: the .node also existed in PowerPC/MicroBlaze, but the only user seems to be arch/powerpc/platforms/powermac/pfunc_core.c. It doesn't look like the assignment between .linux_phandle and .node is significantly different enough to warrant the separate code paths unless ibm,phandle properties actually appear in Apple device trees.
I think it is safe to eliminate the old .node property and use linux_phandle everywhere.
---
arch/powerpc/platforms/powermac/pfunc_core.c | 2 +- arch/sparc/kernel/devices.c | 2 +- arch/sparc/kernel/of_device_32.c | 2 +- arch/sparc/kernel/of_device_64.c | 2 +- arch/sparc/kernel/prom_common.c | 8 ++++---- arch/sparc/kernel/smp_64.c | 2 +- drivers/of/fdt.c | 3 +-- drivers/sbus/char/openprom.c | 10 +++++----- drivers/video/aty/atyfb_base.c | 2 +- include/linux/of.h | 3 --- 10 files changed, 16 insertions(+), 20 deletions(-)
arch/powerpc/platforms/powermac/pfunc_core.c +1 -1
@@ -842,7 +842,7 @@ struct pmf_function *__pmf_find_function(struct device_node *target,list_for_each_entry (func, &dev->functions, link) {if (name &&strcmp (name, func->name))continue ; -if (func->phandle && target->node != func->phandle) +if (func->phandle && target->linux_phandle != func->phandle)continue ;if ((func->flags & flags) ==0 )continue ;
arch/sparc/kernel/devices.c +1 -1
@@ -59,7 +59,7 @@ static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg, cur_inst =0 ;for_each_node_by_type (dp,"cpu" ) { -int err =check_cpu_node (dp->node, &cur_inst, +int err =check_cpu_node (dp->linux_phandle, &cur_inst, compare, compare_arg, prom_node, mid);if (!err) {
arch/sparc/kernel/of_device_32.c +1 -1
@@ -433,7 +433,7 @@ build_resources:if (!parent)dev_set_name (&op->dev,"root" );else -dev_set_name (&op->dev,"%08x" , dp->node); +dev_set_name (&op->dev,"%08x" , dp->linux_phandle);if (of_device_register (op)) { printk("%s: Could not register of device.\n",
arch/sparc/kernel/of_device_64.c +1 -1
@@ -666,7 +666,7 @@ static struct of_device * __init scan_one_device(struct device_node *dp,if (!parent)dev_set_name (&op->dev,"root" );else -dev_set_name (&op->dev,"%08x" , dp->node); +dev_set_name (&op->dev,"%08x" , dp->linux_phandle);if (of_device_register (op)) { printk("%s: Could not register of device.\n",
arch/sparc/kernel/prom_common.c +4 -4
@@ -42,7 +42,7 @@ struct device_node *of_find_node_by_phandle(phandle handle)struct device_node *np;for (np = allnodes; np; np = np->allnext) -if (np->node == handle) +if (np->linux_phandle == handle)break ;return np;
@@ -89,7 +89,7 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int lenvoid *old_val = prop->value;int ret; - ret =prom_setprop (dp->node, name, val, len); + ret =prom_setprop (dp->linux_phandle, name, val, len); err = -EINVAL ;if (ret >=0 ) {
@@ -236,7 +236,7 @@ static struct device_node * __init prom_create_node(phandle node, dp->name =get_one_property (node,"name" ); dp->type =get_one_property (node,"device_type" ); - dp->node = node; + dp->linux_phandle = node; dp->properties =build_prop_list (node);
@@ -313,7 +313,7 @@ void __init prom_build_devicetree(void) nextp = &allnodes->allnext; allnodes->child =prom_build_tree (allnodes, -prom_getchild (allnodes->node), +prom_getchild (allnodes->linux_phandle), &nextp);of_console_init ();
arch/sparc/kernel/smp_64.c +1 -1
@@ -370,7 +370,7 @@ static int __cpuinit smp_boot_one_cpu(unsigned int cpu) }else {struct device_node *dp =of_find_node_by_cpuid (cpu); -prom_startcpu (dp->node, entry, cookie); +prom_startcpu (dp->linux_phandle, entry, cookie); }for (timeout =0 ; timeout <50000 ; timeout++) {
drivers/of/fdt.c +1 -2
@@ -315,9 +315,8 @@ unsigned long __init unflatten_dt_node(unsigned long mem, __alignof__(struct property));if (allnextpp) {if (strcmp (pname,"linux,phandle" ) ==0 ) { - np->node = *((u32 *)*p);if (np->linux_phandle ==0 ) - np->linux_phandle = np->node; + np->linux_phandle = *((u32 *)*p); }if (strcmp (pname,"ibm,phandle" ) ==0 ) np->linux_phandle = *((u32 *)*p);
drivers/sbus/char/openprom.c +5 -5
@@ -233,7 +233,7 @@ static int opromnext(void __user *argp, unsigned int cmd, struct device_node *dp ph =0 ;if (dp) - ph = dp->node; + ph = dp->linux_phandle; data->current_node = dp; *((int *) op->oprom_array) = ph;
@@ -256,7 +256,7 @@ static int oprompci2node(void __user *argp, struct device_node *dp, struct openp dp =pci_device_to_OF_node (pdev); data->current_node = dp; - *((int *)op->oprom_array) = dp->node; + *((int *)op->oprom_array) = dp->linux_phandle; op->oprom_size =sizeof (int ); err =copyout (argp, op, bufsize +sizeof (int ));
@@ -273,7 +273,7 @@ static int oprompath2node(void __user *argp, struct device_node *dp, struct open dp =of_find_node_by_path (op->oprom_array);if (dp) - ph = dp->node; + ph = dp->linux_phandle; data->current_node = dp; *((int *)op->oprom_array) = ph; op->oprom_size =sizeof (int );
@@ -540,7 +540,7 @@ static int opiocgetnext(unsigned int cmd, void __user *argp) } }if (dp) - nd = dp->node; + nd = dp->linux_phandle;if (copy_to_user (argp, &nd,sizeof (phandle)))return -EFAULT ;
@@ -570,7 +570,7 @@ static int openprom_bsd_ioctl(struct inode * inode, struct file * file,case OPIOCGETOPTNODE :BUILD_BUG_ON (sizeof (phandle) !=sizeof (int )); -if (copy_to_user (argp, &options_node->node,sizeof (phandle))) +if (copy_to_user (argp, &options_node->linux_phandle,sizeof (phandle)))return -EFAULT ;return 0 ;
drivers/video/aty/atyfb_base.c +1 -1
@@ -3104,7 +3104,7 @@ static int __devinit atyfb_setup_sparc(struct pci_dev *pdev, } dp =pci_device_to_OF_node (pdev); -if (node == dp->node) { +if (node == dp->linux_phandle) {struct fb_var_screeninfo *var = &default_var;unsigned int N ,P ,Q ,M ,T ,R ;u32 v_total, h_total;
include/linux/of.h +0 -3
@@ -39,10 +39,7 @@ struct of_irq_controller;struct device_node {const char *name;const char *type; -phandle node; -#if !defined(CONFIG_SPARC )phandle linux_phandle; -#endif char *full_name;struct property *properties;
David Miller
maintainerRe: [PATCH 11/11] of: unify phandle name in struct device_node
From: Grant Likely <[email protected]>
Date: Tue, 24 Nov 2009 01:20:05 -0700
Quoted 4 lines
In struct
device_node, the phandle is named 'linux_phandle' for PowerPC and MicroBlaze, and 'node' for SPARC. There is no good reason for the difference, it is just an artifact of the code diverging over a couple of years. This patch renames .node to .linux_phandle for SPARC.
I know it's just a name, but there is no reason to put "linux" in the member name. It's the real device phandle value from OpenFirmware not something invented by Linux's OF layer.
PowerPC uses this for something different, it records the information here using the special "linux,phandle" and "ibm,phandle" properties.
See unflatten_dt_node() in arch/powerpc/kernel/prom.c before your changes.
Re: [PATCH 11/11] of: unify phandle name in struct device_node
Quoted 11 lines · David Miller
From: Grant Likely <[email protected]>
Date: Tue, 24 Nov 2009 01:20:05 -0700Quoted 4 lines
In struct
device_node, the phandle is named 'linux_phandle' for PowerPC and MicroBlaze, and 'node' for SPARC. There is no good reason for the difference, it is just an artifact of the code diverging over a couple of years. This patch renames .node to .linux_phandle for SPARC.I know it's just a name, but there is no reason to put "linux" in the member name. It's the real device phandle value from OpenFirmware not something invented by Linux's OF layer.
I agree, and I also considered renaming it to simply 'phandle' or to change the powerpc code back to using .node everywhere (more on .node usage in powerpc below). I didn't want to use .node because .node is pretty generic, and is used in other places for different things. Basically I wanted to avoid confusion. In particular, .node points to a device_node, not a phandle, in struct of_device. Changing all references to simply 'phandle' seems to be the best, but it does require changes to more locations in the code. In the end I decided on some constructive lazyness by settling for the already-used .linux_phandle so that I would need to touch as many files, but still retain a unique name that is easy to find. If you prefer, I can change it all to simply '.phandle'.
Quoted 2 lines
PowerPC uses this for something different, it records the information here using the special "linux,phandle" and "ibm,phandle" properties.
Agreed, the phandle isn't a real phandle when using the flat tree. However, though the source of the phandle value is different, the use case is identical, so it make sense to stuff it into the same member. Merging them lets me unify more code. For example, of_find_node_by_phandle().
Quoted 2 lines
See
unflatten_dt_node()inarch/powerpc/kernel/prom.cbefore your changes.
Yup, I looked at this. The unflatten code stuffs both linux,phandle and ibm,phandle into .linux_phandle, and linux,phandle also gets stuffed into .node. But all the users except one use the .linux_phandle, not .node, and that remaining user *I think* can safely use .linux_phandle too.
Thanks for the review,
g.
Signature · 6 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
David Miller
maintainerRe: [PATCH 11/11] of: unify phandle name in struct device_node
From: Grant Likely <[email protected]>
Date: Tue, 24 Nov 2009 13:33:22 -0700
Quoted 1 line
If you prefer, I can change it all to simply '.phandle'.
Please do.
A message that is not in the archive (sent off-list or not yet received): 20091124.093732.203692950.davem-fT/PcQaiUtIeIZ0/[email protected]
Re: [PATCH 11/11] of: unify phandle name in struct device_node
Quoted 12 lines · David Miller
From: Grant Likely <grant.likely-s3s/[email protected]>
Date: Tue, 24 Nov 2009 01:20:05 -0700Quoted 4 lines
In struct
device_node, the phandle is named 'linux_phandle' for PowerPC and MicroBlaze, and 'node' for SPARC. There is no good reason for the difference, it is just an artifact of the code diverging over a couple of years. This patch renames .node to .linux_phandle for SPARC.I know it's just a name, but there is no reason to put "linux" in the member name. It's the real device phandle value from OpenFirmware not something invented by Linux's OF layer.
Quoted 5 lines
PowerPC uses this for something different, it records the information here using the special "linux,phandle" and "ibm,phandle" properties.
See
unflatten_dt_node()inarch/powerpc/kernel/prom.cbefore your changes.
Right, this comes from a subtle problem with our firmwares on pSeries.
We have a phandle from OF. But some devices, especially virtual devices, also have an "ibm,phandle" which may or may not be the same afaik.
In addition, when the hypervisor hotplugs some devices, it sends us some new device-tree bits to add. Those don't have a phandle in the formal sense afaik, but -do- have an ibm,phandle property.
I think we can always just use ibm,phandle instead of the OF one when the former is present, they should be non overlapping, but of course, any chance in that area will require plenty of testing on some of those machines.
Cheers,
Ben.
Re: [PATCH 11/11] of: unify phandle name in struct device_node
Quoted 24 lines · Benjamin Herrenschmidt
Quoted 12 lines · David Miller
From: Grant Likely <[email protected]>
Date: Tue, 24 Nov 2009 01:20:05 -0700Quoted 4 lines
In struct
device_node, the phandle is named 'linux_phandle' for PowerPC and MicroBlaze, and 'node' for SPARC. There is no good reason for the difference, it is just an artifact of the code diverging over a couple of years. This patch renames .node to .linux_phandle for SPARC.I know it's just a name, but there is no reason to put "linux" in the member name. It's the real device phandle value from OpenFirmware not something invented by Linux's OF layer.
Quoted 5 lines
PowerPC uses this for something different, it records the information here using the special "linux,phandle" and "ibm,phandle" properties.
See
unflatten_dt_node()inarch/powerpc/kernel/prom.cbefore your changes.Right, this comes from a subtle problem with our firmwares on pSeries.
We have a phandle from OF. But some devices, especially virtual devices, also have an "ibm,phandle" which may or may not be the same afaik.
Quoted 8 lines
In addition, when the hypervisor hotplugs some devices, it sends us some new device-tree bits to add. Those don't have a phandle in the formal sense afaik, but -do- have an ibm,phandle property.
I think we can always just use ibm,phandle instead of the OF one when the former is present, they should be non overlapping, but of course, any chance in that area will require plenty of testing on some of those machines.
If pseries is the troublesome platform, not powermac, then I'm pretty confident this change is okay. I cannot find any other users of .node other than arch/powerpc/platforms/powermac/pfunc_core.c, but I'll double check with an allmodconfig and an allyesconfig. This patch shouldn't change the behaviour of linux_phandle at all.
g.
Signature · 6 lines
Grant Likely, B.Sc., P.Eng. Secret Lab Technologies Ltd. -- To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 4 lines · Grant Likely
Nothing much to say here other than mostly mechanical merging of OF support code. Some of it remains a little ugly, but I'm taking the approach of merging the code first, and refactoring it second.
Quoted 8 lines
I've pushed this series out to my test-devicetree branch on my git server if anyone wants to test. That branch also includes the previous 2 patch series that I've sent out.
git://git.secretlab.ca/git/linux-2.6test-devicetreeCompile tested on: ppc64, ppc32, microblaze, sparc64, sparc32. Boot tested on mpc5200 (ppc32) platform.
test-devicetree as of today also works fine on my phyCORE-MPC5200B-IO.
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |