diff mbox series

[1/2] riscv: Avoid the reserved memory fixup if src and dst point to the same place

Message ID 1589960371-20635-1-git-send-email-bmeng.cn@gmail.com
State Superseded
Delegated to: Andes
Headers show
Series [1/2] riscv: Avoid the reserved memory fixup if src and dst point to the same place | expand

Commit Message

Bin Meng May 20, 2020, 7:39 a.m. UTC
From: Bin Meng <bin.meng@windriver.com>

The copy of reserved memory node from source dtb to destination dtb
can be avoided if they point to the same place. This is useful when
OF_PRIOR_STAGE is used.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
---

 arch/riscv/lib/fdt_fixup.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Bin Meng May 26, 2020, 8:53 a.m. UTC | #1
On Wed, May 20, 2020 at 3:41 PM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> From: Bin Meng <bin.meng@windriver.com>
>
> The copy of reserved memory node from source dtb to destination dtb
> can be avoided if they point to the same place. This is useful when
> OF_PRIOR_STAGE is used.
>
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> ---
>
>  arch/riscv/lib/fdt_fixup.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>

Ping?
Rick Chen May 28, 2020, 8:01 a.m. UTC | #2
> From: Bin Meng [mailto:bmeng.cn@gmail.com]
> Sent: Wednesday, May 20, 2020 3:40 PM
> To: Rick Jian-Zhi Chen(陳建志); U-Boot Mailing List
> Cc: Bin Meng
> Subject: [PATCH 1/2] riscv: Avoid the reserved memory fixup if src and dst point to the same place
>
> From: Bin Meng <bin.meng@windriver.com>
>
> The copy of reserved memory node from source dtb to destination dtb can be avoided if they point to the same place. This is useful when OF_PRIOR_STAGE is used.
>
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> ---

Reviewed-by: Rick Chen <rick@andestech.com>

>
>  arch/riscv/lib/fdt_fixup.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c index 6db48ad..5f523f0 100644
> --- a/arch/riscv/lib/fdt_fixup.c
> +++ b/arch/riscv/lib/fdt_fixup.c
> @@ -82,10 +82,9 @@ int riscv_fdt_copy_resv_mem_node(const void *src, void *dst)
>   * @fdt: Pointer to the device tree in which reserved memory node needs to be
>   *      added.
>   *
> - * In RISC-V, any board compiled with OF_SEPARATE needs to copy the reserved
> - * memory node from the device tree provided by the firmware to the device tree
> - * used by U-Boot. This is a common function that individual board fixup
> - * functions can invoke.
> + * In RISC-V, any board needs to copy the reserved memory node from the
> + device
> + * tree provided by the firmware to the device tree used by U-Boot.
> + This is a
> + * common function that individual board fixup functions can invoke.
>   *
>   * Return: 0 on success or error otherwise.
>   */
> @@ -95,6 +94,11 @@ int riscv_board_reserved_mem_fixup(void *fdt)
>         void *src_fdt_addr;
>
>         src_fdt_addr = map_sysmem(gd->arch.firmware_fdt_addr, 0);
> +
> +       /* avoid the copy if we are using the same device tree */
> +       if (src_fdt_addr == fdt)
> +               return 0;
> +
>         err = riscv_fdt_copy_resv_mem_node(src_fdt_addr, fdt);
>         if (err < 0)
>                 return err;
> --
> 2.7.4
diff mbox series

Patch

diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c
index 6db48ad..5f523f0 100644
--- a/arch/riscv/lib/fdt_fixup.c
+++ b/arch/riscv/lib/fdt_fixup.c
@@ -82,10 +82,9 @@  int riscv_fdt_copy_resv_mem_node(const void *src, void *dst)
  * @fdt: Pointer to the device tree in which reserved memory node needs to be
  *	 added.
  *
- * In RISC-V, any board compiled with OF_SEPARATE needs to copy the reserved
- * memory node from the device tree provided by the firmware to the device tree
- * used by U-Boot. This is a common function that individual board fixup
- * functions can invoke.
+ * In RISC-V, any board needs to copy the reserved memory node from the device
+ * tree provided by the firmware to the device tree used by U-Boot. This is a
+ * common function that individual board fixup functions can invoke.
  *
  * Return: 0 on success or error otherwise.
  */
@@ -95,6 +94,11 @@  int riscv_board_reserved_mem_fixup(void *fdt)
 	void *src_fdt_addr;
 
 	src_fdt_addr = map_sysmem(gd->arch.firmware_fdt_addr, 0);
+
+	/* avoid the copy if we are using the same device tree */
+	if (src_fdt_addr == fdt)
+		return 0;
+
 	err = riscv_fdt_copy_resv_mem_node(src_fdt_addr, fdt);
 	if (err < 0)
 		return err;