diff mbox series

riscv: Fix setting no-map in reserved memory nodes

Message ID 20210912160547.50701-1-samuel@sholland.org
State Accepted
Commit 0d625f400bcab5361484a5446aa54133fd6fe213
Delegated to: Andes
Headers show
Series riscv: Fix setting no-map in reserved memory nodes | expand

Commit Message

Samuel Holland Sept. 12, 2021, 4:05 p.m. UTC
The no-map property is wrongly skipped if a no-map reserved memory
node follows one without that property. Fix this by not remembering
the absence of a no-map property across loop iterations.

Fixes: d4ea649f179a ("riscv: Provide a mechanism to fix DT for reserved memory")
Signed-off-by: Samuel Holland <samuel@sholland.org>
---

 arch/riscv/lib/fdt_fixup.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Bin Meng Sept. 12, 2021, 11:10 p.m. UTC | #1
On Mon, Sep 13, 2021 at 12:05 AM Samuel Holland <samuel@sholland.org> wrote:
>
> The no-map property is wrongly skipped if a no-map reserved memory
> node follows one without that property. Fix this by not remembering
> the absence of a no-map property across loop iterations.
>
> Fixes: d4ea649f179a ("riscv: Provide a mechanism to fix DT for reserved memory")
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
>
>  arch/riscv/lib/fdt_fixup.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Rick Chen Sept. 17, 2021, 6:47 a.m. UTC | #2
> From: Samuel Holland <samuel@sholland.org>
> Sent: Monday, September 13, 2021 12:06 AM
> To: Rick Jian-Zhi Chen(陳建志) <rick@andestech.com>; Leo Yu-Chi Liang(梁育齊) <ycliang@andestech.com>
> Cc: u-boot@lists.denx.de; Samuel Holland <samuel@sholland.org>; Atish Patra <atish.patra@wdc.com>; Bin Meng <bmeng.cn@gmail.com>; Etienne Carriere <etienne.carriere@st.com>; Sean Anderson <seanga2@gmail.com>; Simon Glass <sjg@chromium.org>
> Subject: [PATCH] riscv: Fix setting no-map in reserved memory nodes
>
> The no-map property is wrongly skipped if a no-map reserved memory node follows one without that property. Fix this by not remembering the absence of a no-map property across loop iterations.
>
> Fixes: d4ea649f179a ("riscv: Provide a mechanism to fix DT for reserved memory")
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
>
>  arch/riscv/lib/fdt_fixup.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)

Reviewed-by: Rick Chen <rick@andestech.com>
Atish Patra Sept. 17, 2021, 7:07 p.m. UTC | #3
On Sun, Sep 12, 2021 at 9:05 AM Samuel Holland <samuel@sholland.org> wrote:
>
> The no-map property is wrongly skipped if a no-map reserved memory
> node follows one without that property. Fix this by not remembering
> the absence of a no-map property across loop iterations.
>
> Fixes: d4ea649f179a ("riscv: Provide a mechanism to fix DT for reserved memory")
> Signed-off-by: Samuel Holland <samuel@sholland.org>
> ---
>
>  arch/riscv/lib/fdt_fixup.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c
> index f636b284497..61cf8935269 100644
> --- a/arch/riscv/lib/fdt_fixup.c
> +++ b/arch/riscv/lib/fdt_fixup.c
> @@ -31,7 +31,6 @@ int riscv_fdt_copy_resv_mem_node(const void *src, void *dst)
>         fdt_addr_t addr;
>         fdt_size_t size;
>         int offset, node, err, rmem_offset;
> -       bool nomap = true;
>         char basename[32] = {0};
>         int bname_len;
>         int max_len = sizeof(basename);
> @@ -81,9 +80,7 @@ int riscv_fdt_copy_resv_mem_node(const void *src, void *dst)
>                         log_err("failed to add reserved memory: %d\n", err);
>                         return err;
>                 }
> -               if (!fdt_getprop(src, node, "no-map", NULL))
> -                       nomap = false;
> -               if (nomap) {
> +               if (fdt_getprop(src, node, "no-map", NULL)) {
>                         rmem_offset = fdt_node_offset_by_phandle(dst, phandle);
>                         fdt_setprop_empty(dst, rmem_offset, "no-map");
>                 }
> --
> 2.31.1
>

Thanks for catching it.

Reviewed-by: Atish Patra <atish.patra@wdc.com>
diff mbox series

Patch

diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c
index f636b284497..61cf8935269 100644
--- a/arch/riscv/lib/fdt_fixup.c
+++ b/arch/riscv/lib/fdt_fixup.c
@@ -31,7 +31,6 @@  int riscv_fdt_copy_resv_mem_node(const void *src, void *dst)
 	fdt_addr_t addr;
 	fdt_size_t size;
 	int offset, node, err, rmem_offset;
-	bool nomap = true;
 	char basename[32] = {0};
 	int bname_len;
 	int max_len = sizeof(basename);
@@ -81,9 +80,7 @@  int riscv_fdt_copy_resv_mem_node(const void *src, void *dst)
 			log_err("failed to add reserved memory: %d\n", err);
 			return err;
 		}
-		if (!fdt_getprop(src, node, "no-map", NULL))
-			nomap = false;
-		if (nomap) {
+		if (fdt_getprop(src, node, "no-map", NULL)) {
 			rmem_offset = fdt_node_offset_by_phandle(dst, phandle);
 			fdt_setprop_empty(dst, rmem_offset, "no-map");
 		}