From patchwork Fri Jun 19 01:51:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 242647 List-Id: U-Boot discussion From: atish.patra at wdc.com (Atish Patra) Date: Thu, 18 Jun 2020 18:51:48 -0700 Subject: [PATCH 1/3] riscv: Do not return error if reserved node already exists In-Reply-To: <20200619015150.27745-1-atish.patra@wdc.com> References: <20200619015150.27745-1-atish.patra@wdc.com> Message-ID: <20200619015150.27745-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 6db48ad04a56..91524d9a5ae9 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; } From patchwork Fri Jun 19 01:51:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 242648 List-Id: U-Boot discussion From: atish.patra at wdc.com (Atish Patra) Date: Thu, 18 Jun 2020 18:51:49 -0700 Subject: [PATCH 2/3] riscv: Use optimized version of fdtdec_get_addr_size_no_parent In-Reply-To: <20200619015150.27745-1-atish.patra@wdc.com> References: <20200619015150.27745-1-atish.patra@wdc.com> Message-ID: <20200619015150.27745-3-atish.patra@wdc.com> fdtdec_get_addr_size_no_parent is not an optimized version if parent node is already available with the caller. Use fdtdec_get_addr_size_auto_parent to read the "reg" property Signed-off-by: Atish Patra Reviewed-by: Bin Meng --- 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 91524d9a5ae9..00b84dccbef0 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) { From patchwork Fri Jun 19 01:51:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 242649 List-Id: U-Boot discussion From: atish.patra at wdc.com (Atish Patra) Date: Thu, 18 Jun 2020 18:51:50 -0700 Subject: [PATCH 3/3] cmd: bootefi: Honor the address & size cells properties correctly In-Reply-To: <20200619015150.27745-1-atish.patra@wdc.com> References: <20200619015150.27745-1-atish.patra@wdc.com> Message-ID: <20200619015150.27745-4-atish.patra@wdc.com> fdtdec_get_addr_size reads the uses a fixed value for address & size cell properties which may not be correct always. Use the auto variant of the function which automatically reads #address-cells & #size-cells from parent and uses to read the "reg" property. Signed-off-by: Atish Patra --- cmd/bootefi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/bootefi.c b/cmd/bootefi.c index 0f6d0f77507c..5f3fcce597de 100644 --- a/cmd/bootefi.c +++ b/cmd/bootefi.c @@ -190,8 +190,9 @@ static void efi_carve_out_dt_rsv(void *fdt) subnode = fdt_first_subnode(fdt, nodeoffset); while (subnode >= 0) { /* check if this subnode has a reg property */ - addr = fdtdec_get_addr_size(fdt, subnode, "reg", - (fdt_size_t *)&size); + addr = fdtdec_get_addr_size_auto_parent(fdt, nodeoffset, + subnode, "reg", 0, + (fdt_size_t *)&size, false); /* * The /reserved-memory node may have children with * a size instead of a reg property.