* No subject @ 2013-06-19 10:57 Ben Dooks 2013-06-19 10:57 ` [PATCH] atags_to_fdt: take into account root's #size and #cells Ben Dooks 0 siblings, 1 reply; 5+ messages in thread From: Ben Dooks @ 2013-06-19 10:57 UTC (permalink / raw) To: linux-arm-kernel I found this one whilst testing versatile-express with a -rc kernel and was considering if this is the correct way to fix this. [PATCH] atags_to_fdt: take into account root's #size and #cells ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] atags_to_fdt: take into account root's #size and #cells 2013-06-19 10:57 No subject Ben Dooks @ 2013-06-19 10:57 ` Ben Dooks 2013-06-19 11:11 ` Thomas Petazzoni 2013-06-19 11:12 ` Gregory CLEMENT 0 siblings, 2 replies; 5+ messages in thread From: Ben Dooks @ 2013-06-19 10:57 UTC (permalink / raw) To: linux-arm-kernel When creating entries for /memory, the root #size and #cells must be taken into account otherwise the node will not be recongnized when the OF code scans the nodes. On some systems, the default is now to be 2 for each of #size and #cells which means that appending a kernrel and having it update from ATAGS does not work properly. --- arch/arm/boot/compressed/atags_to_fdt.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c index 74e193e..da36840 100644 --- a/arch/arm/boot/compressed/atags_to_fdt.c +++ b/arch/arm/boot/compressed/atags_to_fdt.c @@ -1,5 +1,6 @@ #include <asm/setup.h> #include <libfdt.h> +#include <linux/of.h> #if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND) #define do_extend_cmdline 1 @@ -95,9 +96,12 @@ static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline) int atags_to_fdt(void *atag_list, void *fdt, int total_space) { struct tag *atag = atag_list; - uint32_t mem_reg_property[2 * NR_BANKS]; + uint32_t mem_reg_property[2 * 2 * NR_BANKS]; + const __be32 *prop; int memcount = 0; int ret; + u32 dt_root_size_cells; + u32 dt_root_addr_cells; /* make sure we've got an aligned pointer */ if ((u32)atag_list & 0x3) @@ -118,6 +122,17 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space) if (ret < 0) return ret; + dt_root_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT; + dt_root_addr_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT; + + prop = getprop(fdt, "/", "#size-cells", NULL); + if (prop) + dt_root_size_cells = be32_to_cpup(prop); + + prop = getprop(fdt, "/", "#address-cells", NULL); + if (prop) + dt_root_addr_cells = be32_to_cpup(prop); + for_each_tag(atag, atag_list) { if (atag->hdr.tag == cpu_to_atag32(ATAG_CMDLINE)) { /* Append the ATAGS command line to the device tree @@ -137,7 +152,12 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space) continue; if (!atag32_to_cpu(atag->u.mem.size)) continue; + + for (ret = 0; ret < dt_root_addr_cells - 1; ret++) + mem_reg_property[memcount++] = cpu_to_fdt32(0); mem_reg_property[memcount++] = cpu_to_fdt32(atag32_to_cpu(atag->u.mem.start)); + for (ret = 0; ret < dt_root_size_cells - 1; ret++) + mem_reg_property[memcount++] = cpu_to_fdt32(0); mem_reg_property[memcount++] = cpu_to_fdt32(atag32_to_cpu(atag->u.mem.size)); } else if (atag->hdr.tag == cpu_to_atag32(ATAG_INITRD2)) { uint32_t initrd_start, initrd_size; -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] atags_to_fdt: take into account root's #size and #cells 2013-06-19 10:57 ` [PATCH] atags_to_fdt: take into account root's #size and #cells Ben Dooks @ 2013-06-19 11:11 ` Thomas Petazzoni 2013-06-19 11:42 ` Ben Dooks 2013-06-19 11:12 ` Gregory CLEMENT 1 sibling, 1 reply; 5+ messages in thread From: Thomas Petazzoni @ 2013-06-19 11:11 UTC (permalink / raw) To: linux-arm-kernel Dear Ben Dooks, On Wed, 19 Jun 2013 11:57:51 +0100, Ben Dooks wrote: > When creating entries for /memory, the root #size and #cells must be taken > into account otherwise the node will not be recongnized when the OF code > scans the nodes. > > On some systems, the default is now to be 2 for each of #size and #cells > which means that appending a kernrel and having it update from ATAGS does > not work properly. > --- > arch/arm/boot/compressed/atags_to_fdt.c | 22 +++++++++++++++++++++- > 1 file changed, 21 insertions(+), 1 deletion(-) Isn't this the same https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=faefd550c45d8d314e8f260f21565320355c947f which is already in linux-next? Best regards, Thomas -- Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] atags_to_fdt: take into account root's #size and #cells 2013-06-19 11:11 ` Thomas Petazzoni @ 2013-06-19 11:42 ` Ben Dooks 0 siblings, 0 replies; 5+ messages in thread From: Ben Dooks @ 2013-06-19 11:42 UTC (permalink / raw) To: linux-arm-kernel On 19/06/13 12:11, Thomas Petazzoni wrote: > Dear Ben Dooks, > > On Wed, 19 Jun 2013 11:57:51 +0100, Ben Dooks wrote: >> When creating entries for /memory, the root #size and #cells must be taken >> into account otherwise the node will not be recongnized when the OF code >> scans the nodes. >> >> On some systems, the default is now to be 2 for each of #size and #cells >> which means that appending a kernrel and having it update from ATAGS does >> not work properly. >> --- >> arch/arm/boot/compressed/atags_to_fdt.c | 22 +++++++++++++++++++++- >> 1 file changed, 21 insertions(+), 1 deletion(-) > > Isn't this the same > https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=faefd550c45d8d314e8f260f21565320355c947f > which is already in linux-next? Ah, it is almost the same although it only takes into account the #size-cells but not the number of them. -- Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] atags_to_fdt: take into account root's #size and #cells 2013-06-19 10:57 ` [PATCH] atags_to_fdt: take into account root's #size and #cells Ben Dooks 2013-06-19 11:11 ` Thomas Petazzoni @ 2013-06-19 11:12 ` Gregory CLEMENT 1 sibling, 0 replies; 5+ messages in thread From: Gregory CLEMENT @ 2013-06-19 11:12 UTC (permalink / raw) To: linux-arm-kernel On 06/19/2013 12:57 PM, Ben Dooks wrote: > When creating entries for /memory, the root #size and #cells must be taken > into account otherwise the node will not be recongnized when the OF code > scans the nodes. > > On some systems, the default is now to be 2 for each of #size and #cells > which means that appending a kernrel and having it update from ATAGS does > not work properly. Hi Ben, There is already a fix for it which is applied in Russell King's git tree, see http://www.arm.linux.org.uk/developer/patches/viewpatch.php?id=7722/1 Regards, > --- > arch/arm/boot/compressed/atags_to_fdt.c | 22 +++++++++++++++++++++- > 1 file changed, 21 insertions(+), 1 deletion(-) > > diff --git a/arch/arm/boot/compressed/atags_to_fdt.c b/arch/arm/boot/compressed/atags_to_fdt.c > index 74e193e..da36840 100644 > --- a/arch/arm/boot/compressed/atags_to_fdt.c > +++ b/arch/arm/boot/compressed/atags_to_fdt.c > @@ -1,5 +1,6 @@ > #include <asm/setup.h> > #include <libfdt.h> > +#include <linux/of.h> > > #if defined(CONFIG_ARM_ATAG_DTB_COMPAT_CMDLINE_EXTEND) > #define do_extend_cmdline 1 > @@ -95,9 +96,12 @@ static void merge_fdt_bootargs(void *fdt, const char *fdt_cmdline) > int atags_to_fdt(void *atag_list, void *fdt, int total_space) > { > struct tag *atag = atag_list; > - uint32_t mem_reg_property[2 * NR_BANKS]; > + uint32_t mem_reg_property[2 * 2 * NR_BANKS]; > + const __be32 *prop; > int memcount = 0; > int ret; > + u32 dt_root_size_cells; > + u32 dt_root_addr_cells; > > /* make sure we've got an aligned pointer */ > if ((u32)atag_list & 0x3) > @@ -118,6 +122,17 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space) > if (ret < 0) > return ret; > > + dt_root_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT; > + dt_root_addr_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT; > + > + prop = getprop(fdt, "/", "#size-cells", NULL); > + if (prop) > + dt_root_size_cells = be32_to_cpup(prop); > + > + prop = getprop(fdt, "/", "#address-cells", NULL); > + if (prop) > + dt_root_addr_cells = be32_to_cpup(prop); > + > for_each_tag(atag, atag_list) { > if (atag->hdr.tag == cpu_to_atag32(ATAG_CMDLINE)) { > /* Append the ATAGS command line to the device tree > @@ -137,7 +152,12 @@ int atags_to_fdt(void *atag_list, void *fdt, int total_space) > continue; > if (!atag32_to_cpu(atag->u.mem.size)) > continue; > + > + for (ret = 0; ret < dt_root_addr_cells - 1; ret++) > + mem_reg_property[memcount++] = cpu_to_fdt32(0); > mem_reg_property[memcount++] = cpu_to_fdt32(atag32_to_cpu(atag->u.mem.start)); > + for (ret = 0; ret < dt_root_size_cells - 1; ret++) > + mem_reg_property[memcount++] = cpu_to_fdt32(0); > mem_reg_property[memcount++] = cpu_to_fdt32(atag32_to_cpu(atag->u.mem.size)); > } else if (atag->hdr.tag == cpu_to_atag32(ATAG_INITRD2)) { > uint32_t initrd_start, initrd_size; > -- Gregory Clement, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-06-19 11:42 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-06-19 10:57 No subject Ben Dooks 2013-06-19 10:57 ` [PATCH] atags_to_fdt: take into account root's #size and #cells Ben Dooks 2013-06-19 11:11 ` Thomas Petazzoni 2013-06-19 11:42 ` Ben Dooks 2013-06-19 11:12 ` Gregory CLEMENT
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.