FDT clean-ups and libfdt support
Subsystems (16)
v2 cover FDT clean-ups and libfdt support
From: Rob Herring <[email protected]>
This is a series of clean-ups of architecture FDT code and converts the core FDT code over to using libfdt functions. This is in preparation to add FDT based address translation parsing functions for early console support. This series removes direct access to FDT data from all arches except powerpc.
The current MIPS lantiq and xlp DT code is buggy as built-in DTBs need to be copied out of init section. Patches 2 and 3 should be applied to 3.15.
Changes in v2 are relatively minor. There was a bug in the unflattening code where walking up the tree was not being handled correctly (thanks to Michal Simek). I re-worked things a bit to avoid globally adding libfdt include paths.
A branch is available here[1], and I plan to put into linux-next in a few days. Please test! I've compiled on arm, arm64, mips, microblaze, xtensa, and powerpc and booted on arm and arm64.
Rob
[1] git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git libfdt
Rob Herring (21):
mips: octeon: convert to use unflatten_and_copy_device_tree
mips: lantiq: copy built-in DTB out of init section
mips: xlp: copy built-in DTB out of init section
mips: ralink: convert to use unflatten_and_copy_device_tree
ARM: dt: use default early_init_dt_alloc_memory_arch
c6x: convert fdt pointers to opaque pointers
mips: convert fdt pointers to opaque pointers of/fdt: consolidate built-in dtb section variables of/fdt: remove some unneeded includes
of/fdt: remove unused of_scan_flat_dt_by_path of/fdt: update of_get_flat_dt_prop in prep for libfdt of/fdt: Convert FDT functions to use libfdt
of/fdt: use libfdt accessors for header data of/fdt: create common debugfs
of/fdt: move memreserve and dtb memory reservations into core of/fdt: fix phys_addr_t related print size warnings of/fdt: introduce of_get_flat_dt_size
powerpc: use libfdt accessors for header data
x86: use FDT accessors for FDT blob header data of/fdt: convert initial_boot_params to opaque pointer
of: push struct boot_param_header and defines into powerpc
arch/arc/include/asm/sections.h | 1 - arch/arc/kernel/devtree.c | 2 +- arch/arm/include/asm/prom.h | 2 - arch/arm/kernel/devtree.c | 34 +-- arch/arm/mach-exynos/exynos.c | 2 +- arch/arm/mach-vexpress/platsmp.c | 2 +- arch/arm/mm/init.c | 1 - arch/arm/plat-samsung/s5p-dev-mfc.c | 4 +- arch/arm64/mm/init.c | 21 -- arch/c6x/kernel/setup.c | 4 +- arch/metag/kernel/setup.c | 4 - arch/microblaze/kernel/prom.c | 39 +-- arch/mips/cavium-octeon/setup.c | 20 +- arch/mips/include/asm/mips-boards/generic.h | 4 - arch/mips/include/asm/prom.h | 6 +- arch/mips/kernel/prom.c | 2 +- arch/mips/lantiq/prom.c | 15 +- arch/mips/lantiq/prom.h | 2 - arch/mips/mti-sead3/sead3-setup.c | 8 +- arch/mips/netlogic/xlp/dt.c | 19 +- arch/mips/ralink/of.c | 29 +- arch/openrisc/kernel/vmlinux.h | 2 - arch/powerpc/include/asm/prom.h | 39 +++ arch/powerpc/kernel/Makefile | 1 + arch/powerpc/kernel/epapr_paravirt.c | 2 +- arch/powerpc/kernel/fadump.c | 4 +- arch/powerpc/kernel/prom.c | 78 ++---- arch/powerpc/kernel/rtas.c | 2 +- arch/powerpc/mm/hash_utils_64.c | 22 +- arch/powerpc/platforms/52xx/efika.c | 4 +- arch/powerpc/platforms/chrp/setup.c | 4 +- arch/powerpc/platforms/powernv/opal.c | 12 +- arch/powerpc/platforms/pseries/setup.c | 4 +- arch/x86/kernel/devicetree.c | 12 +- arch/xtensa/kernel/setup.c | 3 +- drivers/of/Kconfig | 1 + drivers/of/Makefile | 2 + drivers/of/fdt.c | 398 ++++++++++------------------ drivers/of/of_reserved_mem.c | 4 +- include/linux/of_fdt.h | 63 +---- 40 files changed, 280 insertions(+), 598 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/21 mips: octeon: convert to use unflatten_and_copy_device_tree
From: Rob Herring <[email protected]>
The octeon FDT code can be simplified by using unflatten_and_copy_device_tree function. This removes all accesses to FDT header data by the arch code.
---
v2: fix build error
arch/mips/cavium-octeon/setup.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)
arch/mips/cavium-octeon/setup.c +5 -15
@@ -1053,36 +1053,26 @@ void prom_free_prom_memory(void)int octeon_prune_device_tree (void );extern const char __dtb_octeon_3xxx_begin; -extern const char __dtb_octeon_3xxx_end;extern const char __dtb_octeon_68xx_begin; -extern const char __dtb_octeon_68xx_end;void __init device_tree_init (void ) { -int dt_size; -struct boot_param_header *fdt; +const void *fdt;bool do_prune;if (octeon_bootinfo->minor_version >=3 && octeon_bootinfo->fdt_addr) { fdt =phys_to_virt (octeon_bootinfo->fdt_addr);if (fdt_check_header (fdt))panic ("Corrupt Device Tree passed to kernel." ); - dt_size =be32_to_cpu (fdt->totalsize); do_prune = false; }else if (OCTEON_IS_MODEL (OCTEON_CN68XX )) { - fdt = (struct boot_param_header *)&__dtb_octeon_68xx_begin; - dt_size = &__dtb_octeon_68xx_end - &__dtb_octeon_68xx_begin; + fdt = &__dtb_octeon_68xx_begin; do_prune = true; }else { - fdt = (struct boot_param_header *)&__dtb_octeon_3xxx_begin; - dt_size = &__dtb_octeon_3xxx_end - &__dtb_octeon_3xxx_begin; + fdt = &__dtb_octeon_3xxx_begin; do_prune = true; } -/* Copy the default tree from init memory. */ - initial_boot_params =early_init_dt_alloc_memory_arch (dt_size,8 ); -if (initial_boot_params ==NULL ) -panic ("Could not allocate initial_boot_params" ); -memcpy (initial_boot_params, fdt, dt_size); + initial_boot_params = (void *)fdt;if (do_prune) {octeon_prune_device_tree ();
@@ -1090,7 +1080,7 @@ void __init device_tree_init(void) }else {pr_info ("Using passed Device Tree.\n" ); } -unflatten_device_tree (); +unflatten_and_copy_device_tree (); }static int __initdata disable_octeon_edac_p;
Signature · 1 line
1.9.1
PATCH v2 2/21 mips: lantiq: copy built-in DTB out of init section
In reply to Rob HerringFrom: Rob Herring <[email protected]>
The existing code is buggy because built-in DTBs are in init memory. Fix this by using the unflatten_and_copy_device_tree function.
This removes all accesses to FDT header data by the arch code.
---
v2: no change
arch/mips/lantiq/prom.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
arch/mips/lantiq/prom.c +1 -12
@@ -76,18 +76,7 @@ void __init plat_mem_setup(void)void __init device_tree_init (void ) { -unsigned long base, size; - -if (!initial_boot_params) -return ; - - base =virt_to_phys ((void *)initial_boot_params); - size =be32_to_cpu (initial_boot_params->totalsize); - -/* Before we do anything, lets reserve the dt blob */ -reserve_bootmem (base, size,BOOTMEM_DEFAULT ); - -unflatten_device_tree (); +unflatten_and_copy_device_tree (); }void __init prom_init (void )
Signature · 1 line
1.9.1
PATCH v2 3/21 mips: xlp: copy built-in DTB out of init section
In reply to Rob HerringFrom: Rob Herring <[email protected]>
The existing code is buggy because built-in DTBs are in init memory. It is also broken because the reserved bootmem was then freed after unflattening, but the unflattened tree points to data in the flat tree. Fix this by using the unflatten_and_copy_device_tree function.
This removes all accesses to FDT header data by the arch code.
---
v2: no change
arch/mips/netlogic/xlp/dt.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)
arch/mips/netlogic/xlp/dt.c +1 -16
@@ -87,22 +87,7 @@ void __init xlp_early_init_devtree(void)void __init device_tree_init (void ) { -unsigned long base, size; -struct boot_param_header *fdtp = xlp_fdt_blob; - -if (!fdtp) -return ; - - base =virt_to_phys (fdtp); - size =be32_to_cpu (fdtp->totalsize); - -/* Before we do anything, lets reserve the dt blob */ -reserve_bootmem (base, size,BOOTMEM_DEFAULT ); - -unflatten_device_tree (); - -/* free the space reserved for the dt blob */ -free_bootmem (base, size); +unflatten_and_copy_device_tree (); }static struct of_device_id __initdata xlp_ids[] = {
Signature · 1 line
1.9.1
PATCH v2 4/21 mips: ralink: convert to use unflatten_and_copy_device_tree
In reply to Rob HerringFrom: Rob Herring <[email protected]>
The ralink FDT code can be simplified by using unflatten_and_copy_device_tree function. This removes all accesses to FDT header data by the arch code.
---
v2: no change
arch/mips/ralink/of.c | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-)
arch/mips/ralink/of.c +1 -24
@@ -52,30 +52,7 @@ __iomem void *plat_of_remap_node(const char *node)void __init device_tree_init (void ) { -unsigned long base, size; -void *fdt_copy; - -if (!initial_boot_params) -return ; - - base =virt_to_phys ((void *)initial_boot_params); - size =be32_to_cpu (initial_boot_params->totalsize); - -/* Before we do anything, lets reserve the dt blob */ -reserve_bootmem (base, size,BOOTMEM_DEFAULT ); - -/* The strings in the flattened tree are referenced directly by the -* device tree, so copy the flattened device tree from init memory -* to regular memory. -*/ - fdt_copy =alloc_bootmem (size); -memcpy (fdt_copy, initial_boot_params, size); - initial_boot_params = fdt_copy; - -unflatten_device_tree (); - -/* free the space reserved for the dt blob */ -free_bootmem (base, size); +unflatten_and_copy_device_tree (); }void __init plat_mem_setup (void )
Signature · 1 line
1.9.1
PATCH v2 5/21 ARM: dt: use default early_init_dt_alloc_memory_arch
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Now that ARM is using memblock instead of bootmem, the default version of early_init_dt_alloc_memory_arch can be used.
---
v2: no change
arch/arm/kernel/devtree.c | 5 ----- 1 file changed, 5 deletions(-)
arch/arm/kernel/devtree.c +0 -5
@@ -32,11 +32,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)arm_add_memory (base, size); } -void *__init early_init_dt_alloc_memory_arch (u64 size,u64 align) -{ -return memblock_virt_alloc (size, align); -} -void __init arm_dt_memblock_reserve (void ) {u64 *reserve_map, base, size;
Signature · 1 line
1.9.1
PATCH v2 6/21 c6x: convert fdt pointers to opaque pointers
In reply to Rob HerringFrom: Rob Herring <[email protected]>
The architecture code does not need to access the internals of the FDT blob, so make the pointer to it void *.
---
v2: remove unneeded casting
arch/c6x/kernel/setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/c6x/kernel/setup.c +2 -2
@@ -265,8 +265,8 @@ int __init c6x_add_memory(phys_addr_t start, unsigned long size)*/ notrace void __init machine_init(unsigned long dt_ptr) { -struct boot_param_header *dtb =__va (dt_ptr); -struct boot_param_header *fdt = (struct boot_param_header *)_fdt_start; +const void *dtb =__va (dt_ptr); +const void *fdt = _fdt_start;/* interrupts must be masked */ set_creg (IER ,2 );
Signature · 1 line
1.9.1
Re: [PATCH v2 06/21] c6x: convert fdt pointers to opaque pointers
Quoted 10 lines · Rob Herring
From: Rob Herring <[email protected]>
The architecture code does not need to access the internals of the FDT blob, so make the pointer to it void *.
Signed-off-by Rob Herring <[email protected]>Cc Mark Salter <[email protected]>Cc Aurelien Jacquiot <[email protected]>---
--
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 7/21 mips: convert fdt pointers to opaque pointers
In reply to Rob HerringFrom: Rob Herring <[email protected]>
The architecture code does not need to access the internals of the FDT blob directly, so make the pointers to it void * and use char arrays for section variables.
---
v2: no change
arch/mips/include/asm/mips-boards/generic.h | 4 +--- arch/mips/include/asm/prom.h | 6 +++--- arch/mips/kernel/prom.c | 2 +- arch/mips/lantiq/prom.c | 2 +- arch/mips/lantiq/prom.h | 2 +- arch/mips/mti-sead3/sead3-setup.c | 8 ++++---- arch/mips/ralink/of.c | 4 ++-- 7 files changed, 13 insertions(+), 15 deletions(-)
arch/mips/include/asm/mips-boards/generic.h +1 -3
@@ -67,9 +67,7 @@extern int mips_revision_sconid; -#ifdef CONFIG_OF -extern struct boot_param_header __dtb_start; -#endif +extern char __dtb_start[];#ifdef CONFIG_PCI extern void mips_pcibios_init (void );
arch/mips/include/asm/prom.h +3 -3
@@ -21,13 +21,13 @@ extern void device_tree_init(void);struct boot_param_header ; -extern void __dt_setup_arch (struct boot_param_header *bph); +extern void __dt_setup_arch (void *bph);#define dt_setup_arch (sym) \ ({ \ - extern struct boot_param_header __dtb_##sym##_begin; \ + extern char __dtb_##sym##_begin[]; \ \ - __dt_setup_arch(&__dtb_##sym##_begin); \ + __dt_setup_arch(__dtb_##sym##_begin); \ })#else /* CONFIG_OF */
arch/mips/kernel/prom.c +1 -1
@@ -47,7 +47,7 @@ void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)return __alloc_bootmem (size, align,__pa (MAX_DMA_ADDRESS )); } -void __init __dt_setup_arch (struct boot_param_header *bph) +void __init __dt_setup_arch (void *bph) {if (!early_init_dt_scan (bph))return ;
arch/mips/lantiq/prom.c +1 -1
@@ -71,7 +71,7 @@ void __init plat_mem_setup(void)* Load the builtin devicetree. This causes the chosen node to be * parsed resulting in our memory appearing */ -__dt_setup_arch (&__dtb_start); +__dt_setup_arch (__dtb_start); }void __init device_tree_init (void )
arch/mips/lantiq/prom.h +1 -1
@@ -26,6 +26,6 @@ struct ltq_soc_info {extern void ltq_soc_detect (struct ltq_soc_info *i);extern void ltq_soc_init (void ); -extern struct boot_param_header __dtb_start; +extern char __dtb_start[];#endif
arch/mips/mti-sead3/sead3-setup.c +4 -4
@@ -69,17 +69,17 @@ static void __init parse_memsize_param(void)if (!memsize)return ; - offset =fdt_path_offset (&__dtb_start,"/memory" ); + offset =fdt_path_offset (__dtb_start,"/memory" );if (offset >0 ) {uint64_t new_value;/* * reg contains 2 32-bits BE values, offset and size. We just * want to replace the size value without affecting the offset */ - prop_value =fdt_getprop (&__dtb_start, offset,"reg" , &prop_len); + prop_value =fdt_getprop (__dtb_start, offset,"reg" , &prop_len); new_value =be64_to_cpu (*prop_value); new_value = (new_value & ~0xffffffffllu ) | memsize; -fdt_setprop_inplace_u64 (&__dtb_start, offset,"reg" , new_value); +fdt_setprop_inplace_u64 (__dtb_start, offset,"reg" , new_value); } }
@@ -92,7 +92,7 @@ void __init plat_mem_setup(void)* Load the builtin devicetree. This causes the chosen node to be * parsed resulting in our memory appearing */ -__dt_setup_arch (&__dtb_start); +__dt_setup_arch (__dtb_start); }void __init device_tree_init (void )
arch/mips/ralink/of.c +2 -2
@@ -28,7 +28,7 @@__iomem void *rt_sysc_membase;__iomem void *rt_memc_membase; -extern struct boot_param_header __dtb_start; +extern char __dtb_start[];__iomem void *plat_of_remap_node (const char *node) {
@@ -63,7 +63,7 @@ void __init plat_mem_setup(void)* Load the builtin devicetree. This causes the chosen node to be * parsed resulting in our memory appearing */ -__dt_setup_arch (&__dtb_start); +__dt_setup_arch (__dtb_start);if (soc_info.mem_size) add_memory_region(soc_info.mem_base, soc_info.mem_size * SZ_1M,
Signature · 6 lines
1.9.1 -- 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 8/21 of/fdt: consolidate built-in dtb section variables
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Unify the various architectures __dtb_start and __dtb_end definitions moving them into of_fdt.h.
---
v2: no change
arch/arc/include/asm/sections.h | 1 - arch/metag/kernel/setup.c | 4 ---- arch/mips/include/asm/mips-boards/generic.h | 2 -- arch/mips/lantiq/prom.h | 2 -- arch/mips/netlogic/xlp/dt.c | 2 +- arch/mips/ralink/of.c | 2 -- arch/openrisc/kernel/vmlinux.h | 2 -- arch/xtensa/kernel/setup.c | 1 - include/linux/of_fdt.h | 3 +++ 9 files changed, 4 insertions(+), 15 deletions(-)
arch/arc/include/asm/sections.h +0 -1
@@ -12,6 +12,5 @@#include <asm-generic/sections.h> extern char __arc_dccm_base[]; -extern char __dtb_start[];#endif
arch/metag/kernel/setup.c +0 -4
@@ -105,10 +105,6 @@extern char _heap_start[]; -#ifdef CONFIG_METAG_BUILTIN_DTB -extern u32 __dtb_start[]; -#endif -#ifdef CONFIG_DA_CONSOLE /* Our early channel based console driver */ extern struct console dash_console;
arch/mips/include/asm/mips-boards/generic.h +0 -2
@@ -67,8 +67,6 @@extern int mips_revision_sconid; -extern char __dtb_start[]; -#ifdef CONFIG_PCI extern void mips_pcibios_init (void );#else
arch/mips/lantiq/prom.h +0 -2
@@ -26,6 +26,4 @@ struct ltq_soc_info {extern void ltq_soc_detect (struct ltq_soc_info *i);extern void ltq_soc_init (void ); -extern char __dtb_start[]; -#endif
arch/mips/netlogic/xlp/dt.c +1 -1
@@ -42,7 +42,7 @@#include <asm/prom.h> extern u32 __dtb_xlp_evp_begin[], __dtb_xlp_svp_begin[], - __dtb_xlp_fvp_begin[], __dtb_xlp_gvp_begin[], __dtb_start[]; + __dtb_xlp_fvp_begin[], __dtb_xlp_gvp_begin[];static void *xlp_fdt_blob;void __init *xlp_dt_init (void *fdtp)
arch/mips/ralink/of.c +0 -2
@@ -28,8 +28,6 @@__iomem void *rt_sysc_membase;__iomem void *rt_memc_membase; -extern char __dtb_start[]; -__iomem void *plat_of_remap_node (const char *node) {struct resource res;
arch/openrisc/kernel/vmlinux.h +0 -2
@@ -5,6 +5,4 @@extern char __initrd_start, __initrd_end;#endif -extern u32 __dtb_start[]; -#endif
arch/xtensa/kernel/setup.c +0 -1
@@ -73,7 +73,6 @@ extern int initrd_below_start_ok;#endif #ifdef CONFIG_OF -extern u32 __dtb_start[];void *dtb_start = __dtb_start;#endif
include/linux/of_fdt.h +3 -0
@@ -80,6 +80,9 @@ extern int __initdata dt_root_addr_cells;extern int __initdata dt_root_size_cells;extern struct boot_param_header *initial_boot_params; +extern char __dtb_start[]; +extern char __dtb_end[]; +/* For scanning the flat device-tree at boot time */ extern char *find_flat_dt_string (u32 offset); extern int of_scan_flat_dt(int (*it)(unsigned long node, const char *uname,
Signature · 1 line
1.9.1
PATCH v2 9/21 of/fdt: remove some unneeded includes
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Whatever needed powerpc machdep.h appears to have been removed, so the include can be dropped.
module.h is not needed as this code is always built-in.
---
v2: no change
drivers/of/fdt.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/of/fdt.c +0 -5
@@ -12,7 +12,6 @@#include <linux/kernel.h> #include <linux/initrd.h> #include <linux/memblock.h> -#include <linux/module.h> #include <linux/of.h> #include <linux/of_fdt.h> #include <linux/of_reserved_mem.h>
@@ -22,10 +21,6 @@#include <linux/slab.h> #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ -#ifdef CONFIG_PPC -#include <asm/machdep.h> -#endif /* CONFIG_PPC */ -#include <asm/page.h> char *of_fdt_get_string (struct boot_param_header *blob,u32 offset)
Signature · 1 line
1.9.1
PATCH v2 10/21 of/fdt: remove unused of_scan_flat_dt_by_path
In reply to Rob HerringFrom: Rob Herring <[email protected]>
of_scan_flat_dt_by_path is unused anywhere in the kernel, so remove it.
---
v2: no change
drivers/of/fdt.c | 67 -------------------------------------------------- include/linux/of_fdt.h | 3 --- 2 files changed, 70 deletions(-)
drivers/of/fdt.c +0 -67
@@ -671,73 +671,6 @@ struct fdt_scan_status {void *data; }; -/** -* fdt_scan_node_by_path - iterator for of_scan_flat_dt_by_path function -*/ -static int __init fdt_scan_node_by_path (unsigned long node,const char *uname, -int depth,void *data) -{ -struct fdt_scan_status *st = data; - -/* -* if scan at the requested fdt node has been completed, -* return -ENXIO to abort further scanning -*/ -if (depth <= st->depth) -return -ENXIO ; - -/* requested fdt node has been found, so call iterator function */ -if (st->found) -return st->iterator (node, uname, depth, st->data); - -/* check if scanning automata is entering next level of fdt nodes */ -if (depth == st->depth +1 && -strncmp (st->name, uname, st->namelen) ==0 && - uname[st->namelen] ==0 ) { - st->depth +=1 ; -if (st->name[st->namelen] ==0 ) { - st->found =1 ; - }else { -const char *next = st->name + st->namelen +1 ; - st->name = next; - st->namelen =strcspn (next,"/" ); - } -return 0 ; - } - -/* scan next fdt node */ -return 0 ; -} - -/** -* of_scan_flat_dt_by_path - scan flattened tree blob and call callback on each -* child of the given path. -* @path: path to start searching for children -* @it: callback function -* @data: context data pointer -* -* This function is used to scan the flattened device-tree starting from the -* node given by path. It is used to extract information (like reserved -* memory), which is required on ealy boot before we can unflatten the tree. -*/ -int __init of_scan_flat_dt_by_path (const char *path, -int (*it)(unsigned long node,const char *name,int depth,void *data), -void *data) -{ -struct fdt_scan_status st = {path,0 ,-1 ,0 , it, data}; -int ret =0 ; - -if (initial_boot_params) - ret =of_scan_flat_dt (fdt_scan_node_by_path, &st); - -if (!st.found) -return -ENOENT ; -else if (ret == -ENXIO )/* scan has been completed */ -return 0 ; -else -return ret; -} -const char *__init of_flat_dt_get_machine_name (void ) {const char *name;
include/linux/of_fdt.h +0 -3
@@ -93,9 +93,6 @@ extern void *of_get_flat_dt_prop(unsigned long node, const char *name,extern int of_flat_dt_is_compatible (unsigned long node,const char *name);extern int of_flat_dt_match (unsigned long node,const char *const *matches);extern unsigned long of_get_flat_dt_root (void ); -extern int of_scan_flat_dt_by_path (const char *path, -int (*it)(unsigned long node,const char *name,int depth,void *data), -void *data);extern int early_init_dt_scan_chosen (unsigned long node,const char *uname,int depth,void *data);
Signature · 1 line
1.9.1
PATCH v2 11/21 of/fdt: update of_get_flat_dt_prop in prep for libfdt
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Make of_get_flat_dt_prop arguments compatible with libfdt fdt_getprop call in preparation to convert FDT code to use libfdt. Make the return value const and the property length ptr type an int.
---
v2: fix warning on microblaze
arch/arc/kernel/devtree.c | 2 +- arch/arm/kernel/devtree.c | 2 +- arch/arm/mach-exynos/exynos.c | 2 +- arch/arm/mach-vexpress/platsmp.c | 2 +- arch/arm/plat-samsung/s5p-dev-mfc.c | 4 ++-- arch/microblaze/kernel/prom.c | 8 +++---- arch/powerpc/kernel/epapr_paravirt.c | 2 +- arch/powerpc/kernel/fadump.c | 4 ++-- arch/powerpc/kernel/prom.c | 24 +++++++++++---------- arch/powerpc/kernel/rtas.c | 2 +- arch/powerpc/mm/hash_utils_64.c | 22 +++++++++---------- arch/powerpc/platforms/52xx/efika.c | 4 ++-- arch/powerpc/platforms/chrp/setup.c | 4 ++-- arch/powerpc/platforms/powernv/opal.c | 12 +++++------ arch/powerpc/platforms/pseries/setup.c | 4 ++-- arch/xtensa/kernel/setup.c | 2 +- drivers/of/fdt.c | 39 +++++++++++++++++----------------- drivers/of/of_reserved_mem.c | 4 ++-- include/linux/of_fdt.h | 8 +++---- 19 files changed, 77 insertions(+), 74 deletions(-)
arch/arc/kernel/devtree.c +1 -1
@@ -42,7 +42,7 @@ const struct machine_desc * __init setup_machine_fdt(void *dt)const struct machine_desc *mdesc;unsigned long dt_root;void *clk; -unsigned long len; +int len;if (!early_init_dt_scan (dt))return NULL ;
arch/arm/kernel/devtree.c +1 -1
@@ -247,7 +247,7 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)if (!mdesc) {const char *prop; -long size; +int size;unsigned long dt_root; early_print("\nError: unrecognized/unsupported "
arch/arm/mach-exynos/exynos.c +1 -1
@@ -250,7 +250,7 @@ static int __init exynos_fdt_map_chipid(unsigned long node, const char *uname, {struct map_desc iodesc;__be32 *reg; -unsigned long len; +int len;if (!of_flat_dt_is_compatible (node,"samsung,exynos4210-chipid" ) && !of_flat_dt_is_compatible (node,"samsung,exynos5440-clock" ))
arch/arm/mach-vexpress/platsmp.c +1 -1
@@ -53,7 +53,7 @@ static int __init vexpress_dt_find_scu(unsigned long node, {if (of_flat_dt_match (node, vexpress_dt_cortex_a9_match)) {phys_addr_t phys_addr; -__be32 *reg =of_get_flat_dt_prop (node,"reg" ,NULL ); +const __be32 *reg =of_get_flat_dt_prop (node,"reg" ,NULL );if (WARN_ON (!reg))return -EINVAL ;
arch/arm/plat-samsung/s5p-dev-mfc.c +2 -2
@@ -125,8 +125,8 @@ device_initcall(s5p_mfc_memory_init);int __init s5p_fdt_alloc_mfc_mem (unsigned long node,const char *uname,int depth,void *data) { -__be32 *prop; -unsigned long len; +const __be32 *prop; +int len;struct s5p_mfc_dt_meminfo mfc_mem;if (!data)
arch/microblaze/kernel/prom.c +4 -4
@@ -43,13 +43,13 @@#include <asm/pci-bridge.h> #ifdef CONFIG_EARLY_PRINTK -static char *stdout; +static const char *stdout;static int __init early_init_dt_scan_chosen_serial (unsigned long node,const char *uname,int depth,void *data) { -unsigned long l; -char *p; +int l; +const char *p;pr_debug ("%s: depth: %d, uname: %s\n" , __func__, depth, uname);
@@ -80,7 +80,7 @@ static int __init early_init_dt_scan_chosen_serial(unsigned long node, (strncmp(p, "xlnx,opb-uartlite", 17) == 0) || (strncmp(p, "xlnx,axi-uartlite", 17) == 0) || (strncmp(p, "xlnx,mdm", 8) == 0)) { -unsigned int *addrp; +const unsigned int *addrp; *(u32 *)data =UARTLITE ;
arch/powerpc/kernel/epapr_paravirt.c +1 -1
@@ -36,7 +36,7 @@ static int __init early_init_dt_scan_epapr(unsigned long node, int depth, void *data) { const u32 *insts; -unsigned long len; +int len;int i; insts =of_get_flat_dt_prop (node,"hcall-instructions" , &len);
arch/powerpc/kernel/fadump.c +2 -2
@@ -55,9 +55,9 @@ int crash_mem_ranges;int __init early_init_dt_scan_fw_dump (unsigned long node,const char *uname,int depth,void *data) { -__be32 *sections; +const __be32 *sections;int i, num_sections; -unsigned long size; +int size;const int *token;if (depth !=1 ||strcmp (uname,"rtas" ) !=0 )
arch/powerpc/kernel/prom.c +13 -11
@@ -163,7 +163,7 @@ static struct ibm_pa_feature { {CPU_FTR_REAL_LE, PPC_FEATURE_TRUE_LE, 5, 0, 0}, }; -static void __init scan_features (unsigned long node,unsigned char *ftrs, +static void __init scan_features (unsigned long node,const unsigned char *ftrs,unsigned long tablelen,struct ibm_pa_feature *fp,unsigned long ft_size)
@@ -202,8 +202,8 @@ static void __init scan_features(unsigned long node, unsigned char *ftrs,static void __init check_cpu_pa_features (unsigned long node) { -unsigned char *pa_ftrs; -unsigned long tablelen; +const unsigned char *pa_ftrs; +int tablelen; pa_ftrs =of_get_flat_dt_prop (node,"ibm,pa-features" , &tablelen);if (pa_ftrs ==NULL )
@@ -216,7 +216,7 @@ static void __init check_cpu_pa_features(unsigned long node)#ifdef CONFIG_PPC_STD_MMU_64 static void __init check_cpu_slb_size (unsigned long node) { -__be32 *slb_size_ptr; +const __be32 *slb_size_ptr; slb_size_ptr =of_get_flat_dt_prop (node,"slb-size" ,NULL );if (slb_size_ptr !=NULL ) {
@@ -257,7 +257,7 @@ static struct feature_property {static inline void identical_pvr_fixup (unsigned long node) {unsigned int pvr; -char *model =of_get_flat_dt_prop (node,"model" ,NULL ); +const char *model =of_get_flat_dt_prop (node,"model" ,NULL );/* * Since 440GR(x)/440EP(x) processors have the same pvr,
@@ -295,11 +295,11 @@ static int __init early_init_dt_scan_cpus(unsigned long node, const char *uname, int depth, void *data) { - char *type = of_get_flat_dt_prop(node, "device_type", NULL); + const char *type = of_get_flat_dt_prop(node, "device_type", NULL);const __be32 *prop;const __be32 *intserv;int i, nthreads; -unsigned long len; +int len;int found =-1 ;int found_thread =0 ;
@@ -392,7 +392,7 @@ static int __init early_init_dt_scan_cpus(unsigned long node,int __init early_init_dt_scan_chosen_ppc (unsigned long node,const char *uname,int depth,void *data) { -unsigned long *lprop;/* All these set by kernel, so no need to convert endian */ +const unsigned long *lprop;/* All these set by kernel, so no need to convert endian */ /* Use common scan routine to determine if this is the chosen node */ if (early_init_dt_scan_chosen (node, uname, depth, data) ==0 )
@@ -443,8 +443,9 @@ int __init early_init_dt_scan_chosen_ppc(unsigned long node, const char *uname,*/ static int __init early_init_dt_scan_drconf_memory (unsigned long node) { -__be32 *dm, *ls, *usm; -unsigned long l, n, flags; +const __be32 *dm, *ls, *usm; +int l; +unsigned long n, flags;u64 base, size, memblock_size;unsigned int is_kexec_kdump =0 , rngs;
@@ -564,7 +565,8 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)static void __init early_reserve_mem_dt (void ) { -unsigned long i, len, dt_root; +unsigned long i, dt_root; +int len;const __be32 *prop; dt_root =of_get_flat_dt_root ();
arch/powerpc/kernel/rtas.c +1 -1
@@ -1142,7 +1142,7 @@ void __init rtas_initialize(void)int __init early_init_dt_scan_rtas (unsigned long node,const char *uname,int depth,void *data) { -u32 *basep, *entryp, *sizep; +const u32 *basep, *entryp, *sizep;if (depth !=1 ||strcmp (uname,"rtas" ) !=0 )return 0 ;
arch/powerpc/mm/hash_utils_64.c +11 -11
@@ -265,9 +265,9 @@ static int __init htab_dt_scan_seg_sizes(unsigned long node, const char *uname, int depth, void *data) { - char *type = of_get_flat_dt_prop(node, "device_type", NULL); -__be32 *prop; -unsigned long size =0 ; + const char *type = of_get_flat_dt_prop(node, "device_type", NULL); +const __be32 *prop; +int size =0 ;/* We are scanning "cpu" nodes only */ if (type ==NULL ||strcmp (type,"cpu" ) !=0 )
@@ -320,9 +320,9 @@ static int __init htab_dt_scan_page_sizes(unsigned long node, const char *uname, int depth, void *data) { - char *type = of_get_flat_dt_prop(node, "device_type", NULL); -__be32 *prop; -unsigned long size =0 ; + const char *type = of_get_flat_dt_prop(node, "device_type", NULL); +const __be32 *prop; +int size =0 ;/* We are scanning "cpu" nodes only */ if (type ==NULL ||strcmp (type,"cpu" ) !=0 )
@@ -402,9 +402,9 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,static int __init htab_dt_scan_hugepage_blocks (unsigned long node,const char *uname,int depth,void *data) { -char *type =of_get_flat_dt_prop (node,"device_type" ,NULL ); -__be64 *addr_prop; -__be32 *page_count_prop; +const char *type =of_get_flat_dt_prop (node,"device_type" ,NULL ); +const __be64 *addr_prop; +const __be32 *page_count_prop;unsigned int expected_pages;long unsigned int phys_addr;long unsigned int block_size;
@@ -546,8 +546,8 @@ static int __init htab_dt_scan_pftsize(unsigned long node, const char *uname, int depth, void *data) { - char *type = of_get_flat_dt_prop(node, "device_type", NULL); -__be32 *prop; + const char *type = of_get_flat_dt_prop(node, "device_type", NULL); +const __be32 *prop;/* We are scanning "cpu" nodes only */ if (type ==NULL ||strcmp (type,"cpu" ) !=0 )
arch/powerpc/platforms/52xx/efika.c +2 -2
@@ -199,8 +199,8 @@ static void __init efika_setup_arch(void)static int __init efika_probe (void ) { -char *model =of_get_flat_dt_prop (of_get_flat_dt_root (), -"model" ,NULL ); +const char *model =of_get_flat_dt_prop (of_get_flat_dt_root (), +"model" ,NULL );if (model ==NULL )return 0 ;
arch/powerpc/platforms/chrp/setup.c +2 -2
@@ -574,8 +574,8 @@ chrp_init2(void)static int __init chrp_probe (void ) { -char *dtype =of_get_flat_dt_prop (of_get_flat_dt_root (), -"device_type" ,NULL ); +const char *dtype =of_get_flat_dt_prop (of_get_flat_dt_root (), +"device_type" ,NULL );if (dtype ==NULL )return 0 ;if (strcmp (dtype,"chrp" ))
arch/powerpc/platforms/powernv/opal.c +6 -6
@@ -61,7 +61,7 @@ int __init early_init_dt_scan_opal(unsigned long node, const char *uname, int depth, void *data) { const void *basep, *entryp, *sizep; -unsigned long basesz, entrysz, runtimesz; +int basesz, entrysz, runtimesz;if (depth !=1 ||strcmp (uname,"ibm,opal" ) !=0 )return 0 ;
@@ -77,11 +77,11 @@ int __init early_init_dt_scan_opal(unsigned long node, opal.entry =of_read_number (entryp, entrysz/4 ); opal.size =of_read_number (sizep, runtimesz/4 ); -pr_debug ("OPAL Base = 0x%llx (basep=%p basesz=%ld)\n" , +pr_debug ("OPAL Base = 0x%llx (basep=%p basesz=%d)\n" , opal.base, basep, basesz); -pr_debug ("OPAL Entry = 0x%llx (entryp=%p basesz=%ld)\n" , +pr_debug ("OPAL Entry = 0x%llx (entryp=%p basesz=%d)\n" , opal.entry, entryp, entrysz); -pr_debug ("OPAL Entry = 0x%llx (sizep=%p runtimesz=%ld)\n" , +pr_debug ("OPAL Entry = 0x%llx (sizep=%p runtimesz=%d)\n" , opal.size, sizep, runtimesz); powerpc_firmware_features |=FW_FEATURE_OPAL ;
@@ -102,7 +102,7 @@ int __init early_init_dt_scan_opal(unsigned long node,int __init early_init_dt_scan_recoverable_ranges (unsigned long node,const char *uname,int depth,void *data) { -unsigned long i, psize, size; +int i, psize, size;const __be32 *prop;if (depth !=1 ||strcmp (uname,"ibm,opal" ) !=0 )
@@ -359,7 +359,7 @@ int opal_get_chars(uint32_t vtermno, char *buf, int count)if ((be64_to_cpu (evt) &OPAL_EVENT_CONSOLE_INPUT ) ==0 )return 0 ; len =cpu_to_be64 (count); - rc =opal_console_read (vtermno, &len, buf); + rc =opal_console_read (vtermno, &len, buf);if (rc ==OPAL_SUCCESS )return be64_to_cpu (len);return 0 ;
arch/powerpc/platforms/pseries/setup.c +2 -2
@@ -665,7 +665,7 @@ static int __init pseries_probe_fw_features(unsigned long node, void *data) {const char *prop; -unsigned long len; +int len;static int hypertas_found;static int vec5_found;
@@ -698,7 +698,7 @@ static int __init pseries_probe_fw_features(unsigned long node,static int __init pSeries_probe (void ) {unsigned long root =of_get_flat_dt_root (); -char *dtype =of_get_flat_dt_prop (root,"device_type" ,NULL ); +const char *dtype =of_get_flat_dt_prop (root,"device_type" ,NULL );if (dtype ==NULL )return 0 ;
arch/xtensa/kernel/setup.c +1 -1
@@ -220,7 +220,7 @@ static int __init xtensa_dt_io_area(unsigned long node, const char *uname, int depth, void *data) { const __be32 *ranges; -unsigned long len; +int len;if (depth >1 )return 0 ;
drivers/of/fdt.c +20 -19
@@ -35,7 +35,7 @@ char *of_fdt_get_string(struct boot_param_header *blob, u32 offset)*/ void *of_fdt_get_property (struct boot_param_header *blob,unsigned long node,const char *name, -unsigned long *size) +int *size) {unsigned long p = node;
@@ -85,7 +85,8 @@ int of_fdt_is_compatible(struct boot_param_header *blob, unsigned long node, const char *compat) { const char *cp; -unsigned long cplen, l, score =0 ; +int cplen; +unsigned long l, score =0 ; cp =of_fdt_get_property (blob, node,"compatible" , &cplen);if (cp ==NULL )
@@ -444,8 +445,8 @@ static int __init __reserved_mem_reserve_reg(unsigned long node, {int t_len = (dt_root_addr_cells + dt_root_size_cells) *sizeof (__be32);phys_addr_t base, size; -unsigned long len; -__be32 *prop; +int len; +const __be32 *prop;int nomap, first =1 ; prop =of_get_flat_dt_prop (node,"reg" , &len);
@@ -488,7 +489,7 @@ static int __init __reserved_mem_reserve_reg(unsigned long node,*/ static int __init __reserved_mem_check_root (unsigned long node) { -__be32 *prop; +const __be32 *prop; prop =of_get_flat_dt_prop (node,"#size-cells" ,NULL );if (!prop ||be32_to_cpup (prop) != dt_root_size_cells)
@@ -638,8 +639,8 @@ unsigned long __init of_get_flat_dt_root(void)* This function can be used within scan_flattened_dt callback to get * access to properties */ -void *__init of_get_flat_dt_prop (unsigned long node,const char *name, -unsigned long *size) +const void *__init of_get_flat_dt_prop (unsigned long node,const char *name, +int *size) {return of_fdt_get_property (initial_boot_params, node, name, size); }
@@ -710,7 +711,7 @@ const void * __init of_flat_dt_match_machine(const void *default_match, }if (!best_data) {const char *prop; -long size; +int size;pr_err ("\n unrecognized device tree list:\n[ " );
@@ -739,8 +740,8 @@ const void * __init of_flat_dt_match_machine(const void *default_match,static void __init early_init_dt_check_for_initrd (unsigned long node) {u64 start, end; -unsigned long len; -__be32 *prop; +int len; +const __be32 *prop;pr_debug ("Looking for initrd properties... " );
@@ -773,7 +774,7 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)int __init early_init_dt_scan_root (unsigned long node,const char *uname,int depth,void *data) { -__be32 *prop; +const __be32 *prop;if (depth !=0 )return 0 ;
@@ -795,9 +796,9 @@ int __init early_init_dt_scan_root(unsigned long node, const char *uname,return 1 ; } -u64 __init dt_mem_next_cell (int s,__be32 **cellp) +u64 __init dt_mem_next_cell (int s,const __be32 **cellp) { -__be32 *p = *cellp; +const __be32 *p = *cellp; *cellp = p + s;return of_read_number (p, s);
@@ -809,9 +810,9 @@ u64 __init dt_mem_next_cell(int s, __be32 **cellp)int __init early_init_dt_scan_memory (unsigned long node,const char *uname,int depth,void *data) { -char *type =of_get_flat_dt_prop (node,"device_type" ,NULL ); -__be32 *reg, *endp; -unsigned long l; +const char *type =of_get_flat_dt_prop (node,"device_type" ,NULL ); +const __be32 *reg, *endp; +int l;/* We are scanning "memory" nodes only */ if (type ==NULL ) {
@@ -832,7 +833,7 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname, endp = reg + (l /sizeof (__be32)); -pr_debug ("memory scan node %s, reg size %ld, data: %x %x %x %x,\n" , +pr_debug ("memory scan node %s, reg size %d, data: %x %x %x %x,\n" , uname, l, reg[0 ], reg[1 ], reg[2 ], reg[3 ]);while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {
@@ -855,8 +856,8 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,int __init early_init_dt_scan_chosen (unsigned long node,const char *uname,int depth,void *data) { -unsigned long l; -char *p; +int l; +const char *p;pr_debug ("search \"chosen\", depth: %d, uname: %s\n" , depth, uname);
drivers/of/of_reserved_mem.c +2 -2
@@ -95,8 +95,8 @@ static int __init __reserved_mem_alloc_size(unsigned long node,int t_len = (dt_root_addr_cells + dt_root_size_cells) *sizeof (__be32);phys_addr_t start =0 , end =0 ;phys_addr_t base =0 , align =0 , size; -unsigned long len; -__be32 *prop; +int len; +const __be32 *prop;int nomap;int ret;
include/linux/of_fdt.h +4 -4
@@ -66,7 +66,7 @@ extern char *of_fdt_get_string(struct boot_param_header *blob, u32 offset);extern void *of_fdt_get_property (struct boot_param_header *blob,unsigned long node,const char *name, -unsigned long *size); +int *size);extern int of_fdt_is_compatible (struct boot_param_header *blob,unsigned long node,const char *compat);
@@ -88,8 +88,8 @@ extern char *find_flat_dt_string(u32 offset);extern int of_scan_flat_dt (int (*it)(unsigned long node,const char *uname,int depth,void *data),void *data); -extern void *of_get_flat_dt_prop (unsigned long node,const char *name, -unsigned long *size); +extern const void *of_get_flat_dt_prop (unsigned long node,const char *name, +int *size);extern int of_flat_dt_is_compatible (unsigned long node,const char *name);extern int of_flat_dt_match (unsigned long node,const char *const *matches);extern unsigned long of_get_flat_dt_root (void );
@@ -103,7 +103,7 @@ extern void early_init_dt_add_memory_arch(u64 base, u64 size);extern int early_init_dt_reserve_memory_arch (phys_addr_t base,phys_addr_t size,bool no_map);extern void *early_init_dt_alloc_memory_arch (u64 size,u64 align); -extern u64 dt_mem_next_cell (int s,__be32 **cellp); +extern u64 dt_mem_next_cell (int s,const __be32 **cellp);/* Early flat tree scan hooks */ extern int early_init_dt_scan_root(unsigned long node, const char *uname,
Signature · 1 line
1.9.1
PATCH v2 12/21 of/fdt: Convert FDT functions to use libfdt
In reply to Rob HerringFrom: Rob Herring <[email protected]>
The kernel FDT functions predate libfdt and are much more limited in functionality. Also, the kernel functions and libfdt functions are not compatible with each other because they have different definitions of node offsets. To avoid this incompatibility and in preparation to add more FDT parsing functions which will need libfdt, let's first convert the existing code to use libfdt.
The FDT unflattening, top-level FDT scanning, and property retrieval functions are converted to use libfdt. The scanning code should be re-worked to be more efficient and understandable by using libfdt to find nodes directly by path or compatible strings.
---
v2: fix bug reported by Michal Simek in unflatten_dt_node in tracking tree
depth.
drivers/of/Kconfig | 1 + drivers/of/Makefile | 2 + drivers/of/fdt.c | 209 ++++++++++++++----------------------------------- include/linux/of_fdt.h | 1 - 4 files changed, 60 insertions(+), 153 deletions(-)
drivers/of/Kconfig +1 -0
@@ -20,6 +20,7 @@ config OF_SELFTEST config OF_FLATTREE bool select DTC + select LIBFDT config OF_EARLY_FLATTREE bool
drivers/of/Makefile +2 -0
@@ -10,3 +10,5 @@ obj-$(CONFIG_OF_PCI) += of_pci.o obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o obj-$(CONFIG_OF_MTD) += of_mtd.o obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o + +CFLAGS_fdt.o = -I$(src)/../../scripts/dtc/libfdt
drivers/of/fdt.c +57 -152
326 lines not on this page · raw message
include/linux/of_fdt.h +0 -1
@@ -84,7 +84,6 @@ extern char __dtb_start[];extern char __dtb_end[];/* For scanning the flat device-tree at boot time */ -extern char *find_flat_dt_string (u32 offset);extern int of_scan_flat_dt (int (*it)(unsigned long node,const char *uname,int depth,void *data),void *data);
Signature · 1 line
1.9.1
PATCH v2 13/21 of/fdt: use libfdt accessors for header data
In reply to Rob HerringFrom: Rob Herring <[email protected]>
With libfdt support, we can take advantage of helper accessors in libfdt for accessing the FDT header data. This makes the code more readable and makes the FDT blob structure more opaque to the kernel. This also prepares for removing struct boot_param_header completely.
---
v2: fix alignment to be power of 2 in unflatten_and_copy_device_tree
drivers/of/fdt.c | 26 ++++++++++++-------------- include/linux/of_fdt.h | 8 ++++---- 2 files changed, 16 insertions(+), 18 deletions(-)
drivers/of/fdt.c +12 -14
@@ -34,7 +34,7 @@* On match, returns a non-zero value with smaller values returned for more * specific compatible values. */ -int of_fdt_is_compatible (struct boot_param_header *blob, +int of_fdt_is_compatible (const void *blob,unsigned long node,const char *compat) {const char *cp;
@@ -59,7 +59,7 @@ int of_fdt_is_compatible(struct boot_param_header *blob,/** * of_fdt_match - Return true if node matches a list of compatible values */ -int of_fdt_match (struct boot_param_header *blob,unsigned long node, +int of_fdt_match (const void *blob,unsigned long node,const char *const *compat) {unsigned int tmp, score =0 ;
@@ -98,7 +98,7 @@ static void *unflatten_dt_alloc(void **mem, unsigned long size,* @allnextpp: pointer to ->allnext from last allocated device_node * @fpsize: Size of the node path up at the current depth. */ -static void * unflatten_dt_node(struct boot_param_header *blob, +static void * unflatten_dt_node(void *blob, void *mem, int *poffset, struct device_node *dad,
@@ -295,7 +295,7 @@ static void * unflatten_dt_node(struct boot_param_header *blob,* @dt_alloc: An allocator that provides a virtual address to memory * for the resulting tree */ -static void __unflatten_device_tree (struct boot_param_header *blob, +static void __unflatten_device_tree (void *blob,struct device_node **mynodes,void * (*dt_alloc)(u64 size,u64 align)) {
@@ -312,11 +312,11 @@ static void __unflatten_device_tree(struct boot_param_header *blob, }pr_debug ("Unflattening device tree:\n" ); -pr_debug ("magic: %08x\n" ,be32_to_cpu (blob->magic)); -pr_debug ("size: %08x\n" ,be32_to_cpu (blob->totalsize)); -pr_debug ("version: %08x\n" ,be32_to_cpu (blob->version)); +pr_debug ("magic: %08x\n" ,fdt_magic (blob)); +pr_debug ("size: %08x\n" ,fdt_totalsize (blob)); +pr_debug ("version: %08x\n" ,fdt_version (blob)); -if (be32_to_cpu (blob->magic) !=OF_DT_HEADER ) { +if (fdt_check_header (blob)) {pr_err ("Invalid device tree blob header\n" );return ; }
@@ -363,9 +363,7 @@ static void *kernel_tree_alloc(u64 size, u64 align)void of_fdt_unflatten_tree (unsigned long *blob,struct device_node **mynodes) { -struct boot_param_header *device_tree = - (struct boot_param_header *)blob; -__unflatten_device_tree (device_tree, mynodes, &kernel_tree_alloc); +__unflatten_device_tree (blob, mynodes, &kernel_tree_alloc); }EXPORT_SYMBOL_GPL (of_fdt_unflatten_tree);
@@ -852,7 +850,7 @@ bool __init early_init_dt_scan(void *params) initial_boot_params = params;/* check device tree validity */ -if (be32_to_cpu (initial_boot_params->magic) !=OF_DT_HEADER ) { +if (fdt_check_header (params)) { initial_boot_params =NULL ;return false; }
@@ -907,9 +905,9 @@ void __init unflatten_and_copy_device_tree(void)return ; } - size =__be32_to_cpu (initial_boot_params->totalsize); + size =fdt_totalsize (initial_boot_params); dt =early_init_dt_alloc_memory_arch (size, - __alignof__(struct boot_param_header )); +roundup_pow_of_two (FDT_V17_SIZE ));if (dt) {memcpy (dt, initial_boot_params, size);
include/linux/of_fdt.h +4 -4
@@ -62,15 +62,15 @@ struct boot_param_header {struct device_node ;/* For scanning an arbitrary device-tree at any time */ -extern char *of_fdt_get_string (struct boot_param_header *blob,u32 offset); -extern void *of_fdt_get_property (struct boot_param_header *blob, +extern char *of_fdt_get_string (const void *blob,u32 offset); +extern void *of_fdt_get_property (const void *blob,unsigned long node,const char *name,int *size); -extern int of_fdt_is_compatible (struct boot_param_header *blob, +extern int of_fdt_is_compatible (const void *blob,unsigned long node,const char *compat); -extern int of_fdt_match (struct boot_param_header *blob,unsigned long node, +extern int of_fdt_match (const void *blob,unsigned long node,const char *const *compat);extern void of_fdt_unflatten_tree (unsigned long *blob,struct device_node **mynodes);
Signature · 1 line
1.9.1
PATCH v2 14/21 of/fdt: create common debugfs
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Both powerpc and microblaze have the same FDT blob in debugfs feature. Move this to common location and remove the powerpc and microblaze implementations. This feature could become more useful when FDT overlay support is added.
This changes the path of the blob from "$arch/flat-device-tree" to "device-tree/flat-device-tree".
---
v2: move to after libfdt conversion
arch/microblaze/kernel/prom.c | 31 ------------------------------- arch/powerpc/kernel/prom.c | 21 --------------------- drivers/of/fdt.c | 24 ++++++++++++++++++++++++ 3 files changed, 24 insertions(+), 52 deletions(-)
arch/microblaze/kernel/prom.c +0 -31
@@ -114,34 +114,3 @@ void __init early_init_devtree(void *params)pr_debug (" <- early_init_devtree()\n" ); } - -/******* -* -* New implementation of the OF "find" APIs, return a refcounted -* object, call of_node_put() when done. The device tree and list -* are protected by a rw_lock. -* -* Note that property management will need some locking as well, -* this isn't dealt with yet. -* -*******/ - -#if defined(CONFIG_DEBUG_FS ) && defined(DEBUG ) -static struct debugfs_blob_wrapper flat_dt_blob; - -static int __init export_flat_device_tree (void ) -{ -struct dentry *d; - - flat_dt_blob.data = initial_boot_params; - flat_dt_blob.size = initial_boot_params->totalsize; - - d =debugfs_create_blob ("flat-device-tree" ,S_IFREG |S_IRUSR , - of_debugfs_root, &flat_dt_blob); -if (!d) -return 1 ; - -return 0 ; -} -device_initcall (export_flat_device_tree); -#endif
arch/powerpc/kernel/prom.c +0 -21
@@ -29,7 +29,6 @@#include <linux/bitops.h> #include <linux/export.h> #include <linux/kexec.h> -#include <linux/debugfs.h> #include <linux/irq.h> #include <linux/memblock.h> #include <linux/of.h>
@@ -924,23 +923,3 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id) {return (int )phys_id ==get_hard_smp_processor_id (cpu); } - -#if defined(CONFIG_DEBUG_FS ) && defined(DEBUG ) -static struct debugfs_blob_wrapper flat_dt_blob; - -static int __init export_flat_device_tree (void ) -{ -struct dentry *d; - - flat_dt_blob.data = initial_boot_params; - flat_dt_blob.size =be32_to_cpu (initial_boot_params->totalsize); - - d =debugfs_create_blob ("flat-device-tree" ,S_IFREG |S_IRUSR , - powerpc_debugfs_root, &flat_dt_blob); -if (!d) -return 1 ; - -return 0 ; -} -__initcall (export_flat_device_tree); -#endif
drivers/of/fdt.c +24 -0
@@ -20,6 +20,7 @@#include <linux/errno.h> #include <linux/slab.h> #include <linux/libfdt.h> +#include <linux/debugfs.h> #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ #include <asm/page.h>
@@ -916,4 +917,27 @@ void __init unflatten_and_copy_device_tree(void) unflatten_device_tree(); } +#if defined(CONFIG_DEBUG_FS ) && defined(DEBUG ) +static struct debugfs_blob_wrapper flat_dt_blob; + +static int __init of_flat_dt_debugfs_export_fdt (void ) +{ +struct dentry *d =debugfs_create_dir ("device-tree" ,NULL ); + +if (!d) +return -ENOENT ; + + flat_dt_blob.data = initial_boot_params; + flat_dt_blob.size =fdt_totalsize (initial_boot_params); + + d =debugfs_create_blob ("flat-device-tree" ,S_IFREG |S_IRUSR , + d, &flat_dt_blob); +if (!d) +return -ENOENT ; + +return 0 ; +} +module_init (of_flat_dt_debugfs_export_fdt); +#endif +#endif /* CONFIG_OF_EARLY_FLATTREE */
Signature · 6 lines
1.9.1 _______________________________________________ Linuxppc-dev mailing list [email protected] https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v2 14/21] of/fdt: create common debugfs
Quoted 116 lines · Rob Herring
From: Rob Herring <[email protected]>
Both powerpc and microblaze have the same FDT blob in debugfs feature. Move this to common location and remove the powerpc and microblaze implementations. This feature could become more useful when FDT overlay support is added.
This changes the path of the blob from "$arch/flat-device-tree" to "device-tree/flat-device-tree".
Signed-off-by Rob Herring <[email protected]>Cc Michal Simek <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>Cc Paul Mackerras <[email protected]>---
v2: move to after libfdt conversionarch/microblaze/kernel/prom.c | 31 ------------------------------- arch/powerpc/kernel/prom.c | 21 --------------------- drivers/of/fdt.c | 24 ++++++++++++++++++++++++ 3 files changed, 24 insertions(+), 52 deletions(-)arch/microblaze/kernel/prom.c +0
-31@@ -114,34 +114,3 @@ void __init early_init_devtree(void *params)pr_debug (" <- early_init_devtree()\n" ); } - -/******* -* -* New implementation of the OF "find" APIs, return a refcounted -* object, call of_node_put() when done. The device tree and list -* are protected by a rw_lock. -* -* Note that property management will need some locking as well, -* this isn't dealt with yet. -* -*******/ - -#if defined(CONFIG_DEBUG_FS ) && defined(DEBUG ) -static struct debugfs_blob_wrapper flat_dt_blob; - -static int __init export_flat_device_tree (void ) -{ -struct dentry *d; - - flat_dt_blob.data = initial_boot_params; - flat_dt_blob.size = initial_boot_params->totalsize; - - d =debugfs_create_blob ("flat-device-tree" ,S_IFREG |S_IRUSR , - of_debugfs_root, &flat_dt_blob); -if (!d) -return 1 ; - -return 0 ; -} -device_initcall (export_flat_device_tree); -#endif arch/powerpc/kernel/prom.c +0
-21@@ -29,7 +29,6 @@#include <linux/bitops.h> #include <linux/export.h> #include <linux/kexec.h> -#include <linux/debugfs.h> #include <linux/irq.h> #include <linux/memblock.h> #include <linux/of.h> @@ -924,23 +923,3 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id) {return (int )phys_id ==get_hard_smp_processor_id (cpu); } - -#if defined(CONFIG_DEBUG_FS ) && defined(DEBUG ) -static struct debugfs_blob_wrapper flat_dt_blob; - -static int __init export_flat_device_tree (void ) -{ -struct dentry *d; - - flat_dt_blob.data = initial_boot_params; - flat_dt_blob.size =be32_to_cpu (initial_boot_params->totalsize); - - d =debugfs_create_blob ("flat-device-tree" ,S_IFREG |S_IRUSR , - powerpc_debugfs_root, &flat_dt_blob); -if (!d) -return 1 ; - -return 0 ; -} -__initcall (export_flat_device_tree); -#endif drivers/of/fdt.c +3
-0@@ -20,6 +20,7 @@#include <linux/errno.h> #include <linux/slab.h> #include <linux/libfdt.h> +#include <linux/debugfs.h> #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ #include <asm/page.h> @@ -916,4 +917,27 @@ void __init unflatten_and_copy_device_tree(void)unflatten_device_tree (); } +#if defined(CONFIG_DEBUG_FS ) && defined(DEBUG ) +static struct debugfs_blob_wrapper flat_dt_blob;
drivers/of/fdt.c void __init unflatten_and_copy_device_tree(void) · line 931
Quoted 10 lines
drivers/of/fdt.c +10
-0+ +static int __init of_flat_dt_debugfs_export_fdt (void ) +{ +struct dentry *d =debugfs_create_dir ("device-tree" ,NULL ); + +if (!d) +return -ENOENT ; + + flat_dt_blob.data = initial_boot_params; + flat_dt_blob.size =fdt_totalsize (initial_boot_params);
As I wrote in different patch. I would move this to the end of this series and
flat_dt_blob.size = of_get_flat_dt_size();
drivers/of/fdt.c void __init unflatten_and_copy_device_tree(void) · line 943
Quoted 13 lines
drivers/of/fdt.c +11
-0+ + d =debugfs_create_blob ("flat-device-tree" ,S_IFREG |S_IRUSR , + d, &flat_dt_blob); +if (!d) +return -ENOENT ; + +return 0 ; +} +module_init (of_flat_dt_debugfs_export_fdt); +#endif +#endif /* CONFIG_OF_EARLY_FLATTREE */
Other than comment above:
For Microblaze:
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
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
PATCH v2 15/21 of/fdt: move memreserve and dtb memory reservations into core
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Move the /memreserve/ processing and dtb memory reservations into early_init_fdt_scan_reserved_mem. This converts arm, arm64, and powerpc as they are the only users of early_init_fdt_scan_reserved_mem.
memblock_reserve is safe to call on the same region twice, so the reservation check for the dtb in powerpc 32-bit reservations is safe to remove.
---
v2: No change
arch/arm/include/asm/prom.h | 2 -- arch/arm/kernel/devtree.c | 27 --------------------------- arch/arm/mm/init.c | 1 - arch/arm64/mm/init.c | 21 --------------------- arch/powerpc/kernel/prom.c | 22 ---------------------- drivers/of/fdt.c | 16 ++++++++++++++++ 6 files changed, 16 insertions(+), 73 deletions(-)
arch/arm/include/asm/prom.h +0 -2
@@ -14,7 +14,6 @@#ifdef CONFIG_OF extern const struct machine_desc *setup_machine_fdt (unsigned int dt_phys); -extern void arm_dt_memblock_reserve (void );extern void __init arm_dt_init_cpu_maps (void );#else /* CONFIG_OF */
@@ -24,7 +23,6 @@ static inline const struct machine_desc *setup_machine_fdt(unsigned int dt_phys) return NULL; } -static inline void arm_dt_memblock_reserve (void ) { }static inline void arm_dt_init_cpu_maps (void ) { }#endif /* CONFIG_OF */
arch/arm/kernel/devtree.c +0 -27
@@ -32,33 +32,6 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)arm_add_memory (base, size); } -void __init arm_dt_memblock_reserve (void ) -{ -u64 *reserve_map, base, size; - -if (!initial_boot_params) -return ; - -/* Reserve the dtb region */ -memblock_reserve (virt_to_phys (initial_boot_params), -be32_to_cpu (initial_boot_params->totalsize)); - -/* -* Process the reserve map. This will probably overlap the initrd -* and dtb locations which are already reserved, but overlaping -* doesn't hurt anything -*/ - reserve_map = ((void *)initial_boot_params) + -be32_to_cpu (initial_boot_params->off_mem_rsvmap); -while (1 ) { - base =be64_to_cpup (reserve_map++); - size =be64_to_cpup (reserve_map++); -if (!size) -break ; -memblock_reserve (base, size); - } -} -#ifdef CONFIG_SMP extern struct of_cpu_method __cpu_method_of_table_begin[];extern struct of_cpu_method __cpu_method_of_table_end[];
arch/arm/mm/init.c +0 -1
@@ -317,7 +317,6 @@ void __init arm_memblock_init(struct meminfo *mi,#endif arm_mm_memblock_reserve (); -arm_dt_memblock_reserve ();/* reserve any platform specific memblock areas */ if (mdesc->reserve)
arch/arm64/mm/init.c +0 -21
@@ -126,8 +126,6 @@ static void arm64_memory_present(void)void __init arm64_memblock_init (void ) { -u64 *reserve_map, base, size; -/* Register the kernel text, kernel data and initrd with memblock */ memblock_reserve (__pa (_text), _end - _text);#ifdef CONFIG_BLK_DEV_INITRD
@@ -142,25 +140,6 @@ void __init arm64_memblock_init(void)memblock_reserve (__pa (swapper_pg_dir),SWAPPER_DIR_SIZE );memblock_reserve (__pa (idmap_pg_dir),IDMAP_DIR_SIZE ); -/* Reserve the dtb region */ -memblock_reserve (virt_to_phys (initial_boot_params), -be32_to_cpu (initial_boot_params->totalsize)); - -/* -* Process the reserve map. This will probably overlap the initrd -* and dtb locations which are already reserved, but overlapping -* doesn't hurt anything -*/ - reserve_map = ((void *)initial_boot_params) + -be32_to_cpu (initial_boot_params->off_mem_rsvmap); -while (1 ) { - base =be64_to_cpup (reserve_map++); - size =be64_to_cpup (reserve_map++); -if (!size) -break ; -memblock_reserve (base, size); - } -early_init_fdt_scan_reserved_mem ();dma_contiguous_reserve (0 );
arch/powerpc/kernel/prom.c +0 -22
@@ -596,19 +596,11 @@ static void __init early_reserve_mem_dt(void)static void __init early_reserve_mem (void ) { -u64 base, size;__be64 *reserve_map; -unsigned long self_base; -unsigned long self_size; reserve_map = (__be64 *)(((unsigned long )initial_boot_params) +be32_to_cpu (initial_boot_params->off_mem_rsvmap)); -/* before we do anything, lets reserve the dt blob */ - self_base =__pa ((unsigned long )initial_boot_params); - self_size =be32_to_cpu (initial_boot_params->totalsize); -memblock_reserve (self_base, self_size); -/* Look for the new "reserved-regions" property in the DT */ early_reserve_mem_dt ();
@@ -637,26 +629,12 @@ static void __init early_reserve_mem(void) size_32 =be32_to_cpup (reserve_map_32++);if (size_32 ==0 )break ; -/* skip if the reservation is for the blob */ -if (base_32 == self_base && size_32 == self_size) -continue ;DBG ("reserving: %x -> %x\n" , base_32, size_32); memblock_reserve(base_32, size_32); }return ; }#endif -DBG ("Processing reserve map\n" ); - -/* Handle the reserve map in the fdt blob if it exists */ -while (1 ) { - base =be64_to_cpup (reserve_map++); - size =be64_to_cpup (reserve_map++); -if (size ==0 ) -break ; -DBG ("reserving: %llx -> %llx\n" , base, size); -memblock_reserve (base, size); - } }void __init early_init_devtree (void *params)
drivers/of/fdt.c +16 -0
@@ -492,9 +492,25 @@ static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname,*/ void __init early_init_fdt_scan_reserved_mem (void ) { +int n; +u64 base, size; +if (!initial_boot_params)return ; +/* Reserve the dtb region */ +early_init_dt_reserve_memory_arch (__pa (initial_boot_params), +fdt_totalsize (initial_boot_params), +0 ); + +/* Process header /memreserve/ fields */ +for (n =0 ; ; n++) { +fdt_get_mem_rsv (initial_boot_params, n, &base, &size); +if (!size) +break ; +early_init_dt_reserve_memory_arch (base, size,0 ); + } +of_scan_flat_dt (__fdt_scan_reserved_mem,NULL );fdt_init_reserved_mem (); }
Signature · 1 line
1.9.1
Re: [PATCH v2 15/21] of/fdt: move memreserve and dtb memory reservations into core
Quoted 19 lines · Rob Herring
From: Rob Herring <[email protected]>
Move the /memreserve/ processing and dtb memory reservations into
early_init_fdt_scan_reserved_mem. This converts arm, arm64, and powerpc as they are the only users ofearly_init_fdt_scan_reserved_mem.
memblock_reserveis safe to call on the same region twice, so the reservation check for the dtb in powerpc 32-bit reservations is safe to remove.Signed-off-by Rob Herring <[email protected]>Cc Russell King <[email protected]>Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>Cc Paul Mackerras <[email protected]>---
v2: No change
Quoted 7 lines
arch/arm/include/asm/prom.h | 2 -- arch/arm/kernel/devtree.c | 27 --------------------------- arch/arm/mm/init.c | 1 - arch/arm64/mm/init.c | 21 --------------------- arch/powerpc/kernel/prom.c | 22 ---------------------- drivers/of/fdt.c | 16 ++++++++++++++++ 6 files changed, 16 insertions(+), 73 deletions(-)
For arm64:
PATCH v2 16/21 of/fdt: fix phys_addr_t related print size warnings
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Fix warnings in early_init_dt_reserve_memory_arch when phys_addr_t is 32-bit and memblock is not enabled.
---
v2: New patch
drivers/of/fdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/of/fdt.c +2 -2
@@ -852,8 +852,8 @@ void * __init __weak early_init_dt_alloc_memory_arch(u64 size, u64 align)int __init __weak early_init_dt_reserve_memory_arch (phys_addr_t base,phys_addr_t size,bool nomap) { -pr_err ("Reserved memory not supported, ignoring range 0x%llx - 0x%llx%s\n" , - base, size, nomap ?" (nomap)" :"" ); +pr_err ("Reserved memory not supported, ignoring range 0x%pa - 0x%pa%s\n" , + &base, &size, nomap ?" (nomap)" :"" );return -ENOSYS ; }#endif
Signature · 1 line
1.9.1
PATCH v2 17/21 of/fdt: introduce of_get_flat_dt_size
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Add a wrapper function to retrieve the FDT size from the FDT header. This is primarily to avoid libfdt include paths for the whole kernel.
---
v2: new patch
drivers/of/fdt.c | 8 ++++++++ include/linux/of_fdt.h | 1 + 2 files changed, 9 insertions(+)
drivers/of/fdt.c +8 -0
@@ -554,6 +554,14 @@ unsigned long __init of_get_flat_dt_root(void) }/** +* of_get_flat_dt_size - Return the total size of the FDT +*/ +int __init of_get_flat_dt_size (void ) +{ +return fdt_totalsize (initial_boot_params); +} + +/** * of_get_flat_dt_prop - Given a node in the flat blob, return the property ptr * * This function can be used within scan_flattened_dt callback to get
include/linux/of_fdt.h +1 -0
@@ -92,6 +92,7 @@ extern const void *of_get_flat_dt_prop(unsigned long node, const char *name,extern int of_flat_dt_is_compatible (unsigned long node,const char *name);extern int of_flat_dt_match (unsigned long node,const char *const *matches);extern unsigned long of_get_flat_dt_root (void ); +extern int of_get_flat_dt_size (void );extern int early_init_dt_scan_chosen (unsigned long node,const char *uname,int depth,void *data);
Signature · 1 line
1.9.1
Michal Simek
maintainerRe: [PATCH v2 17/21] of/fdt: introduce of_get_flat_dt_size
Quoted 18 lines · Rob Herring
From: Rob Herring <[email protected]>
Add a wrapper function to retrieve the FDT size from the FDT header. This is primarily to avoid libfdt include paths for the whole kernel.
Signed-off-by Rob Herring <[email protected]>---
v2: new patchdrivers/of/fdt.c | 8 ++++++++ include/linux/of_fdt.h | 1 + 2 files changed, 9 insertions(+)drivers/of/fdt.c +0
-0
drivers/of/fdt.c unsigned long __init of_get_flat_dt_root(void) · line 558
Quoted 5 lines
drivers/of/fdt.c +2
-0@@ -554,6 +554,14 @@ unsigned long __init of_get_flat_dt_root(void) }/** +* of_get_flat_dt_size - Return the total size of the FDT +*/
It looks like that you are trying to use kernel-doc format but I believe this will caused kernel-doc warning.
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 v2 18/21 powerpc: use libfdt accessors for header data
In reply to Rob HerringFrom: Rob Herring <[email protected]>
With libfdt support, we can take advantage of helper accessors in libfdt for accessing the FDT header data. This makes the code more readable and makes the FDT blob structure more opaque to the kernel. This also prepares for removing struct boot_param_header completely.
---
v2: As powerpc is the only platform needing FDT header access, make
prom.c include libfdt directly.
arch/powerpc/kernel/Makefile | 1 + arch/powerpc/kernel/prom.c | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-)
arch/powerpc/kernel/Makefile +1 -0
@@ -2,6 +2,7 @@ # Makefile for the linux kernel. # +CFLAGS_prom.o = -I$(src)/../../../scripts/dtc/libfdt CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"' subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
arch/powerpc/kernel/prom.c +6 -5
@@ -33,6 +33,7 @@#include <linux/memblock.h> #include <linux/of.h> #include <linux/of_fdt.h> +#include <linux/libfdt.h> #include <asm/prom.h> #include <asm/rtas.h>
@@ -117,14 +118,14 @@ static void __init move_device_tree(void)DBG ("-> move_device_tree\n" ); start =__pa (initial_boot_params); - size =be32_to_cpu (initial_boot_params->totalsize); + size =fdt_totalsize (initial_boot_params);if ((memory_limit && (start + size) >PHYSICAL_START + memory_limit) ||overlaps_crashkernel (start, size) ||overlaps_initrd (start, size)) { p =__va (memblock_alloc (size,PAGE_SIZE ));memcpy (p, initial_boot_params, size); - initial_boot_params = (struct boot_param_header *)p; + initial_boot_params = p;DBG ("Moved device tree to 0x%p\n" , p); }
@@ -324,9 +325,9 @@ static int __init early_init_dt_scan_cpus(unsigned long node,* version 2 of the kexec param format adds the phys cpuid of * booted proc. */ -if (be32_to_cpu (initial_boot_params->version) >=2 ) { +if (fdt_version (initial_boot_params) >=2 ) {if (be32_to_cpu (intserv[i]) == -be32_to_cpu (initial_boot_params->boot_cpuid_phys)) { +fdt_boot_cpuid_phys (initial_boot_params)) { found = boot_cpu_count; found_thread = i; }
@@ -599,7 +600,7 @@ static void __init early_reserve_mem(void)__be64 *reserve_map; reserve_map = (__be64 *)(((unsigned long )initial_boot_params) + -be32_to_cpu (initial_boot_params->off_mem_rsvmap)); +fdt_off_mem_rsvmap (initial_boot_params));/* Look for the new "reserved-regions" property in the DT */ early_reserve_mem_dt ();
Signature · 1 line
1.9.1
Michal Simek
maintainerRe: [PATCH v2 18/21] powerpc: use libfdt accessors for header data
Quoted 43 lines · Rob Herring
From: Rob Herring <[email protected]>
With libfdt support, we can take advantage of helper accessors in libfdt for accessing the FDT header data. This makes the code more readable and makes the FDT blob structure more opaque to the kernel. This also prepares for removing struct
boot_param_headercompletely.Signed-off-by Rob Herring <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>Cc Paul Mackerras <[email protected]>---
v2: As powerpc is the only platform needing FDT header access, make
prom.cinclude libfdt directly.arch/powerpc/kernel/Makefile | 1 + arch/powerpc/kernel/prom.c | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-)arch/powerpc/kernel/Makefile +1
-0@@ -2,6 +2,7 @@ # Makefile for the linux kernel. # +CFLAGS_prom.o = -I$(src)/../../../scripts/dtc/libfdt CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"' subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werrorarch/powerpc/kernel/prom.c +1
-0@@ -33,6 +33,7 @@#include <linux/memblock.h> #include <linux/of.h> #include <linux/of_fdt.h> +#include <linux/libfdt.h> #include <asm/prom.h> #include <asm/rtas.h>
arch/powerpc/kernel/prom.c static void __init move_device_tree(void) · line 121
Quoted 5 lines
arch/powerpc/kernel/prom.c +1
-1@@ -117,14 +118,14 @@ static void __init move_device_tree(void)DBG ("-> move_device_tree\n" ); start =__pa (initial_boot_params); - size =be32_to_cpu (initial_boot_params->totalsize); + size =fdt_totalsize (initial_boot_params);
In 19/21 you use your newly introduced of_get_flat_dt_size() that's why I expect you will use it here too.
size = of_get_flat_dt_size();
The same is for 14/21 where you can use this new function too. It means moving 14/21 to the end and using this new function makes more sense.
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
Re: [PATCH v2 18/21] powerpc: use libfdt accessors for header data
Quoted 7 lines · Michal Simek
Quoted 6 lines · Rob Herring
From: Rob Herring <[email protected]>
With libfdt support, we can take advantage of helper accessors in libfdt for accessing the FDT header data. This makes the code more readable and makes the FDT blob structure more opaque to the kernel. This also prepares for removing struct
boot_param_headercompletely.
[...]
Quoted 11 lines
arch/powerpc/kernel/prom.c static void __init move_device_tree(void) · line 121
Quoted 6 lines
arch/powerpc/kernel/prom.c +1
-1@@ -117,14 +118,14 @@ static void __init move_device_tree(void)DBG ("-> move_device_tree\n" ); start =__pa (initial_boot_params); - size =be32_to_cpu (initial_boot_params->totalsize); + size =fdt_totalsize (initial_boot_params);In 19/21 you use your newly introduced
of_get_flat_dt_size()that's why I expect you will use it here too.
size =of_get_flat_dt_size();
Quoted 3 lines
The same is for 14/21 where you can use this new function too. It means moving 14/21 to the end and using this new function makes more sense.
Really, I would prefer to just use libfdt accessors directly rather than have wrappers, but including libfdt.h is not the cleanest solution. Since x86 just needed this one function, I added a wrapper. Since PPC needs other header fields I prefer to use the libfdt accessors directly for all fields. The same goes for drivers/of/fdt.c.
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
Michal Simek
maintainerRe: [PATCH v2 18/21] powerpc: use libfdt accessors for header data
Quoted 26 lines · Rob Herring
Quoted 7 lines · Michal Simek
Quoted 6 lines · Rob Herring
From: Rob Herring <[email protected]>
With libfdt support, we can take advantage of helper accessors in libfdt for accessing the FDT header data. This makes the code more readable and makes the FDT blob structure more opaque to the kernel. This also prepares for removing struct
boot_param_headercompletely.[...]
Quoted 11 lines
arch/powerpc/kernel/prom.c static void __init move_device_tree(void) · line 121
Quoted 6 lines
arch/powerpc/kernel/prom.c +1
-1@@ -117,14 +118,14 @@ static void __init move_device_tree(void)DBG ("-> move_device_tree\n" ); start =__pa (initial_boot_params); - size =be32_to_cpu (initial_boot_params->totalsize); + size =fdt_totalsize (initial_boot_params);In 19/21 you use your newly introduced
of_get_flat_dt_size()that's why I expect you will use it here too.
size =of_get_flat_dt_size();Quoted 3 lines
The same is for 14/21 where you can use this new function too. It means moving 14/21 to the end and using this new function makes more sense.
Quoted 5 lines
Really, I would prefer to just use libfdt accessors directly rather than have wrappers, but including
libfdt.his not the cleanest solution. Since x86 just needed this one function, I added a wrapper. Since PPC needs other header fields I prefer to use the libfdt accessors directly for all fields. The same goes fordrivers/of/fdt.c.
Ok. I see your point but maybe will be good to reflect that it is there just for x86 case and none else should use it.
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 v2 19/21 x86: use FDT accessors for FDT blob header data
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Remove the direct accesses to FDT header data using accessor function instead. This makes the code more readable and makes the FDT blob structure more opaque to the arch code. This also prepares for removing struct boot_param_header completely.
---
v2: reworked to use of_get_flat_dt_size helper function
arch/x86/kernel/devicetree.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
arch/x86/kernel/devicetree.c +5 -7
@@ -206,23 +206,21 @@ static void __init dtb_apic_setup(void)static void __init x86_flattree_get_config (void ) {u32 size, map_len; -struct boot_param_header *dt; +void *dt;if (!initial_dtb)return ; - map_len =max (PAGE_SIZE - (initial_dtb & ~PAGE_MASK ), - (u64 )sizeof (struct boot_param_header )); + map_len =max (PAGE_SIZE - (initial_dtb & ~PAGE_MASK ), (u64 )128 ); - dt =early_memremap (initial_dtb, map_len); - size =be32_to_cpu (dt->totalsize); + initial_boot_params = dt =early_memremap (initial_dtb, map_len); + size =of_get_flat_dt_size ();if (map_len < size) {early_iounmap (dt, map_len); - dt =early_memremap (initial_dtb, size); + initial_boot_params = dt =early_memremap (initial_dtb, size); map_len = size; } - initial_boot_params = dt;unflatten_and_copy_device_tree ();early_iounmap (dt, map_len); }
Signature · 1 line
1.9.1
PATCH v2 20/21 of/fdt: convert initial_boot_params to opaque pointer
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Now that all accesses to FDT header data has been converted to accessor helpers, initial_boot_params can become an opaque pointer.
---
v2: no change
drivers/of/fdt.c | 2 +- include/linux/of_fdt.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/of/fdt.c +1 -1
@@ -372,7 +372,7 @@ EXPORT_SYMBOL_GPL(of_fdt_unflatten_tree);int __initdata dt_root_addr_cells;int __initdata dt_root_size_cells; -struct boot_param_header *initial_boot_params; +void *initial_boot_params;#ifdef CONFIG_OF_EARLY_FLATTREE
include/linux/of_fdt.h +1 -1
@@ -78,7 +78,7 @@ extern void of_fdt_unflatten_tree(unsigned long *blob,/* TBD: Temporary export of fdt globals - remove when code fully merged */ extern int __initdata dt_root_addr_cells;extern int __initdata dt_root_size_cells; -extern struct boot_param_header *initial_boot_params; +extern void *initial_boot_params;extern char __dtb_start[];extern char __dtb_end[];
Signature · 1 line
1.9.1
PATCH v2 21/21 of: push struct boot_param_header and defines into powerpc
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Now powerpc is the only user of struct boot_param_header and FDT defines, so they can be moved into the powerpc architecture code.
---
v2: no change
arch/powerpc/include/asm/prom.h | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/of_fdt.h | 37 ------------------------------------- 2 files changed, 39 insertions(+), 37 deletions(-)
arch/powerpc/include/asm/prom.h +39 -0
@@ -26,6 +26,45 @@#include <linux/of_irq.h> #include <linux/platform_device.h> +#define OF_DT_BEGIN_NODE 0x1/* Start of node, full name */ +#define OF_DT_END_NODE 0x2/* End node */ +#define OF_DT_PROP 0x3/* Property: name off, size, +* content */ +#define OF_DT_NOP 0x4/* nop */ +#define OF_DT_END 0x9 + +#define OF_DT_VERSION 0x10 + +/* +* This is what gets passed to the kernel by prom_init or kexec +* +* The dt struct contains the device tree structure, full pathes and +* property contents. The dt strings contain a separate block with just +* the strings for the property names, and is fully page aligned and +* self contained in a page, so that it can be kept around by the kernel, +* each property name appears only once in this page (cheap compression) +* +* the mem_rsvmap contains a map of reserved ranges of physical memory, +* passing it here instead of in the device-tree itself greatly simplifies +* the job of everybody. It's just a list of u64 pairs (base/size) that +* ends when size is 0 +*/ +struct boot_param_header { +__be32 magic;/* magic word OF_DT_HEADER */ +__be32 totalsize;/* total size of DT block */ +__be32 off_dt_struct;/* offset to structure */ +__be32 off_dt_strings;/* offset to strings */ +__be32 off_mem_rsvmap;/* offset to memory reserve map */ +__be32 version;/* format version */ +__be32 last_comp_version;/* last compatible version */ +/* version 2 fields below */ +__be32 boot_cpuid_phys;/* Physical CPU id we're booting on */ +/* version 3 fields below */ +__be32 dt_strings_size;/* size of the DT strings block */ +/* version 17 fields below */ +__be32 dt_struct_size;/* size of the DT structure block */ +}; +/* * OF address retreival & translation */
include/linux/of_fdt.h +0 -37
@@ -17,45 +17,8 @@/* Definitions used by the flattened device tree */ #define OF_DT_HEADER 0xd00dfeed/* marker */ -#define OF_DT_BEGIN_NODE 0x1/* Start of node, full name */ -#define OF_DT_END_NODE 0x2/* End node */ -#define OF_DT_PROP 0x3/* Property: name off, size, -* content */ -#define OF_DT_NOP 0x4/* nop */ -#define OF_DT_END 0x9 - -#define OF_DT_VERSION 0x10#ifndef __ASSEMBLY__ -/* -* This is what gets passed to the kernel by prom_init or kexec -* -* The dt struct contains the device tree structure, full pathes and -* property contents. The dt strings contain a separate block with just -* the strings for the property names, and is fully page aligned and -* self contained in a page, so that it can be kept around by the kernel, -* each property name appears only once in this page (cheap compression) -* -* the mem_rsvmap contains a map of reserved ranges of physical memory, -* passing it here instead of in the device-tree itself greatly simplifies -* the job of everybody. It's just a list of u64 pairs (base/size) that -* ends when size is 0 -*/ -struct boot_param_header { -__be32 magic;/* magic word OF_DT_HEADER */ -__be32 totalsize;/* total size of DT block */ -__be32 off_dt_struct;/* offset to structure */ -__be32 off_dt_strings;/* offset to strings */ -__be32 off_mem_rsvmap;/* offset to memory reserve map */ -__be32 version;/* format version */ -__be32 last_comp_version;/* last compatible version */ -/* version 2 fields below */ -__be32 boot_cpuid_phys;/* Physical CPU id we're booting on */ -/* version 3 fields below */ -__be32 dt_strings_size;/* size of the DT strings block */ -/* version 17 fields below */ -__be32 dt_struct_size;/* size of the DT structure block */ -};#if defined(CONFIG_OF_FLATTREE )
Signature · 1 line
1.9.1
Re: [PATCH v2 21/21] of: push struct boot_param_header and defines into powerpc
Quoted 10 lines · Rob Herring
From: Rob Herring <[email protected]>
Now powerpc is the only user of struct
boot_param_headerand FDT defines, so they can be moved into the powerpc architecture code.Signed-off-by Rob Herring <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>Cc Paul Mackerras <[email protected]>---
I assume we want to get rid of that too eventually ? :-)
We should be able to get the definitions from libfdt too....
In the meantime:
--
Quoted 106 lines
v2: no change
arch/powerpc/include/asm/prom.h | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/of_fdt.h | 37 ------------------------------------- 2 files changed, 39 insertions(+), 37 deletions(-)arch/powerpc/include/asm/prom.h +39
-0@@ -26,6 +26,45 @@#include <linux/of_irq.h> #include <linux/platform_device.h> +#define OF_DT_BEGIN_NODE 0x1/* Start of node, full name */ +#define OF_DT_END_NODE 0x2/* End node */ +#define OF_DT_PROP 0x3/* Property: name off, size, +* content */ +#define OF_DT_NOP 0x4/* nop */ +#define OF_DT_END 0x9 + +#define OF_DT_VERSION 0x10 + +/* +* This is what gets passed to the kernel by prom_init or kexec +* +* The dt struct contains the device tree structure, full pathes and +* property contents. The dt strings contain a separate block with just +* the strings for the property names, and is fully page aligned and +* self contained in a page, so that it can be kept around by the kernel, +* each property name appears only once in this page (cheap compression) +* +* the mem_rsvmap contains a map of reserved ranges of physical memory, +* passing it here instead of in the device-tree itself greatly simplifies +* the job of everybody. It's just a list of u64 pairs (base/size) that +* ends when size is 0 +*/ +struct boot_param_header { +__be32 magic;/* magic word OF_DT_HEADER */ +__be32 totalsize;/* total size of DT block */ +__be32 off_dt_struct;/* offset to structure */ +__be32 off_dt_strings;/* offset to strings */ +__be32 off_mem_rsvmap;/* offset to memory reserve map */ +__be32 version;/* format version */ +__be32 last_comp_version;/* last compatible version */ +/* version 2 fields below */ +__be32 boot_cpuid_phys;/* Physical CPU id we're booting on */ +/* version 3 fields below */ +__be32 dt_strings_size;/* size of the DT strings block */ +/* version 17 fields below */ +__be32 dt_struct_size;/* size of the DT structure block */ +}; +/* * OF address retreival & translation */ include/linux/of_fdt.h +0
-37@@ -17,45 +17,8 @@/* Definitions used by the flattened device tree */ #define OF_DT_HEADER 0xd00dfeed/* marker */ -#define OF_DT_BEGIN_NODE 0x1/* Start of node, full name */ -#define OF_DT_END_NODE 0x2/* End node */ -#define OF_DT_PROP 0x3/* Property: name off, size, -* content */ -#define OF_DT_NOP 0x4/* nop */ -#define OF_DT_END 0x9 - -#define OF_DT_VERSION 0x10#ifndef __ASSEMBLY__ -/* -* This is what gets passed to the kernel by prom_init or kexec -* -* The dt struct contains the device tree structure, full pathes and -* property contents. The dt strings contain a separate block with just -* the strings for the property names, and is fully page aligned and -* self contained in a page, so that it can be kept around by the kernel, -* each property name appears only once in this page (cheap compression) -* -* the mem_rsvmap contains a map of reserved ranges of physical memory, -* passing it here instead of in the device-tree itself greatly simplifies -* the job of everybody. It's just a list of u64 pairs (base/size) that -* ends when size is 0 -*/ -struct boot_param_header { -__be32 magic;/* magic word OF_DT_HEADER */ -__be32 totalsize;/* total size of DT block */ -__be32 off_dt_struct;/* offset to structure */ -__be32 off_dt_strings;/* offset to strings */ -__be32 off_mem_rsvmap;/* offset to memory reserve map */ -__be32 version;/* format version */ -__be32 last_comp_version;/* last compatible version */ -/* version 2 fields below */ -__be32 boot_cpuid_phys;/* Physical CPU id we're booting on */ -/* version 3 fields below */ -__be32 dt_strings_size;/* size of the DT strings block */ -/* version 17 fields below */ -__be32 dt_struct_size;/* size of the DT structure block */ -};#if defined(CONFIG_OF_FLATTREE )
Quoted 81 lines · Rob Herring
From: Rob Herring <[email protected]>
This is a series of clean-ups of architecture FDT code and converts the core FDT code over to using libfdt functions. This is in preparation to add FDT based address translation parsing functions for early console support. This series removes direct access to FDT data from all arches except powerpc.
The current MIPS lantiq and xlp DT code is buggy as built-in DTBs need to be copied out of init section. Patches 2 and 3 should be applied to 3.15.
Changes in v2 are relatively minor. There was a bug in the unflattening code where walking up the tree was not being handled correctly (thanks to Michal Simek). I re-worked things a bit to avoid globally adding libfdt include paths.
A branch is available here[1], and I plan to put into linux-next in a few days. Please test! I've compiled on arm, arm64, mips, microblaze, xtensa, and powerpc and booted on arm and arm64.
Rob
[1]
git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.gitlibfdtRob Herring (21):
mips: octeon: convert to useunflatten_and_copy_device_tree
mips: lantiq: copy built-in DTB out of init section
mips: xlp: copy built-in DTB out of init section
mips: ralink: convert to useunflatten_and_copy_device_tree
ARM: dt: use defaultearly_init_dt_alloc_memory_arch
c6x: convert fdt pointers to opaque pointers
mips: convert fdt pointers to opaque pointers of/fdt: consolidate built-in dtb section variables of/fdt: remove some unneeded includes
of/fdt: remove unusedof_scan_flat_dt_by_pathof/fdt: updateof_get_flat_dt_propin prep for libfdt of/fdt: Convert FDT functions to use libfdt
of/fdt: use libfdt accessors for header data of/fdt: create common debugfs
of/fdt: move memreserve and dtb memory reservations into core of/fdt: fixphys_addr_trelated print size warnings of/fdt: introduceof_get_flat_dt_size
powerpc: use libfdt accessors for header data
x86: use FDT accessors for FDT blob header data of/fdt: convertinitial_boot_paramsto opaque pointer
of: push structboot_param_headerand defines into powerpcarch/arc/include/asm/sections.h | 1 - arch/arc/kernel/devtree.c | 2 +- arch/arm/include/asm/prom.h | 2 - arch/arm/kernel/devtree.c | 34 +-- arch/arm/mach-exynos/exynos.c | 2 +- arch/arm/mach-vexpress/platsmp.c | 2 +- arch/arm/mm/init.c | 1 - arch/arm/plat-samsung/s5p-dev-mfc.c | 4 +- arch/arm64/mm/init.c | 21 -- arch/c6x/kernel/setup.c | 4 +- arch/metag/kernel/setup.c | 4 - arch/microblaze/kernel/prom.c | 39 +-- arch/mips/cavium-octeon/setup.c | 20 +- arch/mips/include/asm/mips-boards/generic.h | 4 - arch/mips/include/asm/prom.h | 6 +- arch/mips/kernel/prom.c | 2 +- arch/mips/lantiq/prom.c | 15 +- arch/mips/lantiq/prom.h | 2 - arch/mips/mti-sead3/sead3-setup.c | 8 +- arch/mips/netlogic/xlp/dt.c | 19 +- arch/mips/ralink/of.c | 29 +- arch/openrisc/kernel/vmlinux.h | 2 - arch/powerpc/include/asm/prom.h | 39 +++ arch/powerpc/kernel/Makefile | 1 + arch/powerpc/kernel/epapr_paravirt.c | 2 +- arch/powerpc/kernel/fadump.c | 4 +- arch/powerpc/kernel/prom.c | 78 ++---- arch/powerpc/kernel/rtas.c | 2 +- arch/powerpc/mm/hash_utils_64.c | 22 +- arch/powerpc/platforms/52xx/efika.c | 4 +- arch/powerpc/platforms/chrp/setup.c | 4 +- arch/powerpc/platforms/powernv/opal.c | 12 +- arch/powerpc/platforms/pseries/setup.c | 4 +-
Quoted 9 lines
arch/x86/kernel/devicetree.c | 12 +- arch/xtensa/kernel/setup.c | 3 +- drivers/of/Kconfig | 1 + drivers/of/Makefile | 2 + drivers/of/fdt.c | 398 ++++++++++------------------ drivers/of/of_reserved_mem.c | 4 +- include/linux/of_fdt.h | 63 +---- 40 files changed, 280 insertions(+), 598 deletions(-)
For Microblaze and generic changes:
Thanks,
Michal
Signature · 14 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 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 263 bytes Desc: OpenPGP digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140423/2c1e5287/attachment-0001.sig>
Max Filippov
maintainerQuoted 17 lines · Rob Herring
From: Rob Herring <[email protected]>
This is a series of clean-ups of architecture FDT code and converts the core FDT code over to using libfdt functions. This is in preparation to add FDT based address translation parsing functions for early console support. This series removes direct access to FDT data from all arches except powerpc.
The current MIPS lantiq and xlp DT code is buggy as built-in DTBs need to be copied out of init section. Patches 2 and 3 should be applied to 3.15.
Changes in v2 are relatively minor. There was a bug in the unflattening code where walking up the tree was not being handled correctly (thanks to Michal Simek). I re-worked things a bit to avoid globally adding libfdt include paths.
Quoted 7 lines
A branch is available here[1], and I plan to put into linux-next in a few days. Please test! I've compiled on arm, arm64, mips, microblaze, xtensa, and powerpc and booted on arm and arm64.
Rob
[1]
git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.gitlibfdt
For xtensa: Tested-by: Max Filippov <[email protected]>
Signature · 2 lines
Thanks. -- Max
Quoted 12 lines · Rob Herring
From: Rob Herring <[email protected]>
This is a series of clean-ups of architecture FDT code and converts the core FDT code over to using libfdt functions. This is in preparation to add FDT based address translation parsing functions for early console support. This series removes direct access to FDT data from all arches except powerpc.
The current MIPS lantiq and xlp DT code is buggy as built-in DTBs need to be copied out of init section. Patches 2 and 3 should be applied to 3.15.
Quoted 8 lines
Changes in v2 are relatively minor. There was a bug in the unflattening code where walking up the tree was not being handled correctly (thanks to Michal Simek). I re-worked things a bit to avoid globally adding libfdt include paths.
A branch is available here[1], and I plan to put into linux-next in a few days. Please test! I've compiled on arm, arm64, mips, microblaze, xtensa, and powerpc and booted on arm and arm64.
This is pretty great work. I'll read through them again and I may have a comment or two, but in general you can add my tested by tag:
Quoted 1 line
40 files changed, 280 insertions(+), 598 deletions(-)
I love the diffstat!
g.
Quoted 23 lines
From: Rob Herring <[email protected]>
To: Grant Likely <[email protected]>, linux- [email protected], [email protected]
Cc: Rob Herring <[email protected]>, Aurelien Jacquiot <a- [email protected]>, Benjamin Herrenschmidt <[email protected]>, Chris Zankel <[email protected]>, "H. Peter Anvin" <[email protected]>, Ingo Molnar <[email protected]>, James Hogan <[email protected]>
Date: 04/30/2014 09:45 AM
Subject: [PATCH v2 00/21] FDT clean-ups and libfdt support Sent by: [email protected]From: Rob Herring <[email protected]>
This is a series of clean-ups of architecture FDT code and converts the core FDT code over to using libfdt functions. This is in preparation to add FDT based address translation parsing functions for early console support. This series removes direct access to FDT data from all arches except powerpc.
The current MIPS lantiq and xlp DT code is buggy as built-in DTBs need to be copied out of init section. Patches 2 and 3 should be applied to 3.15.
Quoted 6 lines
Changes in v2 are relatively minor. There was a bug in the unflattening code where walking up the tree was not being handled correctly (thanks to Michal Simek). I re-worked things a bit to avoid globally adding libfdt include paths.
A branch is available here[1], and I plan to put into linux-next in a
few
Quoted 1 line
days. Please test! I've compiled on arm, arm64, mips, microblaze,
xtensa,
Quoted 1 line
and powerpc and booted on arm and arm64.
I have tested this for PowerPC using a snapshot of libfdt[1] collected from
the today (30/04/2014).
The computers used were 32 bit, Freescale and IBM/AMCC CPUs:
MVME5100 - Motorola/Fresscale CPU - PPCBug firmware SAM440EP - IBM/AMCC - U-Boot firmware
Stephen Chivers,
CSC Australia Pty. Ltd.
[1] git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git libfdt