Early flattened DT init consolidation
Subsystems (10)
cover Early flattened DT init consolidation
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
This is the first of 2 series to do some consolidation of per architecture Device Tree code. We now have 12 architectures with DT support. As new architectures have been added, much of the DT related code for the early flattened DT scanning has been duplicated. Yet little of this code is architecture specific. This series has 4 main parts:
- Create a common function to copy built-in dtb's out of init section
- Create a single, common function to scan the FDT
- Removal of early_init_dt_setup_initrd_arch
- Create common functions for machine matching with DT
The entire series is available here:git://sources.calxeda.com/kernel/linux.git dt-cleanup
Compiled on arm, arm64, microblaze, mips, openrisc, powerpc, sparc, xtensa.
Rob
Rob Herring (28):
c6x: use boot_command_line instead of private c6x_command_line
openrisc: use boot_command_line instead of private cmd_line
of: create unflatten_and_copy_device_tree
arc: use unflatten_and_copy_device_tree
openrisc: use unflatten_and_copy_device_tree
x86: use unflatten_and_copy_device_tree
xtensa: use unflatten_and_copy_device_tree
metag: use unflatten_and_copy_device_tree
of: Introduce common early_init_dt_scan
arc: use early_init_dt_scan
arm: use early_init_dt_scan
arm64: use early_init_dt_scan
c6x: use early_init_dt_scan
microblaze: use early_init_dt_scan
mips: use early_init_dt_scan
openrisc: use early_init_dt_scan
xtensa: use early_init_dt_scan
of: create default early_init_dt_add_memory_arch
arm: set initrd_start/initrd_end for fdt scan
arm64: set initrd_start/initrd_end for fdt scan
of: remove early_init_dt_setup_initrd_arch
openrisc: remove unnecessary prom.c includes
of: introduce common FDT machine related functions
arc: use common of_flat_dt_match_machine
arm: use common of_flat_dt_match_machine
arm64: use common of_flat_dt_get_machine_name
metag: use common of_flat_dt_match_machine
mips: use common of_flat_dt_get_machine_name
arch/arc/include/asm/mach_desc.h | 1 - arch/arc/kernel/devtree.c | 94 +++++++-------------------------- arch/arc/kernel/setup.c | 3 +- arch/arc/mm/init.c | 7 --- arch/arm/kernel/devtree.c | 57 ++++++++------------ arch/arm/mm/init.c | 13 ++--- arch/arm64/kernel/setup.c | 60 ++------------------- arch/arm64/mm/init.c | 24 +++------ arch/c6x/include/asm/setup.h | 2 - arch/c6x/kernel/devicetree.c | 29 ---------- arch/c6x/kernel/setup.c | 13 +---- arch/metag/kernel/devtree.c | 87 ++++++------------------------ arch/metag/kernel/setup.c | 4 +- arch/metag/mm/init.c | 9 ---- arch/microblaze/kernel/prom.c | 31 ++--------- arch/microblaze/kernel/setup.c | 2 +- arch/mips/include/asm/prom.h | 3 -- arch/mips/kernel/prom.c | 60 +-------------------- arch/openrisc/kernel/prom.c | 70 +----------------------- arch/openrisc/kernel/setup.c | 6 +-- arch/powerpc/kernel/prom.c | 9 ---- arch/x86/kernel/devicetree.c | 42 +++------------ arch/xtensa/kernel/setup.c | 55 +++++-------------- drivers/of/fdt.c | 111 +++++++++++++++++++++++++++++++++++++-- include/linux/of_fdt.h | 18 +++---- 25 files changed, 223 insertions(+), 587 deletions(-)
Signature · 6 lines
1.8.1.2 -- 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
PATCH 1/28 c6x: use boot_command_line instead of private c6x_command_line
From: Rob Herring <[email protected]>
Save some pointless copying of the kernel command line and just use boot_command_line instead.
Also remove default_command_line as it is not referenced anywhere, and the DT code already handles the default command line.
--- arch/c6x/include/asm/setup.h | 2 -- arch/c6x/kernel/devicetree.c | 2 +- arch/c6x/kernel/setup.c | 11 +---------- 3 files changed, 2 insertions(+), 13 deletions(-)
arch/c6x/include/asm/setup.h +0 -2
@@ -14,8 +14,6 @@#include <uapi/asm/setup.h> #ifndef __ASSEMBLY__ -extern char c6x_command_line[COMMAND_LINE_SIZE ]; -extern int c6x_add_memory (phys_addr_t start,unsigned long size);extern unsigned long ram_start;
arch/c6x/kernel/devicetree.c +1 -1
@@ -24,7 +24,7 @@ void __init early_init_devtree(void *params)* device-tree, including the platform type, initrd location and * size and more ... */ -of_scan_flat_dt (early_init_dt_scan_chosen, c6x_command_line); +of_scan_flat_dt (early_init_dt_scan_chosen, boot_command_line);/* Scan memory nodes and rebuild MEMBLOCKs */ of_scan_flat_dt (early_init_dt_scan_root,NULL );
arch/c6x/kernel/setup.c +1 -10
@@ -68,13 +68,6 @@ unsigned long ram_end;static unsigned long dma_start__initdata ;static unsigned long dma_size__initdata ; -char c6x_command_line[COMMAND_LINE_SIZE ]; - -#if defined(CONFIG_CMDLINE_BOOL ) -static const char default_command_line[COMMAND_LINE_SIZE] __section(.cmdline) = -CONFIG_CMDLINE ; -#endif -struct cpuinfo_c6x {const char *cpu_name;const char *cpu_voltage;
@@ -296,8 +289,6 @@ notrace void __init machine_init(unsigned long dt_ptr)/* Do some early initialization based on the flat device tree */ early_init_devtree (fdt); -/* parse_early_param needs a boot_command_line */ -strlcpy (boot_command_line, c6x_command_line,COMMAND_LINE_SIZE );parse_early_param (); }
@@ -309,7 +300,7 @@ void __init setup_arch(char **cmdline_p)printk (KERN_INFO "Initializing kernel\n" );/* Initialize command line */ - *cmdline_p = c6x_command_line; + *cmdline_p = boot_command_line; memory_end = ram_end; memory_end &= ~(PAGE_SIZE -1 );
Signature · 1 line
1.8.1.2
Re: [PATCH 01/28] c6x: use boot_command_line instead of private c6x_command_line
Quoted 5 lines · Rob Herring
From: Rob Herring <[email protected]>
Save some pointless copying of the kernel command line and just use
boot_command_lineinstead.
Quoted 7 lines
Also remove
default_command_lineas it is not referenced anywhere, and the DT code already handles the default command line.Signed-off-by Rob Herring <[email protected]>Cc Mark Salter <[email protected]>Cc Aurelien Jacquiot <[email protected]>
This and the next patch look good to me.
Quoted 71 lines
--- arch/c6x/include/asm/setup.h | 2 -- arch/c6x/kernel/devicetree.c | 2 +- arch/c6x/kernel/setup.c | 11 +---------- 3 files changed, 2 insertions(+), 13 deletions(-)arch/c6x/include/asm/setup.h +0
-2@@ -14,8 +14,6 @@#include <uapi/asm/setup.h> #ifndef __ASSEMBLY__ -extern char c6x_command_line[COMMAND_LINE_SIZE ]; -extern int c6x_add_memory (phys_addr_t start,unsigned long size);extern unsigned long ram_start;arch/c6x/kernel/devicetree.c +1
-1@@ -24,7 +24,7 @@ void __init early_init_devtree(void *params)* device-tree, including the platform type, initrd location and * size and more ... */ -of_scan_flat_dt (early_init_dt_scan_chosen, c6x_command_line); +of_scan_flat_dt (early_init_dt_scan_chosen, boot_command_line);/* Scan memory nodes and rebuild MEMBLOCKs */ of_scan_flat_dt (early_init_dt_scan_root,NULL );arch/c6x/kernel/setup.c +1
-10@@ -68,13 +68,6 @@ unsigned long ram_end;static unsigned long dma_start__initdata ;static unsigned long dma_size__initdata ; -char c6x_command_line[COMMAND_LINE_SIZE ]; - -#if defined(CONFIG_CMDLINE_BOOL ) -static const char default_command_line[COMMAND_LINE_SIZE] __section(.cmdline) = -CONFIG_CMDLINE ; -#endif -struct cpuinfo_c6x {const char *cpu_name;const char *cpu_voltage;@@ -296,8 +289,6 @@ notrace void __init machine_init(unsigned long dt_ptr)/* Do some early initialization based on the flat device tree */ early_init_devtree (fdt); -/* parse_early_param needs a boot_command_line */ -strlcpy (boot_command_line, c6x_command_line,COMMAND_LINE_SIZE );parse_early_param (); }@@ -309,7 +300,7 @@ void __init setup_arch(char **cmdline_p)printk (KERN_INFO "Initializing kernel\n" );/* Initialize command line */ - *cmdline_p = c6x_command_line; + *cmdline_p = boot_command_line; memory_end = ram_end; memory_end &= ~(PAGE_SIZE -1 );Signature · 1 line
1.8.1.2
Re: [PATCH 01/28] c6x: use boot_command_line instead of private c6x_command_line
In reply to Rob HerringQuoted 8 lines · Rob Herring
From: Rob Herring <[email protected]>
Save some pointless copying of the kernel command line and just use
boot_command_lineinstead.Also remove
default_command_lineas it is not referenced anywhere, and the DT code already handles the default command line.
The default_command_line is leftover cruft from the kernel before it was upstreamed. It was a mechanism to place the commandline at a known fixed offset in the Image. It was needed for simple (serial eeprom based) loaders which didn't know about DT. Anyway, bits of that support are missing, so I don't see a reason to keep it around. If anyone complains we can add it back in as a completely functional patch. There is also a fragment of arch/c6x/kernel/vmlinux.lds.S which should also be removed:
arch/c6x/kernel/vmlinux.lds.S +0 -6
@@ -37,12 +37,6 @@ SECTIONS _vectors_end = .; } - . = ALIGN(0x1000); - .cmdline : - { - *(.cmdline) - } - /* * This section contains data which may be shared with other * cores. It needs to be a fixed offset from PAGE_OFFSET
PATCH 2/28 openrisc: use boot_command_line instead of private cmd_line
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Save some pointless copying of the kernel command line and just use boot_command_line instead. The DT code already handles CONFIG_CMDLINE, so a separate copy is not needed.
--- arch/openrisc/kernel/prom.c | 7 +------ arch/openrisc/kernel/setup.c | 4 +--- 2 files changed, 2 insertions(+), 9 deletions(-)
arch/openrisc/kernel/prom.c +1 -6
@@ -47,8 +47,6 @@#include <asm/sections.h> #include <asm/setup.h> -extern char cmd_line[COMMAND_LINE_SIZE ]; -void __init early_init_dt_add_memory_arch (u64 base,u64 size) { size &=PAGE_MASK ;
@@ -67,15 +65,12 @@ void __init early_init_devtree(void *params)* device-tree, including the platform type, initrd location and * size, TCE reserve, and more ... */ -of_scan_flat_dt (early_init_dt_scan_chosen, cmd_line); +of_scan_flat_dt (early_init_dt_scan_chosen, boot_command_line);/* Scan memory nodes and rebuild MEMBLOCKs */ 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 ); -memblock_allow_resize ();/* We must copy the flattend device tree from init memory to regular
arch/openrisc/kernel/setup.c +1 -3
@@ -50,8 +50,6 @@#include "vmlinux.h" -char __initdata cmd_line[COMMAND_LINE_SIZE ] =CONFIG_CMDLINE ; -static unsigned long __init setup_memory (void ) {unsigned long bootmap_size;
@@ -316,7 +314,7 @@ void __init setup_arch(char **cmdline_p) conswitchp = &dummy_con;#endif - *cmdline_p = cmd_line; + *cmdline_p = boot_command_line;printk (KERN_INFO "OpenRISC Linux -- http://openrisc.net\n" ); }
Signature · 1 line
1.8.1.2
PATCH 3/28 of: create unflatten_and_copy_device_tree
In reply to Rob HerringFrom: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Several architectures using DT support built-in dtb's in the init section. These platforms need to copy the dtb from init since the strings are referenced after unflattening. Every arch has their own copying routine which do the same thing. Create a common function, unflatten_and_copy_device_tree, to copy the dtb when unflattening the dtb.
--- drivers/of/fdt.c | 13 +++++++++++++ include/linux/of_fdt.h | 2 ++ 2 files changed, 15 insertions(+)
drivers/of/fdt.c +13 -0
@@ -802,6 +802,19 @@ void __init unflatten_device_tree(void) of_alias_scan(early_init_dt_alloc_memory_arch); } +void __init unflatten_and_copy_device_tree (void ) +{ +int size =__be32_to_cpu (initial_boot_params->totalsize); +void *dt =early_init_dt_alloc_memory_arch (size, + __alignof__(struct boot_param_header )); + +if (dt) { +memcpy (dt, initial_boot_params, size); + initial_boot_params = dt; + } +unflatten_device_tree (); +} +#endif /* CONFIG_OF_EARLY_FLATTREE */ /* Feed entire flattened device tree into the random pool */
include/linux/of_fdt.h +2 -0
@@ -118,9 +118,11 @@ extern int early_init_dt_scan_root(unsigned long node, const char *uname,/* Other Prototypes */ extern void unflatten_device_tree (void ); +extern void unflatten_and_copy_device_tree (void );extern void early_init_devtree (void *);#else /* CONFIG_OF_FLATTREE */ static inline void unflatten_device_tree (void ) {} +static inline void unflatten_and_copy_device_tree (void ) {}#endif /* CONFIG_OF_FLATTREE */ #endif /* __ASSEMBLY__ */
Signature · 6 lines
1.8.1.2 -- 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
Re: [PATCH 03/28] of: create unflatten_and_copy_device_tree
Quoted 21 lines · Rob Herring
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Several architectures using DT support built-in dtb's in the init section. These platforms need to copy the dtb from init since the strings are referenced after unflattening. Every arch has their own copying routine which do the same thing. Create a common function,
unflatten_and_copy_device_tree, to copy the dtb when unflattening the dtb.Signed-off-by Rob Herring <rob.herring-bsGFqQB8/[email protected]>Cc Grant Likely <[email protected]>--- drivers/of/fdt.c | 13 +++++++++++++ include/linux/of_fdt.h | 2 ++ 2 files changed, 15 insertions(+)drivers/of/fdt.c +0
-0
drivers/of/fdt.c void __init unflatten_device_tree(void) · line 806
Quoted 5 lines
drivers/of/fdt.c +2
-0@@ -802,6 +802,19 @@ void __init unflatten_device_tree(void)of_alias_scan (early_init_dt_alloc_memory_arch); } +void __init unflatten_and_copy_device_tree (void ) +{
Can we add a comment here why exactly is the copy needed (unflattening doesn't copy strings which are referenced to by the DT APIs). Will help first time readers.
Quoted 13 lines
drivers/of/fdt.c +11
-0+int size =__be32_to_cpu (initial_boot_params->totalsize); +void *dt =early_init_dt_alloc_memory_arch (size, + __alignof__(struct boot_param_header )); + +if (dt) { +memcpy (dt, initial_boot_params, size); + initial_boot_params = dt; + } + unflatten_device_tree(); +} +#endif /* CONFIG_OF_EARLY_FLATTREE */
Re: [PATCH 03/28] of: create unflatten_and_copy_device_tree
In reply to Rob HerringQuoted 8 lines · Rob Herring
From: Rob Herring <[email protected]>
Several architectures using DT support built-in dtb's in the init section. These platforms need to copy the dtb from init since the strings are referenced after unflattening. Every arch has their own copying routine which do the same thing. Create a common function,
unflatten_and_copy_device_tree, to copy the dtb when unflattening the dtb.
This set of changes looks fine by me, but it does raise a question:
For the platforms using memblock; would it work to use memblock_reserve on the region containing the device tree? That would avoid an unnecessary copy of the data. Can anyone tell me if it is legal to do a memblock_reserve on an __init section?
Also, I think the patch needs to add documentation for the function that states when it is appropriate to use the function, and that it shouldn't be used when DT memory has been reserved.
Quoted 51 lines
Signed-off-by Rob Herring <[email protected]>Cc Grant Likely <[email protected]>--- drivers/of/fdt.c | 13 +++++++++++++ include/linux/of_fdt.h | 2 ++ 2 files changed, 15 insertions(+)drivers/of/fdt.c +13
-0@@ -802,6 +802,19 @@ void __init unflatten_device_tree(void) of_alias_scan(early_init_dt_alloc_memory_arch); } +void __init unflatten_and_copy_device_tree (void ) +{ +int size =__be32_to_cpu (initial_boot_params->totalsize); +void *dt =early_init_dt_alloc_memory_arch (size, + __alignof__(struct boot_param_header )); + +if (dt) { +memcpy (dt, initial_boot_params, size); + initial_boot_params = dt; + } +unflatten_device_tree (); +} +#endif /* CONFIG_OF_EARLY_FLATTREE */ /* Feed entire flattened device tree into the random pool */ include/linux/of_fdt.h +2
-0@@ -118,9 +118,11 @@ extern int early_init_dt_scan_root(unsigned long node, const char *uname,/* Other Prototypes */ extern void unflatten_device_tree (void ); +extern void unflatten_and_copy_device_tree (void );extern void early_init_devtree (void *);#else /* CONFIG_OF_FLATTREE */ static inline void unflatten_device_tree (void ) {} +static inline void unflatten_and_copy_device_tree (void ) {}#endif /* CONFIG_OF_FLATTREE */ #endif /* __ASSEMBLY__ */ Signature · 1 line
1.8.1.2
PATCH 4/28 arc: use unflatten_and_copy_device_tree
In reply to Rob HerringFrom: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Use the common unflatten_and_copy_device_tree to copy the built-in FDT out of init section.
--- arch/arc/include/asm/mach_desc.h | 1 - arch/arc/kernel/devtree.c | 15 --------------- arch/arc/kernel/setup.c | 3 +-- 3 files changed, 1 insertion(+), 18 deletions(-)
arch/arc/include/asm/mach_desc.h +0 -1
@@ -82,6 +82,5 @@ __attribute__((__section__(".arch.info.init"))) = { \ };extern struct machine_desc *setup_machine_fdt (void *dt); -extern void __init copy_devtree (void );#endif
arch/arc/kernel/devtree.c +0 -15
@@ -100,18 +100,3 @@ struct machine_desc * __init setup_machine_fdt(void *dt)return mdesc_best; } - -/* -* Copy the flattened DT out of .init since unflattening doesn't copy strings -* and the normal DT APIs refs them from orig flat DT -*/ -void __init copy_devtree (void ) -{ -void *alloc =early_init_dt_alloc_memory_arch ( -be32_to_cpu (initial_boot_params->totalsize),64 ); -if (alloc) { -memcpy (alloc, initial_boot_params, -be32_to_cpu (initial_boot_params->totalsize)); - initial_boot_params = alloc; - } -}
arch/arc/kernel/setup.c +1 -2
@@ -346,8 +346,7 @@ void __init setup_arch(char **cmdline_p)setup_arch_memory ();/* copy flat DT out of .init and then unflatten it */ -copy_devtree (); -unflatten_device_tree (); +unflatten_and_copy_device_tree ();/* Can be issue if someone passes cmd line arg "ro" * But that is unlikely so keeping it as it is
Signature · 6 lines
1.8.1.2 -- 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
Re: [PATCH 04/28] arc: use unflatten_and_copy_device_tree
Quoted 7 lines · Rob Herring
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Use the common
unflatten_and_copy_device_treeto copy the built-in FDT out of init section.Signed-off-by Rob Herring <rob.herring-bsGFqQB8/[email protected]>Cc Vineet Gupta <vgupta-HKixBCOQz3hWk0Htik3J/[email protected]>
I tested the series - works great !
Acked by: Vineet Gupta <vgupta-HKixBCOQz3hWk0Htik3J/[email protected]>
Thx,
-Vineet
--
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
PATCH 5/28 openrisc: use unflatten_and_copy_device_tree
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Use the common unflatten_and_copy_device_tree to copy the built-in FDT out of init section. This moves the copy later in the boot, but there do not appear to be any references to strings in the FDT before the copy.
--- arch/openrisc/kernel/prom.c | 13 ------------- arch/openrisc/kernel/setup.c | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-)
arch/openrisc/kernel/prom.c +0 -13
@@ -55,8 +55,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)void __init early_init_devtree (void *params) { -void *alloc; -/* Setup flat device-tree pointer */ initial_boot_params = params;
@@ -72,17 +70,6 @@ void __init early_init_devtree(void *params)of_scan_flat_dt (early_init_dt_scan_memory,NULL );memblock_allow_resize (); - -/* We must copy the flattend device tree from init memory to regular -* memory because the device tree references the strings in it -* directly. -*/ - - alloc =__va (memblock_alloc (initial_boot_params->totalsize,PAGE_SIZE )); - -memcpy (alloc, initial_boot_params, initial_boot_params->totalsize); - - initial_boot_params = alloc; }#ifdef CONFIG_BLK_DEV_INITRD
arch/openrisc/kernel/setup.c +1 -1
@@ -283,7 +283,7 @@ void __init setup_arch(char **cmdline_p) {unsigned long max_low_pfn; -unflatten_device_tree (); +unflatten_and_copy_device_tree ();setup_cpuinfo ();
Signature · 1 line
1.8.1.2
PATCH 6/28 x86: use unflatten_and_copy_device_tree
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Use the common unflatten_and_copy_device_tree to copy the built-in FDT out of init section.
--- arch/x86/kernel/devicetree.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-)
arch/x86/kernel/devicetree.c +8 -15
@@ -230,7 +230,7 @@ static void __init dtb_apic_setup(void)static void __init x86_flattree_get_config (void ) {u32 size, map_len; -void *new_dtb; +struct boot_param_header *dt;if (!initial_dtb)return ;
@@ -238,24 +238,17 @@ static void __init x86_flattree_get_config(void) map_len =max (PAGE_SIZE - (initial_dtb & ~PAGE_MASK ), (u64 )sizeof (struct boot_param_header )); - initial_boot_params =early_memremap (initial_dtb, map_len); - size =be32_to_cpu (initial_boot_params->totalsize); + dt =early_memremap (initial_dtb, map_len); + size =be32_to_cpu (dt->totalsize);if (map_len < size) { -early_iounmap (initial_boot_params, map_len); - initial_boot_params =early_memremap (initial_dtb, size); +early_iounmap (dt, map_len); + dt =early_memremap (initial_dtb, size); map_len = size; } - new_dtb =alloc_bootmem (size); -memcpy (new_dtb, initial_boot_params, size); -early_iounmap (initial_boot_params, map_len); - - initial_boot_params = new_dtb; - -/* root level address cells */ -of_scan_flat_dt (early_init_dt_scan_root,NULL ); - - unflatten_device_tree(); + initial_boot_params = dt; +unflatten_and_copy_device_tree (); + early_iounmap(dt, map_len); }#else static inline void x86_flattree_get_config (void ) { }
Signature · 1 line
1.8.1.2
PATCH 7/28 xtensa: use unflatten_and_copy_device_tree
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Use the common unflatten_and_copy_device_tree to copy the built-in FDT out of init section.
--- arch/xtensa/kernel/setup.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
arch/xtensa/kernel/setup.c +1 -18
@@ -21,11 +21,8 @@#include <linux/screen_info.h> #include <linux/bootmem.h> #include <linux/kernel.h> - -#ifdef CONFIG_OF #include <linux/of_fdt.h> #include <linux/of_platform.h> -#endif #if defined(CONFIG_VGA_CONSOLE ) || defined(CONFIG_DUMMY_CONSOLE )# include <linux/console.h>
@@ -252,17 +249,6 @@ void __init early_init_devtree(void *params)of_scan_flat_dt (early_init_dt_scan_memory,NULL ); } -static void __init copy_devtree (void ) -{ -void *alloc =early_init_dt_alloc_memory_arch ( -be32_to_cpu (initial_boot_params->totalsize),8 ); -if (alloc) { -memcpy (alloc, initial_boot_params, -be32_to_cpu (initial_boot_params->totalsize)); - initial_boot_params = alloc; - } -} -static int __init xtensa_device_probe (void ) {of_platform_populate (NULL ,NULL ,NULL ,NULL );
@@ -525,10 +511,7 @@ void __init setup_arch(char **cmdline_p)bootmem_init (); -#ifdef CONFIG_OF -copy_devtree (); -unflatten_device_tree (); -#endif +unflatten_and_copy_device_tree ();platform_setup (cmdline_p);
Signature · 1 line
1.8.1.2
Re: [PATCH 07/28] xtensa: use unflatten_and_copy_device_tree
Quoted 5 lines · Rob Herring
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Use the common
unflatten_and_copy_device_treeto copy the built-in FDT out of init section.
Quoted 7 lines
Signed-off-by Rob Herring <rob.herring-bsGFqQB8/[email protected]>Cc Chris Zankel <[email protected]>Cc Max Filippov <[email protected]>Cc linux-xtensa-PjhNF2WwrV/[email protected]--- arch/xtensa/kernel/setup.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
Signature · 6 lines
Thanks. -- Max -- 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
PATCH 8/28 metag: use unflatten_and_copy_device_tree
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Use the common unflatten_and_copy_device_tree to copy the built-in FDT out of init section.
--- arch/metag/kernel/devtree.c | 16 ---------------- arch/metag/kernel/setup.c | 4 +--- 2 files changed, 1 insertion(+), 19 deletions(-)
arch/metag/kernel/devtree.c +0 -16
@@ -94,21 +94,5 @@ struct machine_desc * __init setup_machine_fdt(void *dt)of_scan_flat_dt (early_init_dt_scan_chosen, boot_command_line);return mdesc_best; -} -/** -* copy_fdt - Copy device tree into non-init memory. -* -* We must copy the flattened device tree blob into non-init memory because the -* unflattened device tree will reference the strings in it directly. -*/ -void __init copy_fdt (void ) -{ -void *alloc =early_init_dt_alloc_memory_arch ( -be32_to_cpu (initial_boot_params->totalsize),0x40 ); -if (alloc) { -memcpy (alloc, initial_boot_params, -be32_to_cpu (initial_boot_params->totalsize)); - initial_boot_params = alloc; - } }
arch/metag/kernel/setup.c +1 -3
@@ -408,9 +408,7 @@ void __init setup_arch(char **cmdline_p) cpu_2_hwthread_id[smp_processor_id ()] =hard_processor_id (); hwthread_id_2_cpu[hard_processor_id ()] =smp_processor_id (); -/* Copy device tree blob into non-init memory before unflattening */ -copy_fdt (); -unflatten_device_tree (); +unflatten_and_copy_device_tree ();#ifdef CONFIG_SMP smp_init_cpus ();
Signature · 1 line
1.8.1.2
PATCH 9/28 of: Introduce common early_init_dt_scan
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Most architectures scan the all the same items early in the FDT and none are really architecture specific. Create a common early_init_dt_scan to unify the early scan of root, memory, and chosen nodes in the flattened DT.
--- drivers/of/fdt.c | 18 ++++++++++++++++++ include/linux/of_fdt.h | 2 ++ 2 files changed, 20 insertions(+)
drivers/of/fdt.c +18 -0
@@ -785,6 +785,24 @@ void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) }#endif +bool __init early_init_dt_scan (void *params) +{ +/* Setup flat device-tree pointer */ + initial_boot_params = params; + +/* check device tree validity */ +if (be32_to_cpu (initial_boot_params->magic) !=OF_DT_HEADER ) +return false; + +/* Retrieve various information from the /chosen node */ +of_scan_flat_dt (early_init_dt_scan_chosen, boot_command_line); +/* Initialize {size,address}-cells info */ +of_scan_flat_dt (early_init_dt_scan_root,NULL ); +/* Setup memory, calling early_init_dt_add_memory_arch */ +of_scan_flat_dt (early_init_dt_scan_memory,NULL ); +return true; +} +/** * unflatten_device_tree - create tree of device_nodes from flat blob *
include/linux/of_fdt.h +2 -0
@@ -116,6 +116,8 @@ extern void early_init_dt_setup_initrd_arch(u64 start, u64 end);extern int early_init_dt_scan_root (unsigned long node,const char *uname,int depth,void *data); +extern bool early_init_dt_scan (void *params); +/* Other Prototypes */ extern void unflatten_device_tree (void );extern void unflatten_and_copy_device_tree (void );
Signature · 1 line
1.8.1.2
Re: [PATCH 09/28] of: Introduce common early_init_dt_scan
Quoted 29 lines · Rob Herring
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Most architectures scan the all the same items early in the FDT and none are really architecture specific. Create a common
early_init_dt_scanto unify the early scan of root, memory, and chosen nodes in the flattened DT.Signed-off-by Rob Herring <rob.herring-bsGFqQB8/[email protected]>Cc Grant Likely <[email protected]>--- drivers/of/fdt.c | 18 ++++++++++++++++++ include/linux/of_fdt.h | 2 ++ 2 files changed, 20 insertions(+)drivers/of/fdt.c +7
-0@@ -785,6 +785,24 @@ void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) }#endif +bool __init early_init_dt_scan (void *params) +{ +/* Setup flat device-tree pointer */ + initial_boot_params = params; + +/* check device tree validity */ +if (be32_to_cpu (initial_boot_params->magic) !=OF_DT_HEADER )
drivers/of/fdt.c void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) · line 804
Quoted 10 lines
drivers/of/fdt.c +10
-0+return false; + +/* Retrieve various information from the /chosen node */ +of_scan_flat_dt (early_init_dt_scan_chosen, boot_command_line); +/* Initialize {size,address}-cells info */ +of_scan_flat_dt (early_init_dt_scan_root,NULL ); +/* Setup memory, calling early_init_dt_add_memory_arch */ +of_scan_flat_dt (early_init_dt_scan_memory,NULL ); +return true; +}
You probably need empty lines here.
-Vineet
Quoted 10 lines
drivers/of/fdt.c +1
-0+/** * unflatten_device_tree - create tree of device_nodes from flat blob * include/linux/of_fdt.h +0
-0
include/linux/of_fdt.h extern void early_init_dt_setup_initrd_arch(u64 start, u64 end); · line 123
Quoted 8 lines
include/linux/of_fdt.h +2
-0@@ -116,6 +116,8 @@ extern void early_init_dt_setup_initrd_arch(u64 start, u64 end);extern int early_init_dt_scan_root (unsigned long node,const char *uname,int depth,void *data); +extern bool early_init_dt_scan (void *params); +/* Other Prototypes */ extern void unflatten_device_tree (void );extern void unflatten_and_copy_device_tree (void );
--
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
Re: [PATCH 09/28] of: Introduce common early_init_dt_scan
In reply to Rob HerringQuoted 9 lines · Rob Herring
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Most architectures scan the all the same items early in the FDT and none are really architecture specific. Create a common
early_init_dt_scanto unify the early scan of root, memory, and chosen nodes in the flattened DT.Signed-off-by Rob Herring <rob.herring-bsGFqQB8/[email protected]>Cc Grant Likely <[email protected]>
One caveat below, but otherwise:
Quoted 11 lines
--- drivers/of/fdt.c | 18 ++++++++++++++++++ include/linux/of_fdt.h | 2 ++ 2 files changed, 20 insertions(+)drivers/of/fdt.c +0
-0@@ -785,6 +785,24 @@ void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) }
drivers/of/fdt.c void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) · line 795
Quoted 10 lines
drivers/of/fdt.c +8
-0#endif +bool __init early_init_dt_scan (void *params) +{ +/* Setup flat device-tree pointer */ + initial_boot_params = params; + +/* check device tree validity */ +if (be32_to_cpu (initial_boot_params->magic) !=OF_DT_HEADER ) +return false;
If the test fails, then clear initial_boot_params to NULL. Similarly, if params is NULL, then bail before dereferencing it.
Quoted 29 lines
drivers/of/fdt.c +10
-0+ +/* Retrieve various information from the /chosen node */ +of_scan_flat_dt (early_init_dt_scan_chosen, boot_command_line); +/* Initialize {size,address}-cells info */ +of_scan_flat_dt (early_init_dt_scan_root,NULL ); +/* Setup memory, calling early_init_dt_add_memory_arch */ +of_scan_flat_dt (early_init_dt_scan_memory,NULL ); +return true; +} +/** * unflatten_device_tree - create tree of device_nodes from flat blob * include/linux/of_fdt.h +2
-0@@ -116,6 +116,8 @@ extern void early_init_dt_setup_initrd_arch(u64 start, u64 end);extern int early_init_dt_scan_root (unsigned long node,const char *uname,int depth,void *data); +extern bool early_init_dt_scan (void *params); +/* Other Prototypes */ extern void unflatten_device_tree (void );extern void unflatten_and_copy_device_tree (void );Signature · 1 line
1.8.1.2
--
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
PATCH 10/28 arc: use early_init_dt_scan
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Convert arc to use new early_init_dt_scan function.
--- arch/arc/kernel/devtree.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
arch/arc/kernel/devtree.c +1 -13
@@ -27,7 +27,6 @@*/ struct machine_desc *__init setup_machine_fdt (void *dt) { -struct boot_param_header *devtree = dt;struct machine_desc *mdesc =NULL , *mdesc_best =NULL ;unsigned int score, mdesc_score = ~1 ;unsigned long dt_root;
@@ -36,11 +35,9 @@ struct machine_desc * __init setup_machine_fdt(void *dt)char manufacturer[16 ];unsigned long len; -/* check device tree validity */ -if (be32_to_cpu (devtree->magic) !=OF_DT_HEADER ) +if (!early_init_dt_scan (dt))return NULL ; - initial_boot_params = devtree; dt_root =of_get_flat_dt_root ();/*
@@ -85,15 +82,6 @@ struct machine_desc * __init setup_machine_fdt(void *dt)pr_info ("Board \"%s\" from %s (Manufacturer)\n" , model, manufacturer); -/* Retrieve various information from the /chosen node */ -of_scan_flat_dt (early_init_dt_scan_chosen, boot_command_line); - -/* Initialize {size,address}-cells info */ -of_scan_flat_dt (early_init_dt_scan_root,NULL ); - -/* Setup memory, calling early_init_dt_add_memory_arch */ -of_scan_flat_dt (early_init_dt_scan_memory,NULL ); - clk =of_get_flat_dt_prop (dt_root,"clock-frequency" , &len);if (clk)arc_set_core_freq (of_read_ulong (clk, len/4 ));
Signature · 1 line
1.8.1.2
Re: [PATCH 10/28] arc: use early_init_dt_scan
Quoted 6 lines · Rob Herring
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Convert arc to use new
early_init_dt_scanfunction.Signed-off-by Rob Herring <rob.herring-bsGFqQB8/[email protected]>Cc Vineet Gupta <vgupta-HKixBCOQz3hWk0Htik3J/[email protected]>
-Vineet
--
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
PATCH 11/28 arm: use early_init_dt_scan
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Convert arm to use new early_init_dt_scan function.
--- arch/arm/kernel/devtree.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
arch/arm/kernel/devtree.c +1 -14
@@ -183,7 +183,6 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id)*/ const struct machine_desc *__init setup_machine_fdt (unsigned int dt_phys) { -struct boot_param_header *devtree;const struct machine_desc *mdesc, *mdesc_best =NULL ;unsigned int score, mdesc_score = ~1 ;unsigned long dt_root;
@@ -199,14 +198,9 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)if (!dt_phys)return NULL ; - devtree =phys_to_virt (dt_phys); - -/* check device tree validity */ -if (be32_to_cpu (devtree->magic) !=OF_DT_HEADER ) -return NULL ; +early_init_dt_scan (phys_to_virt (dt_phys));/* Search the mdescs for the 'best' compatible value match */ - initial_boot_params = devtree; dt_root =of_get_flat_dt_root ();for_each_machine_desc (mdesc) { score =of_flat_dt_match (dt_root, mdesc->dt_compat);
@@ -240,13 +234,6 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) model ="<unknown>" ;pr_info ("Machine: %s, model: %s\n" , mdesc_best->name, model); -/* Retrieve various information from the /chosen node */ -of_scan_flat_dt (early_init_dt_scan_chosen, boot_command_line); -/* Initialize {size,address}-cells info */ -of_scan_flat_dt (early_init_dt_scan_root,NULL ); -/* Setup memory, calling early_init_dt_add_memory_arch */ -of_scan_flat_dt (early_init_dt_scan_memory,NULL ); -/* Change machine number to match the mdesc we're using */ __machine_arch_type = mdesc_best->nr;
Signature · 1 line
1.8.1.2
PATCH 12/28 arm64: use early_init_dt_scan
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Convert arm64 to use new early_init_dt_scan function.
--- arch/arm64/kernel/setup.c | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-)
arch/arm64/kernel/setup.c +3 -28
@@ -124,37 +124,19 @@ static void __init setup_processor(void)static void __init setup_machine_fdt (phys_addr_t dt_phys) { -struct boot_param_header *devtree;unsigned long dt_root; -/* Check we have a non-NULL DT pointer */ -if (!dt_phys) { -early_print ("\n" -"Error: NULL or invalid device tree blob\n" -"The dtb must be 8-byte aligned and passed in the first 512MB of memory\n" -"\nPlease check your bootloader.\n" ); - -while (true) -cpu_relax (); - - } - - devtree =phys_to_virt (dt_phys); - -/* Check device tree validity */ -if (be32_to_cpu (devtree->magic) !=OF_DT_HEADER ) { +if (!dt_phys || !early_init_dt_scan (phys_to_virt (dt_phys))) {early_print ("\n" "Error: invalid device tree blob at physical address 0x%p (virtual address 0x%p)\n" -"Expected 0x%x, found 0x%x\n" +"The dtb must be 8-byte aligned and passed in the first 512MB of memory\n" "\nPlease check your bootloader.\n" , - dt_phys, devtree,OF_DT_HEADER , -be32_to_cpu (devtree->magic)); + dt_phys,phys_to_virt (dt_phys));while (true)cpu_relax (); } - initial_boot_params = devtree; dt_root =of_get_flat_dt_root (); machine_name =of_get_flat_dt_prop (dt_root,"model" ,NULL );
@@ -163,13 +145,6 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)if (!machine_name) machine_name ="<unknown>" ;pr_info ("Machine: %s\n" , machine_name); - -/* Retrieve various information from the /chosen node */ -of_scan_flat_dt (early_init_dt_scan_chosen, boot_command_line); -/* Initialize {size,address}-cells info */ -of_scan_flat_dt (early_init_dt_scan_root,NULL ); -/* Setup memory, calling early_init_dt_add_memory_arch */ -of_scan_flat_dt (early_init_dt_scan_memory,NULL ); }void __init early_init_dt_add_memory_arch (u64 base,u64 size)
Signature · 1 line
1.8.1.2
Re: [PATCH 12/28] arm64: use early_init_dt_scan
Quoted 8 lines · Rob Herring
From: Rob Herring <[email protected]>
Convert arm64 to use new
early_init_dt_scanfunction.Signed-off-by Rob Herring <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc linux-arm-kernel at lists.infradead.org
PATCH 13/28 c6x: use early_init_dt_scan
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Convert c6x to use new early_init_dt_scan function.
--- arch/c6x/kernel/devicetree.c | 19 ------------------- arch/c6x/kernel/setup.c | 2 +- 2 files changed, 1 insertion(+), 20 deletions(-)
arch/c6x/kernel/devicetree.c +0 -19
@@ -10,28 +10,9 @@* */ #include <linux/init.h> -#include <linux/of.h> -#include <linux/of_fdt.h> #include <linux/initrd.h> #include <linux/memblock.h> -void __init early_init_devtree (void *params) -{ -/* Setup flat device-tree pointer */ - initial_boot_params = params; - -/* Retrieve various informations from the /chosen node of the -* device-tree, including the platform type, initrd location and -* size and more ... -*/ -of_scan_flat_dt (early_init_dt_scan_chosen, boot_command_line); - -/* Scan memory nodes and rebuild MEMBLOCKs */ -of_scan_flat_dt (early_init_dt_scan_root,NULL ); -of_scan_flat_dt (early_init_dt_scan_memory,NULL ); -} - -#ifdef CONFIG_BLK_DEV_INITRD void __init early_init_dt_setup_initrd_arch (u64 start,u64 end) {
arch/c6x/kernel/setup.c +1 -1
@@ -287,7 +287,7 @@ notrace void __init machine_init(unsigned long dt_ptr) fdt = dtb;/* Do some early initialization based on the flat device tree */ -early_init_devtree (fdt); +early_init_dt_scan (fdt);parse_early_param (); }
Signature · 1 line
1.8.1.2
Re: [PATCH 13/28] c6x: use early_init_dt_scan
Quoted 4 lines · Rob Herring
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Convert c6x to use new
early_init_dt_scanfunction.
Quoted 8 lines
Signed-off-by Rob Herring <rob.herring-bsGFqQB8/[email protected]>Cc Mark Salter <[email protected]>Cc Aurelien Jacquiot <[email protected]>--- arch/c6x/kernel/devicetree.c | 19 ------------------- arch/c6x/kernel/setup.c | 2 +- 2 files changed, 1 insertion(+), 20 deletions(-)
--
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
PATCH 14/28 microblaze: use early_init_dt_scan
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Convert microblaze to use new early_init_dt_scan function.
--- arch/microblaze/kernel/prom.c | 17 +++-------------- arch/microblaze/kernel/setup.c | 2 +- 2 files changed, 4 insertions(+), 15 deletions(-)
arch/microblaze/kernel/prom.c +3 -14
@@ -106,21 +106,10 @@ void __init early_init_devtree(void *params) {pr_debug (" -> early_init_devtree(%p)\n" , params); -/* Setup flat device-tree pointer */ - initial_boot_params = params; +early_init_dt_scan (params); +if (!strlen (boot_command_line)) +strlcpy (boot_command_line, cmd_line,COMMAND_LINE_SIZE ); -/* 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, cmd_line); - -/* Scan memory nodes and rebuild MEMBLOCKs */ -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 ();memblock_allow_resize ();
arch/microblaze/kernel/setup.c +1 -1
@@ -50,7 +50,7 @@ char cmd_line[COMMAND_LINE_SIZE] __attribute__ ((section(".data")));void __init setup_arch (char **cmdline_p) { - *cmdline_p = cmd_line; + *cmdline_p = boot_command_line;console_verbose ();
Signature · 1 line
1.8.1.2
Re: [PATCH 14/28] microblaze: use early_init_dt_scan
Quoted 11 lines · Rob Herring
From: Rob Herring <[email protected]>
Convert microblaze to use new
early_init_dt_scanfunction.Signed-off-by Rob Herring <[email protected]>Cc Michal Simek <[email protected]>--- arch/microblaze/kernel/prom.c | 17 +++-------------- arch/microblaze/kernel/setup.c | 2 +- 2 files changed, 4 insertions(+), 15 deletions(-)
No problem on Microblaze with this change.
Thanks,
Michal
Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/ Maintainer of Linux kernel - Xilinx Zynq ARM architecture Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform
PATCH 15/28 mips: use early_init_dt_scan
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Convert mips to use new early_init_dt_scan function.
Remove early_init_dt_scan_memory_arch
--- arch/mips/include/asm/prom.h | 3 --- arch/mips/kernel/prom.c | 39 +++------------------------------------ 2 files changed, 3 insertions(+), 39 deletions(-)
arch/mips/include/asm/prom.h +0 -3
@@ -17,9 +17,6 @@#include <linux/types.h> #include <asm/bootinfo.h> -extern int early_init_dt_scan_memory_arch (unsigned long node, -const char *uname,int depth,void *data); -extern void device_tree_init (void );static inline unsigned long pci_address_to_pio (phys_addr_t address)
arch/mips/kernel/prom.c +3 -36
@@ -17,8 +17,6 @@#include <linux/debugfs.h> #include <linux/of.h> #include <linux/of_fdt.h> -#include <linux/of_irq.h> -#include <linux/of_platform.h> #include <asm/page.h> #include <asm/prom.h>
@@ -40,13 +38,6 @@ char *mips_get_machine_name(void) }#ifdef CONFIG_OF -int __init early_init_dt_scan_memory_arch (unsigned long node, -const char *uname,int depth, -void *data) -{ -return early_init_dt_scan_memory (node, uname, depth, data); -} -void __init early_init_dt_add_memory_arch (u64 base,u64 size) {return add_memory_region (base, size,BOOT_MEM_RAM );
@@ -78,36 +69,12 @@ int __init early_init_dt_scan_model(unsigned long node, const char *uname, return 0; } -void __init early_init_devtree (void *params) -{ -/* Setup flat device-tree pointer */ - initial_boot_params = params; - -/* Retrieve various informations from the /chosen node of the -* device-tree, including the platform type, initrd location and -* size, and more ... -*/ -of_scan_flat_dt (early_init_dt_scan_chosen, arcs_cmdline); - - -/* Scan memory nodes */ -of_scan_flat_dt (early_init_dt_scan_root,NULL ); -of_scan_flat_dt (early_init_dt_scan_memory_arch,NULL ); - -/* try to load the mips machine name */ -of_scan_flat_dt (early_init_dt_scan_model,NULL ); -} -void __init __dt_setup_arch (struct boot_param_header *bph) { -if (be32_to_cpu (bph->magic) !=OF_DT_HEADER ) { -pr_err ("DTB has bad magic, ignoring builtin OF DTB\n" ); - +if (!early_init_dt_scan (bph))return ; - } - - initial_boot_params = bph; -early_init_devtree (initial_boot_params); +/* try to load the mips machine name */ +of_scan_flat_dt (early_init_dt_scan_model,NULL ); }#endif
Signature · 1 line
1.8.1.2
Re: [PATCH 15/28] mips: use early_init_dt_scan
Quoted 10 lines · Rob Herring
From: Rob Herring<[email protected]>
Convert mips to use new
early_init_dt_scanfunction.Remove
early_init_dt_scan_memory_arch---
Thanks for this series ...
Quoted 85 lines
arch/mips/include/asm/prom.h | 3 --- arch/mips/kernel/prom.c | 39 +++------------------------------------ 2 files changed, 3 insertions(+), 39 deletions(-)arch/mips/include/asm/prom.h +0
-3@@ -17,9 +17,6 @@#include <linux/types.h> #include <asm/bootinfo.h> -extern int early_init_dt_scan_memory_arch (unsigned long node, -const char *uname,int depth,void *data); -extern void device_tree_init (void );static inline unsigned long pci_address_to_pio (phys_addr_t address)arch/mips/kernel/prom.c +3
-36@@ -17,8 +17,6 @@#include <linux/debugfs.h> #include <linux/of.h> #include <linux/of_fdt.h> -#include <linux/of_irq.h> -#include <linux/of_platform.h> #include <asm/page.h> #include <asm/prom.h> @@ -40,13 +38,6 @@ char *mips_get_machine_name(void) }#ifdef CONFIG_OF -int __init early_init_dt_scan_memory_arch (unsigned long node, -const char *uname,int depth, -void *data) -{ -return early_init_dt_scan_memory (node, uname, depth, data); -} -void __init early_init_dt_add_memory_arch (u64 base,u64 size) {return add_memory_region (base, size,BOOT_MEM_RAM );@@ -78,36 +69,12 @@ int __init early_init_dt_scan_model(unsigned long node, const char *uname, return 0; } -void __init early_init_devtree (void *params) -{ -/* Setup flat device-tree pointer */ - initial_boot_params = params; - -/* Retrieve various informations from the /chosen node of the -* device-tree, including the platform type, initrd location and -* size, and more ... -*/ -of_scan_flat_dt (early_init_dt_scan_chosen, arcs_cmdline); - - -/* Scan memory nodes */ -of_scan_flat_dt (early_init_dt_scan_root,NULL ); -of_scan_flat_dt (early_init_dt_scan_memory_arch,NULL ); - -/* try to load the mips machine name */ -of_scan_flat_dt (early_init_dt_scan_model,NULL ); -} -void __init __dt_setup_arch (struct boot_param_header *bph) { -if (be32_to_cpu (bph->magic) !=OF_DT_HEADER ) { -pr_err ("DTB has bad magic, ignoring builtin OF DTB\n" ); - +if (!early_init_dt_scan (bph))return ; - } - - initial_boot_params = bph; -early_init_devtree (initial_boot_params); +/* try to load the mips machine name */ +of_scan_flat_dt (early_init_dt_scan_model,NULL ); }#endif
PATCH 16/28 openrisc: use early_init_dt_scan
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Convert openrisc to use new early_init_dt_scan function.
--- arch/openrisc/kernel/prom.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
arch/openrisc/kernel/prom.c +1 -14
@@ -55,20 +55,7 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)void __init early_init_devtree (void *params) { -/* Setup flat device-tree pointer */ - initial_boot_params = params; - - -/* 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, boot_command_line); - -/* Scan memory nodes and rebuild MEMBLOCKs */ -of_scan_flat_dt (early_init_dt_scan_root,NULL ); -of_scan_flat_dt (early_init_dt_scan_memory,NULL ); - +early_init_dt_scan (params);memblock_allow_resize (); }
Signature · 1 line
1.8.1.2
PATCH 17/28 xtensa: use early_init_dt_scan
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Convert xtensa to use new early_init_dt_scan function.
--- arch/xtensa/kernel/setup.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
arch/xtensa/kernel/setup.c +9 -12
@@ -219,9 +219,13 @@ static int __init parse_bootparam(const bp_tag_t* tag) }#ifdef CONFIG_OF +bool __initdata dt_memory_scan = false;void __init early_init_dt_add_memory_arch (u64 base,u64 size) { +if (!dt_memory_scan) +return ; + size &=PAGE_MASK ;add_sysmem_bank (MEMORY_TYPE_CONVENTIONAL , base, base + size); }
@@ -233,20 +237,13 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)void __init early_init_devtree (void *params) { -/* Setup flat device-tree pointer */ - initial_boot_params = params; +if (sysmem.nr_banks ==0 ) + dt_memory_scan = true; -/* Retrieve various informations from the /chosen node of the -* device-tree, including the platform type, initrd location and -* size, TCE reserve, and more ... -*/ -if (!command_line[0 ]) -of_scan_flat_dt (early_init_dt_scan_chosen, command_line); +early_init_dt_scan (params); -/* Scan memory nodes and rebuild MEMBLOCKs */ -of_scan_flat_dt (early_init_dt_scan_root,NULL ); -if (sysmem.nr_banks ==0 ) -of_scan_flat_dt (early_init_dt_scan_memory,NULL ); +if (!command_line[0 ]) +strlcpy (command_line, boot_command_line,COMMAND_LINE_SIZE ); }static int __init xtensa_device_probe (void )
Signature · 1 line
1.8.1.2
Re: [PATCH 17/28] xtensa: use early_init_dt_scan
Quoted 11 lines · Rob Herring
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Convert xtensa to use new
early_init_dt_scanfunction.Signed-off-by Rob Herring <rob.herring-bsGFqQB8/[email protected]>Cc Chris Zankel <[email protected]>Cc Max Filippov <[email protected]>Cc linux-xtensa-PjhNF2WwrV/[email protected]--- arch/xtensa/kernel/setup.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-)
Signature · 6 lines
Thanks. -- Max -- 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
PATCH 18/28 of: create default early_init_dt_add_memory_arch
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Create a weak version of early_init_dt_add_memory_arch which uses memblock or is an empty function when memblock is not enabled. This will unify all architectures except ones with custom memory bank structs.
--- arch/arm64/kernel/setup.c | 18 ------------------ arch/metag/kernel/devtree.c | 6 ------ arch/microblaze/kernel/prom.c | 5 ----- arch/openrisc/kernel/prom.c | 6 ------ arch/x86/kernel/devicetree.c | 10 ---------- drivers/of/fdt.c | 11 +++++++++++ 6 files changed, 11 insertions(+), 45 deletions(-)
arch/arm64/kernel/setup.c +0 -18
@@ -147,24 +147,6 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)pr_info ("Machine: %s\n" , machine_name); } -void __init early_init_dt_add_memory_arch (u64 base,u64 size) -{ - base &=PAGE_MASK ; - size &=PAGE_MASK ; -if (base + size <PHYS_OFFSET ) { -pr_warning ("Ignoring memory block 0x%llx - 0x%llx\n" , - base, base + size); -return ; - } -if (base <PHYS_OFFSET ) { -pr_warning ("Ignoring memory range 0x%llx - 0x%llx\n" , - base,PHYS_OFFSET ); - size -=PHYS_OFFSET - base; - base =PHYS_OFFSET ; - } -memblock_add (base, size); -} -/* * Limit the memory size that was specified via FDT. */
arch/metag/kernel/devtree.c +0 -6
@@ -23,12 +23,6 @@#include <asm/page.h> #include <asm/mach/arch.h> -void __init early_init_dt_add_memory_arch (u64 base,u64 size) -{ -pr_err ("%s(%llx, %llx)\n" , - __func__, base, size); -} -void *__init early_init_dt_alloc_memory_arch (u64 size,u64 align) {return alloc_bootmem_align (size, align);
arch/microblaze/kernel/prom.c +0 -5
@@ -41,11 +41,6 @@#include <asm/sections.h> #include <asm/pci-bridge.h> -void __init early_init_dt_add_memory_arch (u64 base,u64 size) -{ -memblock_add (base, size); -} -#ifdef CONFIG_EARLY_PRINTK static char *stdout;
arch/openrisc/kernel/prom.c +0 -6
@@ -47,12 +47,6 @@#include <asm/sections.h> #include <asm/setup.h> -void __init early_init_dt_add_memory_arch (u64 base,u64 size) -{ - size &=PAGE_MASK ; -memblock_add (base, size); -} -void __init early_init_devtree (void *params) {early_init_dt_scan (params);
arch/x86/kernel/devicetree.c +0 -10
@@ -36,16 +36,6 @@ unsigned long pci_address_to_pio(phys_addr_t address) }EXPORT_SYMBOL_GPL (pci_address_to_pio); -void __init early_init_dt_scan_chosen_arch (unsigned long node) -{ -BUG (); -} - -void __init early_init_dt_add_memory_arch (u64 base,u64 size) -{ -BUG (); -} -void *__init early_init_dt_alloc_memory_arch (u64 size,u64 align) {return __alloc_bootmem (size, align,__pa (MAX_DMA_ADDRESS ));
drivers/of/fdt.c +11 -0
@@ -688,6 +688,17 @@ u64 __init dt_mem_next_cell(int s, __be32 **cellp)return of_read_number (p, s); } +void __init __weak early_init_dt_add_memory_arch (u64 base,u64 size) +{ +#ifdef CONFIG_HAVE_MEMBLOCK + base &=PAGE_MASK ; + size &=PAGE_MASK ; +memblock_add (base, size); +#else +pr_err ("%s: ignoring memory (%llx, %llx)\n" , __func__, base, size); +#endif +} +/** * early_init_dt_scan_memory - Look for an parse memory nodes */
Signature · 1 line
1.8.1.2
Catalin Marinas
maintainerRe: [PATCH 18/28] of: create default early_init_dt_add_memory_arch
Quoted 27 lines · Rob Herring
arch/arm64/kernel/setup.c +0
-18@@ -147,24 +147,6 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)pr_info ("Machine: %s\n" , machine_name); } -void __init early_init_dt_add_memory_arch (u64 base,u64 size) -{ - base &=PAGE_MASK ; - size &=PAGE_MASK ; -if (base + size <PHYS_OFFSET ) { -pr_warning ("Ignoring memory block 0x%llx - 0x%llx\n" , - base, base + size); -return ; - } -if (base <PHYS_OFFSET ) { -pr_warning ("Ignoring memory range 0x%llx - 0x%llx\n" , - base,PHYS_OFFSET ); - size -=PHYS_OFFSET - base; - base =PHYS_OFFSET ; - } -memblock_add (base, size); -} -/* * Limit the memory size that was specified via FDT. */
...
Quoted 6 lines
drivers/of/fdt.c +0
-0@@ -688,6 +688,17 @@ u64 __init dt_mem_next_cell(int s, __be32 **cellp)return of_read_number (p, s); }
drivers/of/fdt.c u64 __init dt_mem_next_cell(int s, __be32 **cellp) · line 700
Quoted 10 lines
drivers/of/fdt.c +10
-0+void __init __weak early_init_dt_add_memory_arch (u64 base,u64 size) +{ +#ifdef CONFIG_HAVE_MEMBLOCK + base &=PAGE_MASK ; + size &=PAGE_MASK ; +memblock_add (base, size); +#else +pr_err ("%s: ignoring memory (%llx, %llx)\n" , __func__, base, size); +#endif +}
Are the arm64 changes equivalent here? There are some safety checks to cope with the kernel being loaded at a higher offset than the recommended one (PHYS_OFFSET calculated automatically).
Catalin
Re: [PATCH 18/28] of: create default early_init_dt_add_memory_arch
Quoted 37 lines · Catalin Marinas
Quoted 27 lines · Rob Herring
arch/arm64/kernel/setup.c +0
-18@@ -147,24 +147,6 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)pr_info ("Machine: %s\n" , machine_name); } -void __init early_init_dt_add_memory_arch (u64 base,u64 size) -{ - base &=PAGE_MASK ; - size &=PAGE_MASK ; -if (base + size <PHYS_OFFSET ) { -pr_warning ("Ignoring memory block 0x%llx - 0x%llx\n" , - base, base + size); -return ; - } -if (base <PHYS_OFFSET ) { -pr_warning ("Ignoring memory range 0x%llx - 0x%llx\n" , - base,PHYS_OFFSET ); - size -=PHYS_OFFSET - base; - base =PHYS_OFFSET ; - } -memblock_add (base, size); -} -/* * Limit the memory size that was specified via FDT. */ ...
Quoted 6 lines
drivers/of/fdt.c +0
-0@@ -688,6 +688,17 @@ u64 __init dt_mem_next_cell(int s, __be32 **cellp)return of_read_number (p, s); }
Quoted 14 lines
drivers/of/fdt.c u64 __init dt_mem_next_cell(int s, __be32 **cellp) · line 700
Quoted 10 lines
drivers/of/fdt.c +10
-0+void __init __weak early_init_dt_add_memory_arch (u64 base,u64 size) +{ +#ifdef CONFIG_HAVE_MEMBLOCK + base &=PAGE_MASK ; + size &=PAGE_MASK ; +memblock_add (base, size); +#else +pr_err ("%s: ignoring memory (%llx, %llx)\n" , __func__, base, size); +#endif +}Are the arm64 changes equivalent here? There are some safety checks to cope with the kernel being loaded at a higher offset than the recommended one (
PHYS_OFFSETcalculated automatically).
I tried to keep that, but PHYS_OFFSET is not universally defined. My reasoning is this range checking is hardly specific to an architecture. Perhaps if memory always starts at 0 you don't need it. If arm64 really needs these checks, then all architectures do.
Perhaps "__virt_to_phys(PAGE_OFFSET)" instead of PHYS_OFFSET would work for all?
Rob
Catalin Marinas
maintainerRe: [PATCH 18/28] of: create default early_init_dt_add_memory_arch
Quoted 54 lines · Rob Herring
Quoted 37 lines · Catalin Marinas
Quoted 27 lines · Rob Herring
arch/arm64/kernel/setup.c +0
-18@@ -147,24 +147,6 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)pr_info ("Machine: %s\n" , machine_name); } -void __init early_init_dt_add_memory_arch (u64 base,u64 size) -{ - base &=PAGE_MASK ; - size &=PAGE_MASK ; -if (base + size <PHYS_OFFSET ) { -pr_warning ("Ignoring memory block 0x%llx - 0x%llx\n" , - base, base + size); -return ; - } -if (base <PHYS_OFFSET ) { -pr_warning ("Ignoring memory range 0x%llx - 0x%llx\n" , - base,PHYS_OFFSET ); - size -=PHYS_OFFSET - base; - base =PHYS_OFFSET ; - } -memblock_add (base, size); -} -/* * Limit the memory size that was specified via FDT. */ ...
Quoted 6 lines
drivers/of/fdt.c +0
-0@@ -688,6 +688,17 @@ u64 __init dt_mem_next_cell(int s, __be32 **cellp)return of_read_number (p, s); }Quoted 14 lines
drivers/of/fdt.c u64 __init dt_mem_next_cell(int s, __be32 **cellp) · line 700
Quoted 10 lines
drivers/of/fdt.c +10
-0+void __init __weak early_init_dt_add_memory_arch (u64 base,u64 size) +{ +#ifdef CONFIG_HAVE_MEMBLOCK + base &=PAGE_MASK ; + size &=PAGE_MASK ; +memblock_add (base, size); +#else +pr_err ("%s: ignoring memory (%llx, %llx)\n" , __func__, base, size); +#endif +}Are the arm64 changes equivalent here? There are some safety checks to cope with the kernel being loaded at a higher offset than the recommended one (
PHYS_OFFSETcalculated automatically).
Quoted 6 lines
I tried to keep that, but
PHYS_OFFSETis not universally defined. My reasoning is this range checking is hardly specific to an architecture. Perhaps if memory always starts at 0 you don't need it. If arm64 really needs these checks, then all architectures do.Perhaps "
__virt_to_phys(PAGE_OFFSET)" instead ofPHYS_OFFSETwould work for all?
I think virt_to_phys() or __pa() should work, the __virt_to_phys() is only defined by a few architectures.
Signature · 1 line
Catalin
Re: [PATCH 18/28] of: create default early_init_dt_add_memory_arch
In reply to Rob HerringQuoted 6 lines · Rob Herring
From: Rob Herring <[email protected]>
Create a weak version of
early_init_dt_add_memory_archwhich uses memblock or is an empty function when memblock is not enabled. This will unify all architectures except ones with custom memory bank structs.
Two comments below, but otherwise:
Quoted 9 lines
drivers/of/fdt.c +1
-0@@ -688,6 +688,17 @@ u64 __init dt_mem_next_cell(int s, __be32 **cellp)return of_read_number (p, s); } +void __init __weak early_init_dt_add_memory_arch (u64 base,u64 size)
drivers/of/fdt.c u64 __init dt_mem_next_cell(int s, __be32 **cellp) · line 701
Quoted 10 lines
drivers/of/fdt.c +10
-0+{ +#ifdef CONFIG_HAVE_MEMBLOCK + base &=PAGE_MASK ; + size &=PAGE_MASK ; +memblock_add (base, size); +#else +pr_err ("%s: ignoring memory (%llx, %llx)\n" , __func__, base, size); +#endif +} +
Can you do it this way instead:
#ifdef CONFIG_HAVE_MEMBLOCK
void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
{
base &= PAGE_MASK;
size &= PAGE_MASK;
memblock_add(base, size);
}#endif
If the platform doesn't provide an early_init_dt_add_memory_arch() function and it doesn't have a memblock implementation, then the build should outright fail. I don't see a scenario where we would want to successfully build the kernel without a working add memory function.
Also, can you group this function with the common __weak early_init_dt_alloc_memory_arch() implementation? It would be good to group all the memblock specific functions together.
g.
Re: [PATCH 18/28] of: create default early_init_dt_add_memory_arch
Quoted 41 lines · Grant Likely
Quoted 6 lines · Rob Herring
From: Rob Herring <[email protected]>
Create a weak version of
early_init_dt_add_memory_archwhich uses memblock or is an empty function when memblock is not enabled. This will unify all architectures except ones with custom memory bank structs.Two comments below, but otherwise:
Acked-by Grant Likely <[email protected]>Quoted 9 lines
drivers/of/fdt.c +1
-0@@ -688,6 +688,17 @@ u64 __init dt_mem_next_cell(int s, __be32 **cellp)return of_read_number (p, s); } +void __init __weak early_init_dt_add_memory_arch (u64 base,u64 size)drivers/of/fdt.c u64 __init dt_mem_next_cell(int s, __be32 **cellp) · line 701
Quoted 10 lines
drivers/of/fdt.c +10
-0+{ +#ifdef CONFIG_HAVE_MEMBLOCK + base &=PAGE_MASK ; + size &=PAGE_MASK ; +memblock_add (base, size); +#else +pr_err ("%s: ignoring memory (%llx, %llx)\n" , __func__, base, size); +#endif +} +Can you do it this way instead:
#ifdef
CONFIG_HAVE_MEMBLOCK
void__init__weakearly_init_dt_add_memory_arch(u64 base, u64 size){ base &= PAGE_MASK; size &= PAGE_MASK; memblock_add(base, size); }
Quoted 6 lines
#endif
If the platform doesn't provide an
early_init_dt_add_memory_arch()function and it doesn't have a memblock implementation, then the build should outright fail. I don't see a scenario where we would want to successfully build the kernel without a working add memory function.
metag and x86 both have empty functions. I guess they get memory from a different boot interface.
Rob
Quoted 7 lines
Also, can you group this function with the common
__weakearly_init_dt_alloc_memory_arch()implementation? It would be good to group all the memblock specific functions together.g.
Re: [PATCH 18/28] of: create default early_init_dt_add_memory_arch
Quoted 44 lines · Rob Herring
Quoted 43 lines · Grant Likely
Quoted 6 lines · Rob Herring
From: Rob Herring <[email protected]>
Create a weak version of
early_init_dt_add_memory_archwhich uses memblock or is an empty function when memblock is not enabled. This will unify all architectures except ones with custom memory bank structs.Two comments below, but otherwise:
Acked-by Grant Likely <[email protected]>Quoted 9 lines
drivers/of/fdt.c +1
-0@@ -688,6 +688,17 @@ u64 __init dt_mem_next_cell(int s, __be32 **cellp)return of_read_number (p, s); } +void __init __weak early_init_dt_add_memory_arch (u64 base,u64 size)drivers/of/fdt.c u64 __init dt_mem_next_cell(int s, __be32 **cellp) · line 701
Quoted 10 lines
drivers/of/fdt.c +10
-0+{ +#ifdef CONFIG_HAVE_MEMBLOCK + base &=PAGE_MASK ; + size &=PAGE_MASK ; +memblock_add (base, size); +#else +pr_err ("%s: ignoring memory (%llx, %llx)\n" , __func__, base, size); +#endif +} +Can you do it this way instead:
#ifdef
CONFIG_HAVE_MEMBLOCK
void__init__weakearly_init_dt_add_memory_arch(u64 base, u64 size){ base &= PAGE_MASK; size &= PAGE_MASK; memblock_add(base, size); }#endif
Quoted 7 lines
Quoted 4 lines
If the platform doesn't provide an
early_init_dt_add_memory_arch()function and it doesn't have a memblock implementation, then the build should outright fail. I don't see a scenario where we would want to successfully build the kernel without a working add memory function.metag and x86 both have empty functions. I guess they get memory from a different boot interface.
I would put the exceptions into arch/x86 and arch/metag then. The default answer should be that early_init_dt_add_memory_arch() works, and the build will fail if they aren't implemented. If it really is valid to have an empty implementation, then the architecture should have to do something special to get that.
g.
PATCH 19/28 arm: set initrd_start/initrd_end for fdt scan
In reply to Rob HerringFrom: Rob Herring <[email protected]>
In order to unify the initrd scanning for DT across architectures, make arm set initrd_start and initrd_end instead of the physical addresses. This is aligned with all other architectures.
--- arch/arm/mm/init.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
arch/arm/mm/init.c +8 -3
@@ -77,11 +77,11 @@ static int __init parse_tag_initrd2(const struct tag *tag)__tagtable (ATAG_INITRD2 , parse_tag_initrd2); -#ifdef CONFIG_OF_FLATTREE +#if defined(CONFIG_OF_FLATTREE ) && defined(CONFIG_BLK_DEV_INITRD )void __init early_init_dt_setup_initrd_arch (u64 start,u64 end) { - phys_initrd_start = start; - phys_initrd_size = end - start; + initrd_start = (unsigned long )__va (start); + initrd_end = (unsigned long )__va (end); }#endif /* CONFIG_OF_FLATTREE */
@@ -351,6 +351,11 @@ void __init arm_memblock_init(struct meminfo *mi,memblock_reserve (__pa (_stext), _end - _stext);#endif #ifdef CONFIG_BLK_DEV_INITRD +/* FDT scan will populate initrd_start */ +if (initrd_start) { + phys_initrd_start =__virt_to_phys (initrd_start); + phys_initrd_size = initrd_end - initrd_start; + }if (phys_initrd_size && !memblock_is_region_memory (phys_initrd_start, phys_initrd_size)) { pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region - disabling initrd\n",
Signature · 1 line
1.8.1.2
Re: [PATCH 19/28] arm: set initrd_start/initrd_end for fdt scan
Quoted 9 lines · Rob Herring
From: Rob Herring <[email protected]>
In order to unify the initrd scanning for DT across architectures, make arm set
initrd_startandinitrd_endinstead of the physical addresses. This is aligned with all other architectures.Signed-off-by Rob Herring <[email protected]>Cc Russell King <[email protected]>Cc linux-arm-kernel at lists.infradead.org
Quoted 38 lines
--- arch/arm/mm/init.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)arch/arm/mm/init.c +8
-3@@ -77,11 +77,11 @@ static int __init parse_tag_initrd2(const struct tag *tag)__tagtable (ATAG_INITRD2 , parse_tag_initrd2); -#ifdef CONFIG_OF_FLATTREE +#if defined(CONFIG_OF_FLATTREE ) && defined(CONFIG_BLK_DEV_INITRD )void __init early_init_dt_setup_initrd_arch (u64 start,u64 end) { - phys_initrd_start = start; - phys_initrd_size = end - start; + initrd_start = (unsigned long )__va (start); + initrd_end = (unsigned long )__va (end); }#endif /* CONFIG_OF_FLATTREE */ @@ -351,6 +351,11 @@ void __init arm_memblock_init(struct meminfo *mi,memblock_reserve (__pa (_stext), _end - _stext);#endif #ifdef CONFIG_BLK_DEV_INITRD +/* FDT scan will populate initrd_start */ +if (initrd_start) { + phys_initrd_start =__virt_to_phys (initrd_start); + phys_initrd_size = initrd_end - initrd_start; + }if (phys_initrd_size && !memblock_is_region_memory (phys_initrd_start, phys_initrd_size)) { pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region - disabling initrd\n",Signature · 1 line
1.8.1.2
PATCH 20/28 arm64: set initrd_start/initrd_end for fdt scan
In reply to Rob HerringFrom: Rob Herring <[email protected]>
In order to unify the initrd scanning for DT across architectures, make arm64 use initrd_start and initrd_end instead of the physical addresses.
--- arch/arm64/mm/init.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)
arch/arm64/mm/init.c +6 -18
@@ -39,17 +39,9 @@#include "mm.h" -static unsigned long phys_initrd_start__initdata =0 ; -static unsigned long phys_initrd_size__initdata =0 ; -phys_addr_t memstart_addr__read_mostly =0 ; -void __init early_init_dt_setup_initrd_arch (u64 start,u64 end) -{ - phys_initrd_start = start; - phys_initrd_size = end - start; -} - +#ifdef CONFIG_BLK_DEV_INITRD static int __init early_initrd (char *p) {unsigned long start, size;
@@ -59,12 +51,13 @@ static int __init early_initrd(char *p)if (*endp ==',' ) { size =memparse (endp +1 ,NULL ); - phys_initrd_start = start; - phys_initrd_size = size; + initrd_start = (unsigned long )__va (start); + initrd_end = (unsigned long )__va (start + size); } return 0; }early_param ("initrd" , early_initrd); +#endif #define MAX_DMA32_PFN ((4UL * 1024 * 1024 * 1024) >> PAGE_SHIFT)
@@ -137,13 +130,8 @@ void __init arm64_memblock_init(void)/* Register the kernel text, kernel data and initrd with memblock */ memblock_reserve (__pa (_text), _end - _text);#ifdef CONFIG_BLK_DEV_INITRD -if (phys_initrd_size) { -memblock_reserve (phys_initrd_start, phys_initrd_size); - -/* Now convert initrd to virtual addresses */ - initrd_start =__phys_to_virt (phys_initrd_start); - initrd_end = initrd_start + phys_initrd_size; - } +if (initrd_start) +memblock_reserve (__virt_to_phys (initrd_start), initrd_end - initrd_start);#endif /*
Signature · 1 line
1.8.1.2
Re: [PATCH 20/28] arm64: set initrd_start/initrd_end for fdt scan
Quoted 9 lines · Rob Herring
From: Rob Herring <[email protected]>
In order to unify the initrd scanning for DT across architectures, make arm64 use
initrd_startandinitrd_endinstead of the physical addresses.Signed-off-by Rob Herring <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc linux-arm-kernel at lists.infradead.org
Grant Likely
Acked-byRe: [PATCH 20/28] arm64: set initrd_start/initrd_end for fdt scan
Quoted 6 lines · Catalin Marinas
Quoted 5 lines · Rob Herring
From: Rob Herring <[email protected]>
In order to unify the initrd scanning for DT across architectures, make arm64 use
initrd_startandinitrd_endinstead of the physical addresses.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Rob Herring <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc linux-arm-kernel at lists.infradead.orgAcked-by Catalin Marinas <[email protected]>
PATCH 21/28 of: remove early_init_dt_setup_initrd_arch
In reply to Rob HerringFrom: Rob Herring <[email protected]>
All arches do essentially the same thing now for early_init_dt_setup_initrd_arch, so it can now be removed.
--- arch/arc/mm/init.c | 7 ------- arch/arm/mm/init.c | 8 -------- arch/c6x/kernel/devicetree.c | 10 ---------- arch/metag/mm/init.c | 9 --------- arch/microblaze/kernel/prom.c | 9 --------- arch/mips/kernel/prom.c | 10 ---------- arch/openrisc/kernel/prom.c | 9 --------- arch/powerpc/kernel/prom.c | 9 --------- arch/x86/kernel/devicetree.c | 9 --------- arch/xtensa/kernel/setup.c | 15 ++++----------- drivers/of/fdt.c | 9 ++++++--- include/linux/of_fdt.h | 10 ---------- 12 files changed, 10 insertions(+), 104 deletions(-)
arch/arc/mm/init.c +0 -7
@@ -125,10 +125,3 @@ void __init free_initrd_mem(unsigned long start, unsigned long end) free_reserved_area((void *)start, (void *)end, -1, "initrd"); }#endif - -#ifdef CONFIG_OF_FLATTREE -void __init early_init_dt_setup_initrd_arch (u64 start,u64 end) -{ -pr_err ("%s(%llx, %llx)\n" , __func__, start, end); -} -#endif /* CONFIG_OF_FLATTREE */
arch/arm/mm/init.c +0 -8
@@ -77,14 +77,6 @@ static int __init parse_tag_initrd2(const struct tag *tag)__tagtable (ATAG_INITRD2 , parse_tag_initrd2); -#if defined(CONFIG_OF_FLATTREE ) && defined(CONFIG_BLK_DEV_INITRD ) -void __init early_init_dt_setup_initrd_arch (u64 start,u64 end) -{ - initrd_start = (unsigned long )__va (start); - initrd_end = (unsigned long )__va (end); -} -#endif /* CONFIG_OF_FLATTREE */ -/* * This keeps memory configuration data used by a couple memory * initialization functions, as well as show_mem() for the skipping
arch/c6x/kernel/devicetree.c +0 -10
@@ -10,18 +10,8 @@* */ #include <linux/init.h> -#include <linux/initrd.h> #include <linux/memblock.h> -#ifdef CONFIG_BLK_DEV_INITRD -void __init early_init_dt_setup_initrd_arch (u64 start,u64 end) -{ - initrd_start = (unsigned long )__va (start); - initrd_end = (unsigned long )__va (end); - initrd_below_start_ok =1 ; -} -#endif -void __init early_init_dt_add_memory_arch (u64 base,u64 size) {c6x_add_memory (base, size);
arch/metag/mm/init.c +0 -9
@@ -12,7 +12,6 @@#include <linux/percpu.h> #include <linux/memblock.h> #include <linux/initrd.h> -#include <linux/of_fdt.h> #include <asm/setup.h> #include <asm/page.h>
@@ -405,11 +404,3 @@ void free_initrd_mem(unsigned long start, unsigned long end) "initrd"); }#endif - -#ifdef CONFIG_OF_FLATTREE -void __init early_init_dt_setup_initrd_arch (u64 start,u64 end) -{ -pr_err ("%s(%llx, %llx)\n" , - __func__, start, end); -} -#endif /* CONFIG_OF_FLATTREE */
arch/microblaze/kernel/prom.c +0 -9
@@ -114,15 +114,6 @@ void __init early_init_devtree(void *params)pr_debug (" <- early_init_devtree()\n" ); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init early_init_dt_setup_initrd_arch (u64 start,u64 end) -{ - initrd_start = (unsigned long )__va (start); - initrd_end = (unsigned long )__va (end); - initrd_below_start_ok =1 ; -} -#endif -/******* * * New implementation of the OF "find" APIs, return a refcounted
arch/mips/kernel/prom.c +0 -10
@@ -13,7 +13,6 @@#include <linux/errno.h> #include <linux/types.h> #include <linux/bootmem.h> -#include <linux/initrd.h> #include <linux/debugfs.h> #include <linux/of.h> #include <linux/of_fdt.h>
@@ -48,15 +47,6 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)return __alloc_bootmem (size, align,__pa (MAX_DMA_ADDRESS )); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init early_init_dt_setup_initrd_arch (u64 start,u64 end) -{ - initrd_start = (unsigned long )__va (start); - initrd_end = (unsigned long )__va (end); - initrd_below_start_ok =1 ; -} -#endif -int __init early_init_dt_scan_model (unsigned long node,const char *uname,int depth,void *data) {
arch/openrisc/kernel/prom.c +0 -9
@@ -52,12 +52,3 @@ void __init early_init_devtree(void *params)early_init_dt_scan (params);memblock_allow_resize (); } - -#ifdef CONFIG_BLK_DEV_INITRD -void __init early_init_dt_setup_initrd_arch (u64 start,u64 end) -{ - initrd_start = (unsigned long )__va (start); - initrd_end = (unsigned long )__va (end); - initrd_below_start_ok =1 ; -} -#endif
arch/powerpc/kernel/prom.c +0 -9
@@ -546,15 +546,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)memblock_add (base, size); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init early_init_dt_setup_initrd_arch (u64 start,u64 end) -{ - initrd_start = (unsigned long )__va (start); - initrd_end = (unsigned long )__va (end); - initrd_below_start_ok =1 ; -} -#endif -static void __init early_reserve_mem_dt (void ) {unsigned long i, len, dt_root;
arch/x86/kernel/devicetree.c +0 -9
@@ -41,15 +41,6 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)return __alloc_bootmem (size, align,__pa (MAX_DMA_ADDRESS )); } -#ifdef CONFIG_BLK_DEV_INITRD -void __init early_init_dt_setup_initrd_arch (u64 start,u64 end) -{ - initrd_start = (unsigned long )__va (start); - initrd_end = (unsigned long )__va (end); - initrd_below_start_ok =1 ; -} -#endif -void __init add_dtb (u64 data) { initial_dtb = data + offsetof(struct setup_data , data);
arch/xtensa/kernel/setup.c +4 -11
@@ -61,8 +61,8 @@ extern struct rtc_ops no_rtc_ops;struct rtc_ops *rtc_ops;#ifdef CONFIG_BLK_DEV_INITRD -extern void *initrd_start; -extern void *initrd_end; +extern unsigned long initrd_start; +extern unsigned long initrd_end;int initrd_is_mapped =0 ;extern int initrd_below_start_ok;#endif
@@ -149,8 +149,8 @@ static int __init parse_tag_initrd(const bp_tag_t* tag) {meminfo_t * mi; mi = (meminfo_t *)(tag->data); - initrd_start =__va (mi->start); - initrd_end =__va (mi->end); + initrd_start = (unsigned long )__va (mi->start); + initrd_end = (unsigned long )__va (mi->end);return 0 ; }
@@ -167,13 +167,6 @@ static int __init parse_tag_fdt(const bp_tag_t *tag)__tagtable (BP_TAG_FDT , parse_tag_fdt); -void __init early_init_dt_setup_initrd_arch (u64 start,u64 end) -{ - initrd_start = (void *)__va (start); - initrd_end = (void *)__va (end); - initrd_below_start_ok =1 ; -} -#endif /* CONFIG_OF */ #endif /* CONFIG_BLK_DEV_INITRD */
drivers/of/fdt.c +6 -3
@@ -624,7 +624,7 @@ int __init of_scan_flat_dt_by_path(const char *path,* 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) +static void __init early_init_dt_check_for_initrd (unsigned long node) {u64 start, end;unsigned long len;
@@ -642,12 +642,15 @@ void __init early_init_dt_check_for_initrd(unsigned long node)return ; end =of_read_number (prop, len/4 ); -early_init_dt_setup_initrd_arch (start, end); + initrd_start = (unsigned long )__va (start); + initrd_end = (unsigned long )__va (end); + initrd_below_start_ok =1 ; +pr_debug ("initrd_start=0x%llx initrd_end=0x%llx\n" , (unsigned long long)start, (unsigned long long)end); }#else -inline void early_init_dt_check_for_initrd (unsigned long node) +static inline void early_init_dt_check_for_initrd (unsigned long node) { }#endif /* CONFIG_BLK_DEV_INITRD */
include/linux/of_fdt.h +0 -10
@@ -96,22 +96,12 @@ extern int of_scan_flat_dt_by_path(const char *path,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_memory (unsigned long node,const char *uname,int depth,void *data);extern void early_init_dt_add_memory_arch (u64 base,u64 size);extern void *early_init_dt_alloc_memory_arch (u64 size,u64 align);extern u64 dt_mem_next_cell (int s,__be32 **cellp); -/* -* If BLK_DEV_INITRD, the fdt early init code will call this function, -* to be provided by the arch code. start and end are specified as -* physical addresses. -*/ -#ifdef CONFIG_BLK_DEV_INITRD -extern void early_init_dt_setup_initrd_arch (u64 start,u64 end); -#endif -/* Early flat tree scan hooks */ extern int early_init_dt_scan_root (unsigned long node,const char *uname,int depth,void *data);
Signature · 1 line
1.8.1.2
Re: [PATCH 21/28] of: remove early_init_dt_setup_initrd_arch
Quoted 7 lines · Rob Herring
From: Rob Herring <[email protected]>
All arches do essentially the same thing now for
early_init_dt_setup_initrd_arch, so it can now be removed.Signed-off-by Rob Herring <[email protected]>Cc Vineet Gupta <[email protected]>
-Vineet
Re: [PATCH 21/28] of: remove early_init_dt_setup_initrd_arch
In reply to Rob HerringQuoted 6 lines · Rob Herring
From: Rob Herring <[email protected]>
All arches do essentially the same thing now for
early_init_dt_setup_initrd_arch, so it can now be removed.Signed-off-by Rob Herring <[email protected]>
PATCH 22/28 openrisc: remove unnecessary prom.c includes
In reply to Rob HerringFrom: Rob Herring <[email protected]>
It appears openrisc prom.c was just copied from another arch with a bunch of unnecessary includes. Remove all the unecessary ones.
--- arch/openrisc/kernel/prom.c | 22 ---------------------- 1 file changed, 22 deletions(-)
arch/openrisc/kernel/prom.c +0 -22
@@ -18,34 +18,12 @@* */ -#include <stdarg.h> -#include <linux/kernel.h> -#include <linux/string.h> #include <linux/init.h> -#include <linux/threads.h> -#include <linux/spinlock.h> #include <linux/types.h> -#include <linux/pci.h> -#include <linux/stringify.h> -#include <linux/delay.h> -#include <linux/initrd.h> -#include <linux/bitops.h> -#include <linux/module.h> -#include <linux/kexec.h> -#include <linux/debugfs.h> -#include <linux/irq.h> #include <linux/memblock.h> #include <linux/of_fdt.h> -#include <asm/prom.h> #include <asm/page.h> -#include <asm/processor.h> -#include <asm/irq.h> -#include <linux/io.h> -#include <asm/mmu.h> -#include <asm/pgtable.h> -#include <asm/sections.h> -#include <asm/setup.h> void __init early_init_devtree (void *params) {
Signature · 1 line
1.8.1.2
PATCH 23/28 of: introduce common FDT machine related functions
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Introduce common of_flat_dt_match_machine and of_flat_dt_get_machine_name functions to unify architectures' handling of machine level model and compatible properties.
Several architectures match the root compatible string with an arch specific list of machine descriptors duplicating the same search algorithm. Create a common implementation with a simple architecture specific hook to iterate over each machine's match table.
--- drivers/of/fdt.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/of_fdt.h | 4 ++++ 2 files changed, 64 insertions(+)
drivers/of/fdt.c +60 -0
@@ -619,6 +619,66 @@ int __init of_scan_flat_dt_by_path(const char *path,return ret; } +const char *of_flat_dt_get_machine_name (void ) +{ +const char *name; +unsigned long dt_root =of_get_flat_dt_root (); + + name =of_get_flat_dt_prop (dt_root,"model" ,NULL ); +if (!name) + name =of_get_flat_dt_prop (dt_root,"compatible" ,NULL ); +return name; +} + +/** +* of_flat_dt_match_machine - Iterate match tables to find matching machine. +* +* @default_match: A machine specific ptr to return in case of no match. +* @get_next_compat: callback function to return next compatible match table. +* +* Iterate through machine match tables to find the best match for the machine +* compatible string in the FDT. +*/ +void *__init of_flat_dt_match_machine (void *default_match, +void * (*get_next_compat)(const char *const **)) +{ +void *data =NULL ; +void *best_data = default_match; +const char *const *compat; +unsigned long dt_root; +unsigned int best_score = ~1 , score =0 ; + + dt_root =of_get_flat_dt_root (); +while ((data =get_next_compat (&compat))) { + score =of_flat_dt_match (dt_root, compat); +if (score >0 && score < best_score) { + best_data = data; + best_score = score; + } + } +if (!best_data) { +const char *prop; +long size; + +pr_err ("\n unrecognized device tree list:\n[ " ); + + prop =of_get_flat_dt_prop (dt_root,"compatible" , &size); +if (prop) { +while (size >0 ) { +printk ("'%s' " , prop); + size -=strlen (prop) +1 ; + prop +=strlen (prop) +1 ; + } + } +printk ("]\n\n" ); +return NULL ; + } + +pr_info ("Machine model: %s\n" ,of_flat_dt_get_machine_name ()); + +return best_data; +} +#ifdef CONFIG_BLK_DEV_INITRD /** * early_init_dt_check_for_initrd - Decode initrd location from flat tree
include/linux/of_fdt.h +4 -0
@@ -108,6 +108,10 @@ extern int early_init_dt_scan_root(unsigned long node, const char *uname,extern bool early_init_dt_scan (void *params); +const char *of_flat_dt_get_machine_name (void ); +extern void *of_flat_dt_match_machine (void *default_match, +void * (*get_next_compat)(const char *const **)); +/* Other Prototypes */ extern void unflatten_device_tree (void );extern void unflatten_and_copy_device_tree (void );
Signature · 1 line
1.8.1.2
Re: [PATCH 23/28] of: introduce common FDT machine related functions
Quoted 6 lines · Rob Herring
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Introduce common
of_flat_dt_match_machineandof_flat_dt_get_machine_namefunctions to unify architectures' handling of machine level model and compatible properties.
Quoted 7 lines
Several architectures match the root compatible string with an arch specific list of machine descriptors duplicating the same search algorithm. Create a common implementation with a simple architecture specific hook to iterate over each machine's match table.
Signed-off-by Rob Herring <rob.herring-bsGFqQB8/[email protected]>Cc Grant Likely <[email protected]>
Nice!
Thanks for doing this whole series. It's some really good improvements.
g.
--
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
Re: [PATCH 23/28] of: introduce common FDT machine related functions
In reply to Rob HerringQuoted 23 lines · Rob Herring
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Introduce common
of_flat_dt_match_machineandof_flat_dt_get_machine_namefunctions to unify architectures' handling of machine level model and compatible properties.Several architectures match the root compatible string with an arch specific list of machine descriptors duplicating the same search algorithm. Create a common implementation with a simple architecture specific hook to iterate over each machine's match table.
Signed-off-by Rob Herring <rob.herring-bsGFqQB8/[email protected]>Cc Grant Likely <[email protected]>--- drivers/of/fdt.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/of_fdt.h | 4 ++++ 2 files changed, 64 insertions(+)drivers/of/fdt.c +0
-0
drivers/of/fdt.c int __init of_scan_flat_dt_by_path(const char *path, · line 622
Quoted 4 lines
drivers/of/fdt.c +1
-0@@ -619,6 +619,66 @@ int __init of_scan_flat_dt_by_path(const char *path,return ret; } +const char *of_flat_dt_get_machine_name (void )
Just discovered that this needs to be __init.
g.
--
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
PATCH 24/28 arc: use common of_flat_dt_match_machine
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Convert arc to use the common of_flat_dt_match_machine function.
--- arch/arc/kernel/devtree.c | 65 +++++++++++++---------------------------------- 1 file changed, 18 insertions(+), 47 deletions(-)
arch/arc/kernel/devtree.c +18 -47
@@ -18,6 +18,19 @@#include <asm/clk.h> #include <asm/mach_desc.h> +static void *__init arch_get_next_mach (const char *const **match) +{ +static struct machine_desc *mdesc = __arch_info_begin; +struct machine_desc *m = mdesc; + +if (m >= __arch_info_end) +return NULL ; + + mdesc++; + *match = m->dt_compat; +return m; +} +/** * setup_machine_fdt - Machine setup when an dtb was passed to the kernel * @dt: virtual address pointer to dt blob
@@ -27,64 +40,22 @@*/ struct machine_desc *__init setup_machine_fdt (void *dt) { -struct machine_desc *mdesc =NULL , *mdesc_best =NULL ; -unsigned int score, mdesc_score = ~1 ; +struct machine_desc *mdesc;unsigned long dt_root; -const char *model, *compat;void *clk; -char manufacturer[16 ];unsigned long len;if (!early_init_dt_scan (dt))return NULL ; - dt_root =of_get_flat_dt_root (); - -/* -* The kernel could be multi-platform enabled, thus could have many -* "baked-in" machine descriptors. Search thru all for the best -* "compatible" string match. -*/ -for_each_machine_desc (mdesc) { - score =of_flat_dt_match (dt_root, mdesc->dt_compat); -if (score >0 && score < mdesc_score) { - mdesc_best = mdesc; - mdesc_score = score; - } - } -if (!mdesc_best) { -const char *prop; -long size; - -pr_err ("\n unrecognized device tree list:\n[ " ); - - prop =of_get_flat_dt_prop (dt_root,"compatible" , &size); -if (prop) { -while (size >0 ) { -printk ("'%s' " , prop); - size -=strlen (prop) +1 ; - prop +=strlen (prop) +1 ; - } - } -printk ("]\n\n" ); - + mdesc =of_flat_dt_match_machine (NULL , arch_get_next_mach); +if (!mdesc)machine_halt (); - } - -/* compat = "<manufacturer>,<model>" */ - compat = mdesc_best->dt_compat[0 ]; - - model =strchr (compat,',' ); -if (model) - model++; - -strlcpy (manufacturer, compat, model ? model - compat :strlen (compat)); - -pr_info ("Board \"%s\" from %s (Manufacturer)\n" , model, manufacturer); + dt_root =of_get_flat_dt_root (); clk =of_get_flat_dt_prop (dt_root,"clock-frequency" , &len);if (clk)arc_set_core_freq (of_read_ulong (clk, len/4 )); -return mdesc_best; +return mdesc; }
Signature · 1 line
1.8.1.2
Re: [PATCH 24/28] arc: use common of_flat_dt_match_machine
Quoted 6 lines · Rob Herring
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Convert arc to use the common
of_flat_dt_match_machinefunction.Signed-off-by Rob Herring <rob.herring-bsGFqQB8/[email protected]>Cc Vineet Gupta <vgupta-HKixBCOQz3hWk0Htik3J/[email protected]>
Thx for the series.
-Vineet
--
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
PATCH 25/28 arm: use common of_flat_dt_match_machine
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Convert arm to use the common of_flat_dt_match_machine function.
--- arch/arm/kernel/devtree.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-)
arch/arm/kernel/devtree.c +20 -22
@@ -174,6 +174,19 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id)return (phys_id &MPIDR_HWID_BITMASK ) ==cpu_logical_map (cpu); } +static void *__init arch_get_next_mach (const char *const **match) +{ +static struct machine_desc *mdesc = __arch_info_begin; +struct machine_desc *m = mdesc; + +if (m >= __arch_info_end) +return NULL ; + + mdesc++; + *match = m->dt_compat; +return m; +} +/** * setup_machine_fdt - Machine setup when an dtb was passed to the kernel * @dt_phys: physical address of dt blob
@@ -184,9 +197,6 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id)const struct machine_desc *__init setup_machine_fdt (unsigned int dt_phys) {const struct machine_desc *mdesc, *mdesc_best =NULL ; -unsigned int score, mdesc_score = ~1 ; -unsigned long dt_root; -const char *model;#ifdef CONFIG_ARCH_MULTIPLATFORM DT_MACHINE_START (GENERIC_DT ,"Generic DT based system" )
@@ -199,23 +209,17 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)return NULL ;early_init_dt_scan (phys_to_virt (dt_phys)); + mdesc =of_flat_dt_match_machine (mdesc_best, arch_get_next_mach); -/* Search the mdescs for the 'best' compatible value match */ - dt_root =of_get_flat_dt_root (); -for_each_machine_desc (mdesc) { - score =of_flat_dt_match (dt_root, mdesc->dt_compat); -if (score >0 && score < mdesc_score) { - mdesc_best = mdesc; - mdesc_score = score; - } - } -if (!mdesc_best) { +if (!mdesc) {const char *prop;long size; +unsigned long dt_root;early_print ("\nError: unrecognized/unsupported " "device tree compatible list:\n[ " ); + dt_root =of_get_flat_dt_root (); prop =of_get_flat_dt_prop (dt_root,"compatible" , &size);while (size >0 ) {early_print ("'%s' " , prop);
@@ -226,16 +230,10 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)dump_machine_table ();/* does not return */ } - - model =of_get_flat_dt_prop (dt_root,"model" ,NULL ); -if (!model) - model =of_get_flat_dt_prop (dt_root,"compatible" ,NULL ); -if (!model) - model ="<unknown>" ; -pr_info ("Machine: %s, model: %s\n" , mdesc_best->name, model); +early_print ("matched mach %s\n" , mdesc->name);/* Change machine number to match the mdesc we're using */ - __machine_arch_type = mdesc_best->nr; + __machine_arch_type = mdesc->nr; -return mdesc_best; +return mdesc; }
Signature · 1 line
1.8.1.2
PATCH 26/28 arm64: use common of_flat_dt_get_machine_name
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Convert arm64 to use the common of_flat_dt_get_machine_name function.
--- arch/arm64/kernel/setup.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
arch/arm64/kernel/setup.c +1 -10
@@ -124,8 +124,6 @@ static void __init setup_processor(void)static void __init setup_machine_fdt (phys_addr_t dt_phys) { -unsigned long dt_root; -if (!dt_phys || !early_init_dt_scan (phys_to_virt (dt_phys))) {early_print ("\n" "Error: invalid device tree blob at physical address 0x%p (virtual address 0x%p)\n"
@@ -137,14 +135,7 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)cpu_relax (); } - dt_root =of_get_flat_dt_root (); - - machine_name =of_get_flat_dt_prop (dt_root,"model" ,NULL ); -if (!machine_name) - machine_name =of_get_flat_dt_prop (dt_root,"compatible" ,NULL ); -if (!machine_name) - machine_name ="<unknown>" ; -pr_info ("Machine: %s\n" , machine_name); + machine_name =of_flat_dt_get_machine_name (); }/*
Signature · 1 line
1.8.1.2
Re: [PATCH 26/28] arm64: use common of_flat_dt_get_machine_name
Quoted 8 lines · Rob Herring
From: Rob Herring <[email protected]>
Convert arm64 to use the common
of_flat_dt_get_machine_namefunction.Signed-off-by Rob Herring <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc linux-arm-kernel at lists.infradead.org
PATCH 27/28 metag: use common of_flat_dt_match_machine
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Convert metag to use the common of_flat_dt_get_machine_name function.
--- arch/metag/kernel/devtree.c | 67 ++++++++++++--------------------------------- 1 file changed, 18 insertions(+), 49 deletions(-)
arch/metag/kernel/devtree.c +18 -49
@@ -28,6 +28,19 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)return alloc_bootmem_align (size, align); } +static void *__init arch_get_next_mach (const char *const **match) +{ +static struct machine_desc *mdesc = __arch_info_begin; +struct machine_desc *m = mdesc; + +if (m >= __arch_info_end) +return NULL ; + + mdesc++; + *match = m->dt_compat; +return m; +} +/** * setup_machine_fdt - Machine setup when an dtb was passed to the kernel * @dt: virtual address pointer to dt blob
@@ -37,56 +50,12 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)*/ struct machine_desc *__init setup_machine_fdt (void *dt) { -struct boot_param_header *devtree = dt; -struct machine_desc *mdesc, *mdesc_best =NULL ; -unsigned int score, mdesc_score = ~1 ; -unsigned long dt_root; -const char *model; - -/* check device tree validity */ -if (be32_to_cpu (devtree->magic) !=OF_DT_HEADER ) -return NULL ; - -/* Search the mdescs for the 'best' compatible value match */ - initial_boot_params = devtree; - dt_root =of_get_flat_dt_root (); - -for_each_machine_desc (mdesc) { - score =of_flat_dt_match (dt_root, mdesc->dt_compat); -if (score >0 && score < mdesc_score) { - mdesc_best = mdesc; - mdesc_score = score; - } - } -if (!mdesc_best) { -const char *prop; -long size; - -pr_err ("\nError: unrecognized/unsupported device tree compatible list:\n[ " ); - - prop =of_get_flat_dt_prop (dt_root,"compatible" , &size); -if (prop) { -while (size >0 ) { -printk ("'%s' " , prop); - size -=strlen (prop) +1 ; - prop +=strlen (prop) +1 ; - } - } -printk ("]\n\n" ); +struct machine_desc *mdesc; +early_init_dt_scan (dt); + mdesc =of_flat_dt_match_machine (NULL , arch_get_next_mach); +if (!mdesc)dump_machine_table ();/* does not return */ - } - - model =of_get_flat_dt_prop (dt_root,"model" ,NULL ); -if (!model) - model =of_get_flat_dt_prop (dt_root,"compatible" ,NULL ); -if (!model) - model ="<unknown>" ; -pr_info ("Machine: %s, model: %s\n" , mdesc_best->name, model); - -/* Retrieve various information from the /chosen node */ -of_scan_flat_dt (early_init_dt_scan_chosen, boot_command_line); - -return mdesc_best; +return mdesc; }
Signature · 1 line
1.8.1.2
PATCH 28/28 mips: use common of_flat_dt_get_machine_name
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Convert mips to use the common of_flat_dt_get_machine_name function.
--- arch/mips/kernel/prom.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
arch/mips/kernel/prom.c +1 -14
@@ -47,24 +47,11 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS)); } -int __init early_init_dt_scan_model (unsigned long node,const char *uname, -int depth,void *data) -{ -if (!depth) { -char *model =of_get_flat_dt_prop (node,"model" ,NULL ); - -if (model) -mips_set_machine_name (model); - } -return 0 ; -} -void __init __dt_setup_arch (struct boot_param_header *bph) {if (!early_init_dt_scan (bph))return ; -/* try to load the mips machine name */ -of_scan_flat_dt (early_init_dt_scan_model,NULL ); +mips_set_machine_name (of_flat_dt_get_machine_name ()); }#endif
Signature · 1 line
1.8.1.2
Re: [PATCH 28/28] mips: use common of_flat_dt_get_machine_name
Quoted 8 lines · Rob Herring
From: Rob Herring<rob.herring-bsGFqQB8/[email protected]>
Convert mips to use the common
of_flat_dt_get_machine_namefunction.Signed-off-by Rob Herring<rob.herring-bsGFqQB8/[email protected]>Cc Ralf Baechle<ralf-6z/[email protected]>Cc linux-mips-6z/[email protected]---
Thanks for this series ...
Quoted 23 lines
arch/mips/kernel/prom.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)arch/mips/kernel/prom.c +0
-12@@ -47,24 +47,11 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)return __alloc_bootmem (size, align,__pa (MAX_DMA_ADDRESS )); } -int __init early_init_dt_scan_model (unsigned long node,const char *uname, -int depth,void *data) -{ -if (!depth) { -char *model =of_get_flat_dt_prop (node,"model" ,NULL ); - -if (model) -mips_set_machine_name (model); - } -return 0 ; -} -
arch/mips/kernel/prom.c void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) · line 57
Quoted 10 lines
arch/mips/kernel/prom.c +1
-2void __init __dt_setup_arch (struct boot_param_header *bph) {if (!early_init_dt_scan (bph))return ; -/* try to load the mips machine name */ -of_scan_flat_dt (early_init_dt_scan_model,NULL ); +mips_set_machine_name (of_flat_dt_get_machine_name ()); }#endif
--
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 8 lines · Rob Herring
From: Rob Herring <[email protected]>
This is the first of 2 series to do some consolidation of per architecture Device Tree code. We now have 12 architectures with DT support. As new architectures have been added, much of the DT related code for the early flattened DT scanning has been duplicated. Yet little of this code is architecture specific. This series has 4 main parts:
Quoted 7 lines
- Create a common function to copy built-in dtb's out of init section
- Create a single, common function to scan the FDT
- Removal ofearly_init_dt_setup_initrd_arch
- Create common functions for machine matching with DTThe entire series is available here:
git://sources.calxeda.com/kernel/linux.gitdt-cleanup
Hi Rob,
I gave this branch a try on metag.
The following patches break the build:e09b397e of: only include prom.h on sparc740de19c of: remove empty arch prom.h headers
because metag's prom.h has a setup_machine_fdt function declaration which is used in arch/metag/kernel/setup.c (and defined in arch/metag/kernel/devtree.c). Please move that declaration elsewhere (asm/setup.h would seem appropriate) if you're going to remove prom.h.
Also I appear to hit the BUG_ON at
drivers/of/fdt.c:511/of_get_flat_dt_root().
This is because on metag we try interpreting the command line argument as a device tree and only use the built-in DT if that fails. Previously we relied on the be32_to_cpu(devtree->magic) != OF_DT_HEADER check in setup_machine_fdt. The following seems to fix it:
arch/metag/kernel/devtree.c +4 -1
@@ -52,7 +52,10 @@ struct machine_desc * __init setup_machine_fdt(void *dt) {struct machine_desc *mdesc; -early_init_dt_scan (dt); +/* check device tree validity */ +if (!early_init_dt_scan (dt)) +return NULL ; + mdesc =of_flat_dt_match_machine (NULL , arch_get_next_mach);if (!mdesc)dump_machine_table ();/* does not return */
Cheers
James
Quoted 63 lines
Compiled on arm, arm64, microblaze, mips, openrisc, powerpc, sparc, xtensa.
Rob
Rob Herring (28):
c6x: useboot_command_lineinstead of privatec6x_command_line
openrisc: useboot_command_lineinstead of privatecmd_line
of: createunflatten_and_copy_device_tree
arc: useunflatten_and_copy_device_tree
openrisc: useunflatten_and_copy_device_tree
x86: useunflatten_and_copy_device_tree
xtensa: useunflatten_and_copy_device_tree
metag: useunflatten_and_copy_device_tree
of: Introduce commonearly_init_dt_scan
arc: useearly_init_dt_scan
arm: useearly_init_dt_scan
arm64: useearly_init_dt_scan
c6x: useearly_init_dt_scan
microblaze: useearly_init_dt_scan
mips: useearly_init_dt_scan
openrisc: useearly_init_dt_scan
xtensa: useearly_init_dt_scan
of: create defaultearly_init_dt_add_memory_arch
arm: set initrd_start/initrd_end for fdt scan
arm64: set initrd_start/initrd_end for fdt scan
of: removeearly_init_dt_setup_initrd_arch
openrisc: remove unnecessaryprom.cincludes
of: introduce common FDT machine related functions
arc: use commonof_flat_dt_match_machine
arm: use commonof_flat_dt_match_machine
arm64: use commonof_flat_dt_get_machine_name
metag: use commonof_flat_dt_match_machine
mips: use commonof_flat_dt_get_machine_namearch/arc/include/asm/mach_desc.h | 1 - arch/arc/kernel/devtree.c | 94 +++++++-------------------------- arch/arc/kernel/setup.c | 3 +- arch/arc/mm/init.c | 7 --- arch/arm/kernel/devtree.c | 57 ++++++++------------ arch/arm/mm/init.c | 13 ++--- arch/arm64/kernel/setup.c | 60 ++------------------- arch/arm64/mm/init.c | 24 +++------ arch/c6x/include/asm/setup.h | 2 - arch/c6x/kernel/devicetree.c | 29 ---------- arch/c6x/kernel/setup.c | 13 +---- arch/metag/kernel/devtree.c | 87 ++++++------------------------ arch/metag/kernel/setup.c | 4 +- arch/metag/mm/init.c | 9 ---- arch/microblaze/kernel/prom.c | 31 ++--------- arch/microblaze/kernel/setup.c | 2 +- arch/mips/include/asm/prom.h | 3 -- arch/mips/kernel/prom.c | 60 +-------------------- arch/openrisc/kernel/prom.c | 70 +----------------------- arch/openrisc/kernel/setup.c | 6 +-- arch/powerpc/kernel/prom.c | 9 ---- arch/x86/kernel/devicetree.c | 42 +++------------ arch/xtensa/kernel/setup.c | 55 +++++-------------- drivers/of/fdt.c | 111 +++++++++++++++++++++++++++++++++++++-- include/linux/of_fdt.h | 18 +++---- 25 files changed, 223 insertions(+), 587 deletions(-)