From patchwork Wed Jun 17 23:51:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 242587 List-Id: U-Boot discussion From: atish.patra at wdc.com (Atish Patra) Date: Wed, 17 Jun 2020 16:51:30 -0700 Subject: [PATCH 1/2] riscv: Use correct version of fdtdec_get_addr_size Message-ID: <20200617235131.21374-1-atish.patra@wdc.com> fdtdec_get_addr_size uses a fixed value for address_cells & size_cells which may not work correctly always. fdtdec_get_addr_size_no_parent will automatically calculate the cell sizes from parent but not optimized especially when parent node is already available with the caller. Use fdtdec_get_addr_size_auto_parent that automatically calculate the cell sizes and optimized for the given usecase. Signed-off-by: Atish Patra --- arch/riscv/lib/fdt_fixup.c | 2 +- lib/fdtdec.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c index 6db48ad04a56..f2ec37b57b15 100644 --- a/arch/riscv/lib/fdt_fixup.c +++ b/arch/riscv/lib/fdt_fixup.c @@ -44,7 +44,7 @@ int riscv_fdt_copy_resv_mem_node(const void *src, void *dst) fdt_for_each_subnode(node, src, offset) { name = fdt_get_name(src, node, NULL); - addr = fdtdec_get_addr_size_auto_noparent(src, node, + addr = fdtdec_get_addr_size_auto_parent(src, offset, node, "reg", 0, &size, false); if (addr == FDT_ADDR_T_NONE) { diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 1f2b763acc31..b62eb142ccc3 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1296,7 +1296,8 @@ int fdtdec_add_reserved_memory(void *blob, const char *basename, const char *name = fdt_get_name(blob, node, NULL); phys_addr_t addr, size; - addr = fdtdec_get_addr_size(blob, node, "reg", &size); + addr = fdtdec_get_addr_size_auto_parent(blob, parent, node, + "reg", 0, &size, false); if (addr == FDT_ADDR_T_NONE) { debug("failed to read address/size for %s\n", name); continue; From patchwork Wed Jun 17 23:51:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 242588 List-Id: U-Boot discussion From: atish.patra at wdc.com (Atish Patra) Date: Wed, 17 Jun 2020 16:51:31 -0700 Subject: [PATCH 2/2] riscv: Do not return error if reserved node already exists In-Reply-To: <20200617235131.21374-1-atish.patra@wdc.com> References: <20200617235131.21374-1-atish.patra@wdc.com> Message-ID: <20200617235131.21374-2-atish.patra@wdc.com> Not all errors are fatal. If a reserved memory node already exists in the destination device tree, we can continue to boot without failing. Signed-off-by: Atish Patra --- arch/riscv/lib/fdt_fixup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c index f2ec37b57b15..00b84dccbef0 100644 --- a/arch/riscv/lib/fdt_fixup.c +++ b/arch/riscv/lib/fdt_fixup.c @@ -62,7 +62,7 @@ int riscv_fdt_copy_resv_mem_node(const void *src, void *dst) pmp_mem.end = addr + size - 1; err = fdtdec_add_reserved_memory(dst, basename, &pmp_mem, &phandle); - if (err < 0) { + if (err < 0 && err != FDT_ERR_EXISTS) { printf("failed to add reserved memory: %d\n", err); return err; }