* [PATCH v4 1/3] riscv: Avoid the reserved memory fixup if src and dst point to the same place
@ 2020-06-26 1:16 Bin Meng
2020-06-26 1:16 ` [PATCH v4 2/3] riscv: Expand the DT size before copy reserved memory node Bin Meng
2020-06-26 1:16 ` [PATCH v4 3/3] riscv: Enable CONFIG_OF_BOARD_FIXUP by default for OF_SEPARATE Bin Meng
0 siblings, 2 replies; 5+ messages in thread
From: Bin Meng @ 2020-06-26 1:16 UTC (permalink / raw
To: u-boot
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>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
---
(no changes since v1)
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 2/3] riscv: Expand the DT size before copy reserved memory node
2020-06-26 1:16 [PATCH v4 1/3] riscv: Avoid the reserved memory fixup if src and dst point to the same place Bin Meng
@ 2020-06-26 1:16 ` Bin Meng
[not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA471F2B2@ATCPCS16.andestech.com>
2020-06-26 1:16 ` [PATCH v4 3/3] riscv: Enable CONFIG_OF_BOARD_FIXUP by default for OF_SEPARATE Bin Meng
1 sibling, 1 reply; 5+ messages in thread
From: Bin Meng @ 2020-06-26 1:16 UTC (permalink / raw
To: u-boot
From: Bin Meng <bin.meng@windriver.com>
The FDT blob might not have sufficient space to hold a copy of
reserved memory node. Expand it before the copy.
Reported-by: Rick Chen <rick@andestech.com>
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
---
(no changes since v3)
Changes in v3:
- Extend the FDT size by 1024 bytes
arch/riscv/lib/fdt_fixup.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c
index 5f523f0..160ccca 100644
--- a/arch/riscv/lib/fdt_fixup.c
+++ b/arch/riscv/lib/fdt_fixup.c
@@ -41,6 +41,18 @@ int riscv_fdt_copy_resv_mem_node(const void *src, void *dst)
return 0;
}
+ /*
+ * Extend the FDT by the following estimated size:
+ *
+ * Each PMP memory region entry occupies 64 bytes.
+ * With 16 PMP memory regions we need 64 * 16 = 1024 bytes.
+ */
+ err = fdt_open_into(dst, dst, fdt_totalsize(dst) + 1024);
+ if (err < 0) {
+ printf("Device Tree can't be expanded to accommodate new node");
+ return err;
+ }
+
fdt_for_each_subnode(node, src, offset) {
name = fdt_get_name(src, node, NULL);
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 3/3] riscv: Enable CONFIG_OF_BOARD_FIXUP by default for OF_SEPARATE
2020-06-26 1:16 [PATCH v4 1/3] riscv: Avoid the reserved memory fixup if src and dst point to the same place Bin Meng
2020-06-26 1:16 ` [PATCH v4 2/3] riscv: Expand the DT size before copy reserved memory node Bin Meng
@ 2020-06-26 1:16 ` Bin Meng
[not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA471F2B9@ATCPCS16.andestech.com>
1 sibling, 1 reply; 5+ messages in thread
From: Bin Meng @ 2020-06-26 1:16 UTC (permalink / raw
To: u-boot
From: Bin Meng <bin.meng@windriver.com>
Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the
reserved memory node for PMP protected memory regions. All RISC-V
boards need to copy the reserved memory node from the device tree
provided by the firmware to the device tree used by U-Boot.
Turn on CONFIG_OF_BOARD_FIXUP by default for OF_SEPARATE.
Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
---
Changes in v4:
- /s/needs/need in the commit message
Changes in v3:
- change to "default y if OF_SEPARATE"
arch/riscv/Kconfig | 3 +++
configs/sifive_fu540_defconfig | 1 -
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index d9854f5..ff8a9f8 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -273,4 +273,7 @@ config STACK_SIZE_SHIFT
int
default 14
+config OF_BOARD_FIXUP
+ default y if OF_SEPARATE
+
endmenu
diff --git a/configs/sifive_fu540_defconfig b/configs/sifive_fu540_defconfig
index 8d412f8..32347c2 100644
--- a/configs/sifive_fu540_defconfig
+++ b/configs/sifive_fu540_defconfig
@@ -16,7 +16,6 @@ CONFIG_DISPLAY_CPUINFO=y
CONFIG_DISPLAY_BOARDINFO=y
CONFIG_SPL_SEPARATE_BSS=y
CONFIG_SPL_YMODEM_SUPPORT=y
-CONFIG_OF_BOARD_FIXUP=y
CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00"
CONFIG_SYS_RELOC_GD_ENV_ADDR=y
CONFIG_SPL_CLK=y
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v4 2/3] riscv: Expand the DT size before copy reserved memory node
[not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA471F2B2@ATCPCS16.andestech.com>
@ 2020-06-29 6:36 ` Rick Chen
0 siblings, 0 replies; 5+ messages in thread
From: Rick Chen @ 2020-06-29 6:36 UTC (permalink / raw
To: u-boot
> From: Bin Meng [mailto:bmeng.cn at gmail.com]
> Sent: Friday, June 26, 2020 9:16 AM
> To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
> Cc: Atish Patra; Bin Meng
> Subject: [PATCH v4 2/3] riscv: Expand the DT size before copy reserved memory node
>
> From: Bin Meng <bin.meng@windriver.com>
>
> The FDT blob might not have sufficient space to hold a copy of reserved memory node. Expand it before the copy.
>
> Reported-by: Rick Chen <rick@andestech.com>
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> Reviewed-by: Atish Patra <atish.patra@wdc.com>
> ---
>
> (no changes since v3)
>
> Changes in v3:
> - Extend the FDT size by 1024 bytes
>
> arch/riscv/lib/fdt_fixup.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
Reviewed-by: Rick Chen <rick@andestech.com>
> diff --git a/arch/riscv/lib/fdt_fixup.c b/arch/riscv/lib/fdt_fixup.c index 5f523f0..160ccca 100644
> --- a/arch/riscv/lib/fdt_fixup.c
> +++ b/arch/riscv/lib/fdt_fixup.c
> @@ -41,6 +41,18 @@ int riscv_fdt_copy_resv_mem_node(const void *src, void *dst)
> return 0;
> }
>
> + /*
> + * Extend the FDT by the following estimated size:
> + *
> + * Each PMP memory region entry occupies 64 bytes.
> + * With 16 PMP memory regions we need 64 * 16 = 1024 bytes.
> + */
> + err = fdt_open_into(dst, dst, fdt_totalsize(dst) + 1024);
> + if (err < 0) {
> + printf("Device Tree can't be expanded to accommodate new node");
> + return err;
> + }
> +
> fdt_for_each_subnode(node, src, offset) {
> name = fdt_get_name(src, node, NULL);
>
> --
> 2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v4 3/3] riscv: Enable CONFIG_OF_BOARD_FIXUP by default for OF_SEPARATE
[not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA471F2B9@ATCPCS16.andestech.com>
@ 2020-06-29 6:37 ` Rick Chen
0 siblings, 0 replies; 5+ messages in thread
From: Rick Chen @ 2020-06-29 6:37 UTC (permalink / raw
To: u-boot
> From: Bin Meng [mailto:bmeng.cn at gmail.com]
> Sent: Friday, June 26, 2020 9:16 AM
> To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
> Cc: Atish Patra; Bin Meng
> Subject: [PATCH v4 3/3] riscv: Enable CONFIG_OF_BOARD_FIXUP by default for OF_SEPARATE
>
> From: Bin Meng <bin.meng@windriver.com>
>
> Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards need to copy the reserved memory node from the device tree provided by the firmware to the device tree used by U-Boot.
>
> Turn on CONFIG_OF_BOARD_FIXUP by default for OF_SEPARATE.
>
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> Reviewed-by: Atish Patra <atish.patra@wdc.com>
> ---
>
> Changes in v4:
> - /s/needs/need in the commit message
>
> Changes in v3:
> - change to "default y if OF_SEPARATE"
>
> arch/riscv/Kconfig | 3 +++
> configs/sifive_fu540_defconfig | 1 -
> 2 files changed, 3 insertions(+), 1 deletion(-)
Reviewed-by: Rick Chen <rick@andestech.com>
>
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index d9854f5..ff8a9f8 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -273,4 +273,7 @@ config STACK_SIZE_SHIFT
> int
> default 14
>
> +config OF_BOARD_FIXUP
> + default y if OF_SEPARATE
> +
> endmenu
> diff --git a/configs/sifive_fu540_defconfig b/configs/sifive_fu540_defconfig index 8d412f8..32347c2 100644
> --- a/configs/sifive_fu540_defconfig
> +++ b/configs/sifive_fu540_defconfig
> @@ -16,7 +16,6 @@ CONFIG_DISPLAY_CPUINFO=y CONFIG_DISPLAY_BOARDINFO=y CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_YMODEM_SUPPORT=y -CONFIG_OF_BOARD_FIXUP=y CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00"
> CONFIG_SYS_RELOC_GD_ENV_ADDR=y
> CONFIG_SPL_CLK=y
> --
> 2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-06-29 6:37 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-26 1:16 [PATCH v4 1/3] riscv: Avoid the reserved memory fixup if src and dst point to the same place Bin Meng
2020-06-26 1:16 ` [PATCH v4 2/3] riscv: Expand the DT size before copy reserved memory node Bin Meng
[not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA471F2B2@ATCPCS16.andestech.com>
2020-06-29 6:36 ` Rick Chen
2020-06-26 1:16 ` [PATCH v4 3/3] riscv: Enable CONFIG_OF_BOARD_FIXUP by default for OF_SEPARATE Bin Meng
[not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA471F2B9@ATCPCS16.andestech.com>
2020-06-29 6:37 ` Rick Chen
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.