Early flattened DT init consolidation
Subsystems (10)
v2 cover Early flattened DT init consolidation
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:
- 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 with prom.h clean-up series is available here:git://sources.calxeda.com/kernel/linux.git dt-cleanup
Compiled on arm, arm64, microblaze, mips, openrisc, powerpc, sparc, xtensa.
Version 1 of this series is here:
http://www.spinics.net/lists/devicetree/msg04865.html
The prom.h clean-up series is here:
http://www.spinics.net/lists/devicetree/msg06175.html
Changes in v2:
- Rebase to v3.12-rc3
- add arm64 sanity checks to default early_init_dt_add_memory_arch
- drop x86 and metag from common early_init_dt_add_memory_arch
- move metag early_init_dt_scan support to separate patch
- metag fixes from James Hogan
- Add NULL checks in early_init_dt_scan
- Document proper use of unflatten_and_copy_device_tree
- fix section mismatches with of_flat_dt_get_machine_name
- fix non-DT boot on ARM
Rob
Rob Herring (29):
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
metag: 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 | 58 ++++++---------- 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/c6x/kernel/vmlinux.lds.S | 6 -- arch/metag/include/asm/mach/arch.h | 2 +- arch/metag/include/asm/prom.h | 2 +- arch/metag/kernel/devtree.c | 83 ++++++---------------- arch/metag/kernel/setup.c | 6 +- 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 | 32 +++------ arch/xtensa/kernel/setup.c | 55 ++++----------- drivers/of/fdt.c | 138 ++++++++++++++++++++++++++++++++++++- include/linux/of_fdt.h | 18 +++-- 28 files changed, 256 insertions(+), 580 deletions(-)
Signature · 1 line
1.8.1.2
PATCH v2 1/29 c6x: use boot_command_line instead of private c6x_command_line
From: Rob Herring <rob.herring-bsGFqQB8/[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 +---------- arch/c6x/kernel/vmlinux.lds.S | 6 ------ 4 files changed, 2 insertions(+), 19 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 );
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
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 v2 01/29] c6x: use boot_command_line instead of private c6x_command_line
Quoted 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.
Quoted 6 lines
Signed-off-by Rob Herring <[email protected]>Cc Mark Salter <[email protected]>Cc Aurelien Jacquiot <[email protected]>Reviewed-by Grant Likely <[email protected]>---
Tested and
PATCH v2 2/29 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 v2 3/29 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 | 24 ++++++++++++++++++++++++ include/linux/of_fdt.h | 2 ++ 2 files changed, 26 insertions(+)
drivers/of/fdt.c +24 -0
@@ -802,6 +802,30 @@ void __init unflatten_device_tree(void) of_alias_scan(early_init_dt_alloc_memory_arch); } +/** +* unflatten_and_copy_device_tree - copy and create tree of device_nodes from flat blob +* +* Copies and unflattens the device-tree passed by the firmware, creating the +* tree of struct device_node. It also fills the "name" and "type" +* pointers of the nodes so the normal device-tree walking functions +* can be used. This should only be used when the FDT memory has not been +* reserved such is the case when the FDT is built-in to the kernel init +* section. If the FDT memory is reserved already then unflatten_device_tree +* should be used instead. +*/ +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
PATCH v2 4/29 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
PATCH v2 5/29 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 v2 6/29 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 v2 7/29 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
PATCH v2 8/29 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
Re: [PATCH v2 08/29] metag: use unflatten_and_copy_device_tree
should remove extern void copy_fdt(void) declaration from prom.h too as you removed the definition and the only user.
Re: [PATCH v2 08/29] metag: use unflatten_and_copy_device_tree
In reply to Rob HerringQuoted 7 lines · Rob Herring
From: Rob Herring <[email protected]>
Use the common
unflatten_and_copy_device_treeto copy the built-in FDT out of init section.Signed-off-by Rob Herring <[email protected]>Cc James Hogan <[email protected]>
With Qais' suggestion of removing the extern void copy_fdt(void) from arch/metag/include/asm/prom.h (thanks Qais):
Cheers
James
Quoted 47 lines
--- 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 ();
Re: [PATCH v2 08/29] metag: use unflatten_and_copy_device_tree
Quoted 6 lines · James Hogan
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 6 lines
Quoted 2 lines
Signed-off-by Rob Herring <rob.herring-bsGFqQB8/[email protected]>Cc James Hogan <[email protected]>With Qais' suggestion of removing the extern void
copy_fdt(void)fromarch/metag/include/asm/prom.h(thanks Qais):Acked-by James Hogan <[email protected]>
Look at the second series with the prom.h clean-up. prom.h is removed from metag altogether now.
Rob
--
To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 08/29] metag: use unflatten_and_copy_device_tree
Quoted 10 lines · Rob Herring
Quoted 9 lines · James Hogan
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 James Hogan <[email protected]>
Quoted 6 lines
Quoted 3 lines
With Qais' suggestion of removing the extern void
copy_fdt(void)fromarch/metag/include/asm/prom.h(thanks Qais):Acked-by James Hogan <[email protected]>Look at the second series with the
prom.hclean-up.prom.his removed from metag altogether now.
Ah yes. It should technically be removed in this patch, but since prom.h is going away anyway it doesn't particularly bother me.
Thanks
James
--
To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 9/29 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 | 26 ++++++++++++++++++++++++++ include/linux/of_fdt.h | 2 ++ 2 files changed, 28 insertions(+)
drivers/of/fdt.c +26 -0
@@ -785,6 +785,32 @@ void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align) }#endif +bool __init early_init_dt_scan (void *params) +{ +if (!params) +return false; + +/* Setup flat device-tree pointer */ + initial_boot_params = params; + +/* check device tree validity */ +if (be32_to_cpu (initial_boot_params->magic) !=OF_DT_HEADER ) { + initial_boot_params =NULL ; +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
PATCH v2 10/29 arc: use early_init_dt_scan
In reply to Rob HerringFrom: Rob Herring <rob.herring-bsGFqQB8/[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 · 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 v2 11/29 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 | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
arch/arm/kernel/devtree.c +1 -15
@@ -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;
@@ -196,17 +195,11 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) mdesc_best = &__mach_desc_GENERIC_DT;#endif -if (!dt_phys) +if (!dt_phys || !early_init_dt_scan (phys_to_virt (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 ;/* 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 +233,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 v2 12/29 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
PATCH v2 13/29 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
PATCH v2 14/29 metag: use early_init_dt_scan
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Convert metag to use new early_init_dt_scan function.
--- arch/metag/kernel/devtree.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
arch/metag/kernel/devtree.c +1 -6
@@ -43,18 +43,16 @@ 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 ) +if (!early_init_dt_scan (dt))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) {
@@ -90,9 +88,6 @@ struct machine_desc * __init setup_machine_fdt(void *dt) 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; }
Signature · 1 line
1.8.1.2
Re: [PATCH v2 14/29] metag: use early_init_dt_scan
Quoted 6 lines · Rob Herring
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Convert metag to use new
early_init_dt_scanfunction.Signed-off-by Rob Herring <rob.herring-bsGFqQB8/[email protected]>Cc James Hogan <[email protected]>
Cheers
James
Quoted 30 lines
--- arch/metag/kernel/devtree.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)arch/metag/kernel/devtree.c +1
-3@@ -43,18 +43,16 @@ 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 ) +if (!early_init_dt_scan (dt))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) {
arch/metag/kernel/devtree.c struct machine_desc * __init setup_machine_fdt(void *dt) · line 93
Quoted 9 lines
arch/metag/kernel/devtree.c +0
-3@@ -90,9 +88,6 @@ struct machine_desc * __init setup_machine_fdt(void *dt) 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; }
--
To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 15/29 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
PATCH v2 16/29 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
PATCH v2 17/29 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 v2 18/29 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
PATCH v2 19/29 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. This will unify all architectures except ones with custom memory bank structs.
--- arch/arm64/kernel/setup.c | 18 ------------------ arch/microblaze/kernel/prom.c | 5 ----- arch/openrisc/kernel/prom.c | 6 ------ drivers/of/fdt.c | 19 +++++++++++++++++++ 4 files changed, 19 insertions(+), 29 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/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);
drivers/of/fdt.c +19 -0
@@ -775,6 +775,25 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, }#ifdef CONFIG_HAVE_MEMBLOCK +void __init __weak early_init_dt_add_memory_arch (u64 base,u64 size) +{ +const u64 phys_offset =__pa (PAGE_OFFSET ); + 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); +} +/* * called from unflatten_device_tree() to bootstrap devicetree itself * Architectures can override this definition if memblock isn't used
Signature · 1 line
1.8.1.2
Re: [PATCH v2 19/29] of: create default early_init_dt_add_memory_arch
Quoted 6 lines · Rob Herring
From: Rob Herring <[email protected]>
Create a weak version of
early_init_dt_add_memory_archwhich uses memblock. This will unify all architectures except ones with custom memory bank structs.
Quoted 10 lines
Signed-off-by Rob Herring <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Michal Simek <[email protected]>Cc Jonas Bonn <[email protected]>Acked-by Grant Likely <[email protected]>Cc linux-arm-kernel at lists.infradead.orgCc microblaze-uclinux at itee.uq.edu.auCc linux at lists.openrisc.netCc devicetree at vger.kernel.org
PATCH v2 20/29 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
PATCH v2 21/29 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
PATCH v2 22/29 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
@@ -51,15 +51,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 v2 22/29] of: remove early_init_dt_setup_initrd_arch
Quoted 15 lines · Rob Herring
From: Rob Herring <rob.herring-bsGFqQB8/[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 <rob.herring-bsGFqQB8/[email protected]>Cc Russell King <linux-lFZ/[email protected]>Cc Mark Salter <[email protected]>Cc Aurelien Jacquiot <[email protected]>Cc James Hogan <[email protected]>Cc Michal Simek <[email protected]>Cc Ralf Baechle <ralf-6z/[email protected]>Cc Jonas Bonn <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>
Quoted 8 lines
Cc Paul Mackerras <[email protected]>Cc Thomas Gleixner <[email protected]>Cc Ingo Molnar <[email protected]>Cc "H. Peter Anvin" <[email protected]>Cc Chris Zankel <[email protected]>Cc Max Filippov <[email protected]>Acked-by Grant Likely <[email protected]>
Cheers
James
Quoted 290 lines
--- 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@@ -51,15 +51,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
-3@@ -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,
include/linux/of_fdt.h extern int of_scan_flat_dt_by_path(const char *path, · line 107
Quoted 10 lines
include/linux/of_fdt.h +0
-7-* 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);
--
To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 23/29 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 v2 24/29 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 *__init 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. +*/ +const void *__init of_flat_dt_match_machine (const void *default_match, +const void * (*get_next_compat)(const char *const **)) +{ +const void *data =NULL ; +const 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); +extern const char *of_flat_dt_get_machine_name (void ); +extern const void *of_flat_dt_match_machine (const void *default_match, +const 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
PATCH v2 25/29 arc: use common of_flat_dt_match_machine
In reply to Rob HerringFrom: Rob Herring <rob.herring-bsGFqQB8/[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 const void *__init arch_get_next_mach (const char *const **match) +{ +static const struct machine_desc *mdesc = __arch_info_begin; +const 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 · 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 v2 25/29] arc: use common of_flat_dt_match_machine
Hi Rob,
Quoted 95 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]>--- arch/arc/kernel/devtree.c | 65 +++++++++++++---------------------------------- 1 file changed, 18 insertions(+), 47 deletions(-)arch/arc/kernel/devtree.c +16
-45@@ -18,6 +18,19 @@#include <asm/clk.h> #include <asm/mach_desc.h> +static const void *__init arch_get_next_mach (const char *const **match) +{ +static const struct machine_desc *mdesc = __arch_info_begin; +const 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)); -
arch/arc/kernel/devtree.c line 61
Quoted 10 lines
arch/arc/kernel/devtree.c +2
-2-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; }
Can you please fold the following into this patch. This removes the const warning and also gets rid of some dead code.
Thx,
-Vineet
------------------->
Quoted 1 line
From
3cd48b4955e9763248e306fff7ddf420b126ebabMon Sep 17 00:00:00 2001
From: Vineet Gupta <vgupta-HKixBCOQz3hWk0Htik3J/[email protected]>
Date: Tue, 8 Oct 2013 09:53:17 +0530
Subject: [PATCH] ARC: Addendum to "use common of_flat_dt_match_machine"
--- arch/arc/include/asm/mach_desc.h | 14 ++------------ arch/arc/kernel/devtree.c | 4 ++-- arch/arc/kernel/setup.c | 2 +- 3 files changed, 5 insertions(+), 15 deletions(-)
arch/arc/include/asm/mach_desc.h +2 -12
@@ -51,22 +51,12 @@ struct machine_desc {/* * Current machine - only accessible during boot. */ -extern struct machine_desc *machine_desc; +extern const struct machine_desc *machine_desc;/* * Machine type table - also only accessible during boot */ extern struct machine_desc __arch_info_begin[], __arch_info_end[]; -#define for_each_machine_desc (p) \ - for (p = __arch_info_begin; p < __arch_info_end; p++) - -static inline struct machine_desc *default_machine_desc (void ) -{ -/* the default machine is the last one linked in */ -if (__arch_info_end -1 < __arch_info_begin) -return NULL ; -return __arch_info_end -1 ; -}/* * Set of macros to define architecture features.
@@ -81,6 +71,6 @@ __attribute__((__section__(".arch.info.init"))) = { \#define MACHINE_END \ }; -extern struct machine_desc *setup_machine_fdt (void *dt); +extern const struct machine_desc *setup_machine_fdt (void *dt);#endif
arch/arc/kernel/devtree.c +0 -0
@@ -37,9 +37,9 @@ static const void * __init arch_get_next_mach(const char *const
**match)
* If a dtb was passed to the kernel, then use it to choose the correct
* machine_desc and to setup the system.
*/
-struct machine_desc * __init setup_machine_fdt(void *dt) +const struct machine_desc * __init setup_machine_fdt(void *dt)
{
- struct machine_desc *mdesc;
+ const struct machine_desc *mdesc;
unsigned long dt_root;
void *clk;
unsigned long len;arch/arc/kernel/setup.c +1 -1
@@ -30,7 +30,7 @@int running_on_hw =1 ;/* vs. on ISS */ char __initdata command_line[COMMAND_LINE_SIZE ]; -struct machine_desc *machine_desc; +const struct machine_desc *machine_desc;struct task_struct *_current_task[NR_CPUS ];/* For stack switching */
-- 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 v2 25/29] arc: use common of_flat_dt_match_machine
Quoted 5 lines · Vineet Gupta
Hi Rob,
Quoted 2 lines · Rob Herring
From: Rob Herring <rob.herring-bsGFqQB8/[email protected]>
Quoted 8 lines
Quoted 4 lines
Convert arc to use the common
of_flat_dt_match_machinefunction.Can you please fold the following into this patch. This removes the const warning and also gets rid of some dead code.
Thanks. I've added this in and updated my branch. Please double check it when you have a chance. I also made __arch_info_begin[] and __arch_info_end[] const.
Rob
--
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 v2 25/29] arc: use common of_flat_dt_match_machine
Quoted 3 lines · Rob Herring
Thanks. I've added this in and updated my branch. Please double check it when you have a chance. I also made __arch_info_begin[] and __arch_info_end[] const.
Works great !
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 v2 26/29 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 const void *__init arch_get_next_mach (const char *const **match) +{ +static const struct machine_desc *mdesc = __arch_info_begin; +const 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" )
@@ -198,23 +208,17 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)if (!dt_phys || !early_init_dt_scan (phys_to_virt (dt_phys)))return NULL ; + 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);
@@ -225,16 +229,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 v2 27/29 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
PATCH v2 28/29 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/include/asm/mach/arch.h | 2 +- arch/metag/include/asm/prom.h | 2 +- arch/metag/kernel/devtree.c | 60 ++++++++++++-------------------------- arch/metag/kernel/setup.c | 2 +- 4 files changed, 22 insertions(+), 44 deletions(-)
arch/metag/include/asm/mach/arch.h +1 -1
@@ -53,7 +53,7 @@ struct machine_desc {/* * Current machine - only accessible during boot. */ -extern struct machine_desc *machine_desc; +extern const struct machine_desc *machine_desc;/* * Machine type table - also only accessible during boot
arch/metag/include/asm/prom.h +1 -1
@@ -17,7 +17,7 @@#include <asm/setup.h> #define HAVE_ARCH_DEVTREE_FIXUPS -extern struct machine_desc *setup_machine_fdt (void *dt); +extern const struct machine_desc *setup_machine_fdt (void *dt);extern void copy_fdt (void );#endif /* __ASM_METAG_PROM_H */
arch/metag/kernel/devtree.c +19 -41
78 lines not on this page · raw message
arch/metag/kernel/setup.c +1 -1
@@ -115,7 +115,7 @@ extern u32 __dtb_start[];extern struct console dash_console;#endif -struct machine_desc *machine_desc__initdata ; +const struct machine_desc *machine_desc__initdata ;/* * Map a Linux CPU number to a hardware thread ID
Signature · 1 line
1.8.1.2
PATCH v2 29/29 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