Skip to contentSkip to conversation

riscv: Avoid the reserved memory fixup if src and dst point to the same place

PATCH Superseded Bin Meng 3 participants 21 messages May 20, 2020 – Jun 3, 2020 2 messages not in the archive

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

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

From: Bin Meng <[email protected]>

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.

---

 arch/riscv/lib/fdt_fixup.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
arch/riscv/lib/fdt_fixup.c +8 -4
index 6db48ad..5f523f0 100644
@@ -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;
Signature · 1 line
2.7.4
author
#1 lore raw

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

Quoted 7 lines · Bin Meng

From: Bin Meng <[email protected]>

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.

Quoted 6 lines

---

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

Ping?

author
#2 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

In reply to Bin Meng

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +3 -0
index fb5fe5a..5176b35 100644
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
 	int
 	default 14
 
+config OF_BOARD_FIXUP
+	default y
+
 endmenu
configs/sifive_fu540_defconfig +0 -1
index f805aac..6d61e6c 100644
@@ -9,7 +9,6 @@ CONFIG_FIT=y
 CONFIG_MISC_INIT_R=y
 CONFIG_DISPLAY_CPUINFO=y
 CONFIG_DISPLAY_BOARDINFO=y
-CONFIG_OF_BOARD_FIXUP=y
 CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM_MTD=y
Signature · 1 line
2.7.4

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

Hi Bin

Quoted 23 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 5 lines
arch/riscv/Kconfig +2 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

In [PATCH 1/2] if source and destination are the same place, it represent that OF_BOARD_FIXUP is unnecessary.

BTW when I try OF_SEPARATE and OF_BOARD_FIXUP both are enabled, it hit the problem as below:

U-Boot SPL 2020.07-rc3-16981-g4332225-dirty (May 28 2020 - 14:48:18 +0800) Trying to boot from RAM

U-Boot 2020.07-rc3-16981-g4332225-dirty (May 28 2020 - 14:48:18 +0800)

DRAM: 1 GiB
failed to add reserved memory: -3
failed to fixup DT for reserved memory: -3
initcall sequence 0000000001253c20 failed at call 000000000120b8e0 (err=-3) ### ERROR ### Please RESET the board ###

I will dig in and figure out what is going on here ? Maybe there exist a potential issue somehow!

Thanks,
Rick

Quoted 15 lines
arch/riscv/Kconfig +1 -0
+
 endmenu
configs/sifive_fu540_defconfig +0 -2
@@ -9,7 +9,6 @@ CONFIG_FIT=y
 CONFIG_MISC_INIT_R=y
 CONFIG_DISPLAY_CPUINFO=y
 CONFIG_DISPLAY_BOARDINFO=y
-CONFIG_OF_BOARD_FIXUP=y
 CONFIG_DEFAULT_DEVICE_TREE="hifive-unleashed-a00"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
 CONFIG_DM_MTD=y
--

2.7.4

author
#5 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

Hi Rick,

Quoted 29 lines · Rick Chen

Hi Bin

Quoted 26 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +0 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
Quoted 5 lines

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 2 lines
arch/riscv/Kconfig +2 -0
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

I believe we should turn on this feature by default for every RISC-V board, because SBI firmware used memory must be marked as reserved otherwise OS might use it and get crashed. For boards which don't want to enable this, they can unset the option in their board defconfig files. This is to reduce some maintenance effort.

Quoted 7 lines

In [PATCH 1/2] if source and destination are the same place, it represent that OF_BOARD_FIXUP is unnecessary.

BTW when I try OF_SEPARATE and OF_BOARD_FIXUP both are enabled, it hit the problem as below:

Quoted 8 lines

U-Boot SPL 2020.07-rc3-16981-g4332225-dirty (May 28 2020 - 14:48:18 +0800) Trying to boot from RAM

U-Boot 2020.07-rc3-16981-g4332225-dirty (May 28 2020 - 14:48:18 +0800)

DRAM: 1 GiB
failed to add reserved memory: -3

-3 means FDT_ERR_NOSPACE.

The FDT does not have enough space to add reserved memory node. Could you please check your FDT blob?

Quoted 7 lines

failed to fixup DT for reserved memory: -3
initcall sequence 0000000001253c20 failed at call 000000000120b8e0 (err=-3) ### ERROR ### Please RESET the board ###

I will dig in and figure out what is going on here ? Maybe there exist a potential issue somehow!

Regards,
Bin

author
#6 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

Hi Rick,

Quoted 58 lines · Bin Meng

Hi Rick,

Quoted 29 lines · Rick Chen

Hi Bin

Quoted 26 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +0 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
Quoted 5 lines

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 2 lines
arch/riscv/Kconfig +2 -0
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

I believe we should turn on this feature by default for every RISC-V board, because SBI firmware used memory must be marked as reserved otherwise OS might use it and get crashed. For boards which don't want to enable this, they can unset the option in their board defconfig files. This is to reduce some maintenance effort.

Quoted 13 lines

In [PATCH 1/2] if source and destination are the same place, it represent that OF_BOARD_FIXUP is unnecessary.

BTW when I try OF_SEPARATE and OF_BOARD_FIXUP both are enabled, it hit the problem as below:

U-Boot SPL 2020.07-rc3-16981-g4332225-dirty (May 28 2020 - 14:48:18 +0800) Trying to boot from RAM

U-Boot 2020.07-rc3-16981-g4332225-dirty (May 28 2020 - 14:48:18 +0800)

Quoted 14 lines
Quoted 2 lines

DRAM: 1 GiB
failed to add reserved memory: -3

-3 means FDT_ERR_NOSPACE.

The FDT does not have enough space to add reserved memory node. Could you please check your FDT blob?

Quoted 6 lines

failed to fixup DT for reserved memory: -3
initcall sequence 0000000001253c20 failed at call 000000000120b8e0 (err=-3) ### ERROR ### Please RESET the board ###

I will dig in and figure out what is going on here ? Maybe there exist a potential issue somehow!

Could you please try this patch?
http://patchwork.ozlabs.org/project/uboot/patch/1590655604-13704-2-git-send-email-bmeng.cn at gmail.com/

Regards,
Bin

#7 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

Hi Bin

Quoted 73 lines

Hi Rick,

Quoted 70 lines · Bin Meng

Hi Rick,

Quoted 29 lines · Rick Chen

Hi Bin

Quoted 26 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +0 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
Quoted 5 lines

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 2 lines
arch/riscv/Kconfig +2 -0
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

I believe we should turn on this feature by default for every RISC-V board, because SBI firmware used memory must be marked as reserved otherwise OS might use it and get crashed. For boards which don't want to enable this, they can unset the option in their board defconfig files. This is to reduce some maintenance effort.

Quoted 7 lines

In [PATCH 1/2] if source and destination are the same place, it represent that OF_BOARD_FIXUP is unnecessary.

BTW when I try OF_SEPARATE and OF_BOARD_FIXUP both are enabled, it hit the problem as below:

Quoted 8 lines

U-Boot SPL 2020.07-rc3-16981-g4332225-dirty (May 28 2020 - 14:48:18 +0800) Trying to boot from RAM

U-Boot 2020.07-rc3-16981-g4332225-dirty (May 28 2020 - 14:48:18 +0800)

DRAM: 1 GiB
failed to add reserved memory: -3

-3 means FDT_ERR_NOSPACE.

The FDT does not have enough space to add reserved memory node. Could you please check your FDT blob?

Quoted 4 lines

failed to fixup DT for reserved memory: -3
initcall sequence 0000000001253c20 failed at call 000000000120b8e0 (err=-3) ### ERROR ### Please RESET the board ###

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

I will dig in and figure out what is going on here ? Maybe there exist a potential issue somehow!

Could you please try this patch?
http://patchwork.ozlabs.org/project/uboot/patch/1590655604-13704-2-git-send-email-bmeng.cn at gmail.com/

I try this patch, it still fail.
But after increase 32 more larger, it can pass.

Thanks,
Rick

Quoted 3 lines

Regards,
Bin

author
#8 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

Hi Rick,

Quoted 76 lines · Rick Chen

Hi Bin

Quoted 73 lines

Hi Rick,

Quoted 70 lines · Bin Meng

Hi Rick,

Quoted 29 lines · Rick Chen

Hi Bin

Quoted 26 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +0 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
Quoted 5 lines

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 2 lines
arch/riscv/Kconfig +2 -0
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

I believe we should turn on this feature by default for every RISC-V board, because SBI firmware used memory must be marked as reserved otherwise OS might use it and get crashed. For boards which don't want to enable this, they can unset the option in their board defconfig files. This is to reduce some maintenance effort.

Quoted 7 lines

In [PATCH 1/2] if source and destination are the same place, it represent that OF_BOARD_FIXUP is unnecessary.

BTW when I try OF_SEPARATE and OF_BOARD_FIXUP both are enabled, it hit the problem as below:

Quoted 8 lines

U-Boot SPL 2020.07-rc3-16981-g4332225-dirty (May 28 2020 - 14:48:18 +0800) Trying to boot from RAM

U-Boot 2020.07-rc3-16981-g4332225-dirty (May 28 2020 - 14:48:18 +0800)

DRAM: 1 GiB
failed to add reserved memory: -3

-3 means FDT_ERR_NOSPACE.

The FDT does not have enough space to add reserved memory node. Could you please check your FDT blob?

Quoted 4 lines

failed to fixup DT for reserved memory: -3
initcall sequence 0000000001253c20 failed at call 000000000120b8e0 (err=-3) ### ERROR ### Please RESET the board ###

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

I will dig in and figure out what is going on here ? Maybe there exist a potential issue somehow!

Could you please try this patch?
http://patchwork.ozlabs.org/project/uboot/patch/1590655604-13704-2-git-send-email-bmeng.cn at gmail.com/

I try this patch, it still fail.
But after increase 32 more larger, it can pass.

What number did you enlarge this fdt size to?

Regards,
Bin

#9 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

Hi Bin

Quoted 82 lines

Hi Rick,

Quoted 79 lines · Rick Chen

Hi Bin

Quoted 76 lines

Hi Rick,

Quoted 72 lines · Bin Meng

Hi Rick,

Quoted 29 lines · Rick Chen

Hi Bin

Quoted 26 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +0 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
Quoted 5 lines

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 2 lines
arch/riscv/Kconfig +2 -0
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

I believe we should turn on this feature by default for every RISC-V board, because SBI firmware used memory must be marked as reserved otherwise OS might use it and get crashed. For boards which don't want to enable this, they can unset the option in their board defconfig files. This is to reduce some maintenance effort.

Quoted 7 lines

In [PATCH 1/2] if source and destination are the same place, it represent that OF_BOARD_FIXUP is unnecessary.

BTW when I try OF_SEPARATE and OF_BOARD_FIXUP both are enabled, it hit the problem as below:

Quoted 8 lines

U-Boot SPL 2020.07-rc3-16981-g4332225-dirty (May 28 2020 - 14:48:18 +0800) Trying to boot from RAM

U-Boot 2020.07-rc3-16981-g4332225-dirty (May 28 2020 - 14:48:18 +0800)

DRAM: 1 GiB
failed to add reserved memory: -3

-3 means FDT_ERR_NOSPACE.

The FDT does not have enough space to add reserved memory node. Could you please check your FDT blob?

Quoted 6 lines

failed to fixup DT for reserved memory: -3
initcall sequence 0000000001253c20 failed at call 000000000120b8e0 (err=-3) ### ERROR ### Please RESET the board ###

I will dig in and figure out what is going on here ? Maybe there exist a potential issue somehow!

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Could you please try this patch?
http://patchwork.ozlabs.org/project/uboot/patch/1590655604-13704-2-git-send-email-bmeng.cn at gmail.com/

I try this patch, it still fail.
But after increase 32 more larger, it can pass.

What number did you enlarge this fdt size to?

It looks like depend on individual boards. We can not guarantee other boards adopt this size at rum time.
That is why I suggest it shall be enabled individually.

Thanks,
Rick

Quoted 3 lines

Regards,
Bin

author
#10 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

Hi Rick,

Quoted 92 lines · Rick Chen

Hi Bin

Quoted 89 lines

Hi Rick,

Quoted 85 lines · Rick Chen

Hi Bin

Quoted 73 lines

Hi Rick,

Quoted 70 lines · Bin Meng

Hi Rick,

Quoted 29 lines · Rick Chen

Hi Bin

Quoted 26 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +0 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
Quoted 5 lines

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 2 lines
arch/riscv/Kconfig +2 -0
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

I believe we should turn on this feature by default for every RISC-V board, because SBI firmware used memory must be marked as reserved otherwise OS might use it and get crashed. For boards which don't want to enable this, they can unset the option in their board defconfig files. This is to reduce some maintenance effort.

Quoted 7 lines

In [PATCH 1/2] if source and destination are the same place, it represent that OF_BOARD_FIXUP is unnecessary.

BTW when I try OF_SEPARATE and OF_BOARD_FIXUP both are enabled, it hit the problem as below:

Quoted 8 lines

U-Boot SPL 2020.07-rc3-16981-g4332225-dirty (May 28 2020 - 14:48:18 +0800) Trying to boot from RAM

U-Boot 2020.07-rc3-16981-g4332225-dirty (May 28 2020 - 14:48:18 +0800)

DRAM: 1 GiB
failed to add reserved memory: -3

-3 means FDT_ERR_NOSPACE.

The FDT does not have enough space to add reserved memory node. Could you please check your FDT blob?

Quoted 4 lines

failed to fixup DT for reserved memory: -3
initcall sequence 0000000001253c20 failed at call 000000000120b8e0 (err=-3) ### ERROR ### Please RESET the board ###

Quoted 5 lines
Quoted 2 lines
Quoted 2 lines

I will dig in and figure out what is going on here ? Maybe there exist a potential issue somehow!

Could you please try this patch?
http://patchwork.ozlabs.org/project/uboot/patch/1590655604-13704-2-git-send-email-bmeng.cn at gmail.com/

I try this patch, it still fail.
But after increase 32 more larger, it can pass.

Quoted 6 lines
Quoted 1 line

What number did you enlarge this fdt size to?

It looks like depend on individual boards. We can not guarantee other boards adopt this size at rum time.
That is why I suggest it shall be enabled individually.

This is a generic code and we should find a suitable size to get it work on every board. We should provide a consistent interface for every RISC-V board support, ie: we should not have some board turned on this option but some board not.

Regards,
Bin

#11 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

In reply to Bin Meng

Hi Bin

Quoted 38 lines

Hi Rick,

Quoted 29 lines · Rick Chen

Hi Bin

Quoted 26 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +0 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
Quoted 5 lines

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 2 lines
arch/riscv/Kconfig +2 -0
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

Quoted 5 lines

I believe we should turn on this feature by default for every RISC-V board, because SBI firmware used memory must be marked as reserved otherwise OS might use it and get crashed. For boards which don't want to enable this, they can unset the option in their board defconfig files. This is to reduce some maintenance effort.

But not all RISC-V boards need this configuration.
If we enable it by default, non spl configuration will run this fdt fix flow, but it is unnecessary.

Thanks,
Rick

Quoted 32 lines
Quoted 8 lines

In [PATCH 1/2] if source and destination are the same place, it represent that OF_BOARD_FIXUP is unnecessary.

BTW when I try OF_SEPARATE and OF_BOARD_FIXUP both are enabled, it hit the problem as below:

Quoted 8 lines

U-Boot SPL 2020.07-rc3-16981-g4332225-dirty (May 28 2020 - 14:48:18 +0800) Trying to boot from RAM

U-Boot 2020.07-rc3-16981-g4332225-dirty (May 28 2020 - 14:48:18 +0800)

DRAM: 1 GiB
failed to add reserved memory: -3

-3 means FDT_ERR_NOSPACE.

The FDT does not have enough space to add reserved memory node. Could you please check your FDT blob?

Quoted 7 lines

failed to fixup DT for reserved memory: -3
initcall sequence 0000000001253c20 failed at call 000000000120b8e0 (err=-3) ### ERROR ### Please RESET the board ###

I will dig in and figure out what is going on here ? Maybe there exist a potential issue somehow!

Regards,
Bin

author
#12 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

Hi Rick,

Quoted 47 lines · Rick Chen

Hi Bin

Quoted 38 lines

Hi Rick,

Quoted 29 lines · Rick Chen

Hi Bin

Quoted 26 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +0 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
Quoted 5 lines

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 2 lines
arch/riscv/Kconfig +2 -0
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

Quoted 5 lines

I believe we should turn on this feature by default for every RISC-V board, because SBI firmware used memory must be marked as reserved otherwise OS might use it and get crashed. For boards which don't want to enable this, they can unset the option in their board defconfig files. This is to reduce some maintenance effort.

Quoted 4 lines

But not all RISC-V boards need this configuration.
If we enable it by default, non spl configuration will run this fdt fix flow, but it is unnecessary.

Non SPL configuration also needs this, because U-Boot has to patch the final DTB that is passed to the kernel. It's a RISC-V architecture thing.

Regards,
Bin

#13 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

Hi Bin

Quoted 50 lines

Hi Rick,

Quoted 47 lines · Rick Chen

Hi Bin

Quoted 43 lines

Hi Rick,

Quoted 29 lines · Rick Chen

Hi Bin

Quoted 26 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +0 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
Quoted 5 lines

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 2 lines
arch/riscv/Kconfig +2 -0
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

I believe we should turn on this feature by default for every RISC-V board, because SBI firmware used memory must be marked as reserved otherwise OS might use it and get crashed. For boards which don't want to enable this, they can unset the option in their board defconfig files. This is to reduce some maintenance effort.

Quoted 8 lines
Quoted 4 lines

But not all RISC-V boards need this configuration.
If we enable it by default, non spl configuration will run this fdt fix flow, but it is unnecessary.

Non SPL configuration also needs this, because U-Boot has to patch the final DTB that is passed to the kernel. It's a RISC-V architecture thing.

But non SPL configuration will not run openSbi, why it will need this flow ?

Thanks,
Rick

Quoted 3 lines

Regards,
Bin

author
#14 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

Hi Rick,

Quoted 58 lines · Rick Chen

Hi Bin

Quoted 55 lines

Hi Rick,

Quoted 51 lines · Rick Chen

Hi Bin

Quoted 38 lines

Hi Rick,

Quoted 29 lines · Rick Chen

Hi Bin

Quoted 26 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +0 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
Quoted 5 lines

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 2 lines
arch/riscv/Kconfig +2 -0
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

Quoted 5 lines

I believe we should turn on this feature by default for every RISC-V board, because SBI firmware used memory must be marked as reserved otherwise OS might use it and get crashed. For boards which don't want to enable this, they can unset the option in their board defconfig files. This is to reduce some maintenance effort.

But not all RISC-V boards need this configuration.
If we enable it by default, non spl configuration will run this fdt fix flow, but it is unnecessary.

Quoted 6 lines
Quoted 3 lines

Non SPL configuration also needs this, because U-Boot has to patch the final DTB that is passed to the kernel. It's a RISC-V architecture thing.

But non SPL configuration will not run openSbi, why it will need this flow ?

Which configuration is this?

Regards,
Bin

#15 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

Hi Bin

Bin Meng <[email protected]> ? 2020?6?2? ?? ??2:13???

Quoted 62 lines

Hi Rick,

Quoted 58 lines · Rick Chen

Hi Bin

Quoted 55 lines

Hi Rick,

Quoted 51 lines · Rick Chen

Hi Bin

Quoted 38 lines

Hi Rick,

Quoted 29 lines · Rick Chen

Hi Bin

Quoted 26 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +0 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
Quoted 5 lines

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 2 lines
arch/riscv/Kconfig +2 -0
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

Quoted 5 lines

I believe we should turn on this feature by default for every RISC-V board, because SBI firmware used memory must be marked as reserved otherwise OS might use it and get crashed. For boards which don't want to enable this, they can unset the option in their board defconfig files. This is to reduce some maintenance effort.

But not all RISC-V boards need this configuration.
If we enable it by default, non spl configuration will run this fdt fix flow, but it is unnecessary.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Non SPL configuration also needs this, because U-Boot has to patch the final DTB that is passed to the kernel. It's a RISC-V architecture thing.

But non SPL configuration will not run openSbi, why it will need this flow ?

Which configuration is this?

e.q: ae350_rv[32|64]_defconfig

Thanks,
Rick

Quoted 3 lines

Regards,
Bin

author
#16 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

Hi Rick,

Quoted 70 lines · Rick Chen

Hi Bin

Bin Meng <[email protected]> ? 2020?6?2? ?? ??2:13???

Quoted 66 lines

Hi Rick,

Quoted 62 lines · Rick Chen

Hi Bin

Quoted 58 lines

Hi Rick,

Quoted 47 lines · Rick Chen

Hi Bin

Quoted 38 lines

Hi Rick,

Quoted 29 lines · Rick Chen

Hi Bin

Quoted 26 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +0 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
Quoted 5 lines

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 2 lines
arch/riscv/Kconfig +2 -0
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

Quoted 5 lines

I believe we should turn on this feature by default for every RISC-V board, because SBI firmware used memory must be marked as reserved otherwise OS might use it and get crashed. For boards which don't want to enable this, they can unset the option in their board defconfig files. This is to reduce some maintenance effort.

Quoted 4 lines

But not all RISC-V boards need this configuration.
If we enable it by default, non spl configuration will run this fdt fix flow, but it is unnecessary.

Non SPL configuration also needs this, because U-Boot has to patch the final DTB that is passed to the kernel. It's a RISC-V architecture thing.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

But non SPL configuration will not run openSbi, why it will need this flow ?

Which configuration is this?

e.q: ae350_rv[32|64]_defconfig

It looks these 2 configs are for U-Boot M-mode. How are they supposed to work, if they do not work with OpenSBI?

Regards,
Bin

#17 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

Hi Bin

Bin Meng <[email protected]> ? 2020?6?2? ?? ??2:33???

Quoted 77 lines

Hi Rick,

Quoted 73 lines · Rick Chen

Hi Bin

Bin Meng <[email protected]> ? 2020?6?2? ?? ??2:13???

Quoted 69 lines

Hi Rick,

Quoted 64 lines · Rick Chen

Hi Bin

Quoted 50 lines

Hi Rick,

Quoted 47 lines · Rick Chen

Hi Bin

Quoted 43 lines

Hi Rick,

Quoted 29 lines · Rick Chen

Hi Bin

Quoted 26 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +0 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
Quoted 5 lines

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 2 lines
arch/riscv/Kconfig +2 -0
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

I believe we should turn on this feature by default for every RISC-V board, because SBI firmware used memory must be marked as reserved otherwise OS might use it and get crashed. For boards which don't want to enable this, they can unset the option in their board defconfig files. This is to reduce some maintenance effort.

Quoted 8 lines
Quoted 4 lines

But not all RISC-V boards need this configuration.
If we enable it by default, non spl configuration will run this fdt fix flow, but it is unnecessary.

Non SPL configuration also needs this, because U-Boot has to patch the final DTB that is passed to the kernel. It's a RISC-V architecture thing.

But non SPL configuration will not run openSbi, why it will need this flow ?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Which configuration is this?

e.q: ae350_rv[32|64]_defconfig

It looks these 2 configs are for U-Boot M-mode. How are they supposed to work, if they do not work with OpenSBI?

They work with BBL(riscv-pk).

Thanks,
Rick

Quoted 3 lines

Regards,
Bin

#18 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

Quoted 86 lines · Rick Chen

Hi Bin

Bin Meng <[email protected]> ? 2020?6?2? ?? ??2:33???

Quoted 82 lines

Hi Rick,

Quoted 77 lines · Rick Chen

Hi Bin

Bin Meng <[email protected]> ? 2020?6?2? ?? ??2:13???

Quoted 62 lines

Hi Rick,

Quoted 58 lines · Rick Chen

Hi Bin

Quoted 55 lines

Hi Rick,

Quoted 51 lines · Rick Chen

Hi Bin

Quoted 38 lines

Hi Rick,

Quoted 29 lines · Rick Chen

Hi Bin

Quoted 26 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +0 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
Quoted 5 lines

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 2 lines
arch/riscv/Kconfig +2 -0
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

Quoted 5 lines

I believe we should turn on this feature by default for every RISC-V board, because SBI firmware used memory must be marked as reserved otherwise OS might use it and get crashed. For boards which don't want to enable this, they can unset the option in their board defconfig files. This is to reduce some maintenance effort.

But not all RISC-V boards need this configuration.
If we enable it by default, non spl configuration will run this fdt fix flow, but it is unnecessary.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Non SPL configuration also needs this, because U-Boot has to patch the final DTB that is passed to the kernel. It's a RISC-V architecture thing.

But non SPL configuration will not run openSbi, why it will need this flow ?

Which configuration is this?

e.q: ae350_rv[32|64]_defconfig

Quoted 11 lines
Quoted 2 lines

It looks these 2 configs are for U-Boot M-mode. How are they supposed to work, if they do not work with OpenSBI?

They work with BBL(riscv-pk).

Thanks,
Rick

Quoted 3 lines

Regards,
Bin

How about enabling only if OF_SEPARATE is enabled ? We don't need a board fixup for prior stage case.

Signature · 2 lines
Regards,
Atish
#19 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

Hi Atish

Atish Patra <[email protected]> ? 2020?6?3? ?? ??2:22???

Quoted 97 lines · Rick Chen
Quoted 95 lines

Hi Bin

Bin Meng <[email protected]> ? 2020?6?2? ?? ??2:33???

Quoted 77 lines

Hi Rick,

Quoted 73 lines · Rick Chen

Hi Bin

Bin Meng <[email protected]> ? 2020?6?2? ?? ??2:13???

Quoted 69 lines

Hi Rick,

Quoted 64 lines · Rick Chen

Hi Bin

Quoted 50 lines

Hi Rick,

Quoted 47 lines · Rick Chen

Hi Bin

Quoted 43 lines

Hi Rick,

Quoted 29 lines · Rick Chen

Hi Bin

Quoted 26 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +0 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
Quoted 5 lines

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 2 lines
arch/riscv/Kconfig +2 -0
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

I believe we should turn on this feature by default for every RISC-V board, because SBI firmware used memory must be marked as reserved otherwise OS might use it and get crashed. For boards which don't want to enable this, they can unset the option in their board defconfig files. This is to reduce some maintenance effort.

Quoted 8 lines
Quoted 4 lines

But not all RISC-V boards need this configuration.
If we enable it by default, non spl configuration will run this fdt fix flow, but it is unnecessary.

Non SPL configuration also needs this, because U-Boot has to patch the final DTB that is passed to the kernel. It's a RISC-V architecture thing.

But non SPL configuration will not run openSbi, why it will need this flow ?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Which configuration is this?

e.q: ae350_rv[32|64]_defconfig

It looks these 2 configs are for U-Boot M-mode. How are they supposed to work, if they do not work with OpenSBI?

They work with BBL(riscv-pk).

Thanks,
Rick

Quoted 1 line
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines

Regards,
Bin

How about enabling only if OF_SEPARATE is enabled ? We don't need a board fixup for prior stage case.

It is a good suggestion.

Thanks,
Rick

Quoted 4 lines

--
Regards,
Atish

#20 lore raw

PATCH 2/2 riscv: Enable CONFIG_OF_BOARD_FIXUP by default

In reply to Rick Chen
Quoted 83 lines · Rick Chen

Hi Bin

Bin Meng <[email protected]> ? 2020?6?2? ?? ??2:33???

Quoted 79 lines

Hi Rick,

Quoted 75 lines · Rick Chen

Hi Bin

Bin Meng <[email protected]> ? 2020?6?2? ?? ??2:13???

Quoted 70 lines

Hi Rick,

Quoted 58 lines · Rick Chen

Hi Bin

Quoted 55 lines

Hi Rick,

Quoted 51 lines · Rick Chen

Hi Bin

Quoted 38 lines

Hi Rick,

Quoted 29 lines · Rick Chen

Hi Bin

Quoted 26 lines

From: Bin Meng [mailto:bmeng.cn at gmail.com]
Sent: Wednesday, May 20, 2020 3:40 PM
To: Rick Jian-Zhi Chen(???); U-Boot Mailing List
Cc: Bin Meng
Subject: [PATCH 2/2] riscv: Enable CONFIG_OF_BOARD_FIXUP by default

From: Bin Meng <[email protected]>

Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the reserved memory node for PMP protected memory regions. All RISC-V boards needs 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.

---

 arch/riscv/Kconfig             | 3 +++
 configs/sifive_fu540_defconfig | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +0 -0
@@ -272,4 +272,7 @@ config STACK_SIZE_SHIFT
        int
        default 14
 
Quoted 5 lines

arch/riscv/Kconfig config STACK_SIZE_SHIFT · line 276

Quoted 2 lines
arch/riscv/Kconfig +2 -0
+config OF_BOARD_FIXUP
+       default y

I think it shall invoke by individual board, just like the description of riscv_fdt_copy_resv_mem_node function.

Quoted 5 lines

I believe we should turn on this feature by default for every RISC-V board, because SBI firmware used memory must be marked as reserved otherwise OS might use it and get crashed. For boards which don't want to enable this, they can unset the option in their board defconfig files. This is to reduce some maintenance effort.

But not all RISC-V boards need this configuration.
If we enable it by default, non spl configuration will run this fdt fix flow, but it is unnecessary.

Quoted 6 lines
Quoted 3 lines

Non SPL configuration also needs this, because U-Boot has to patch the final DTB that is passed to the kernel. It's a RISC-V architecture thing.

But non SPL configuration will not run openSbi, why it will need this flow ?

Which configuration is this?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

e.q: ae350_rv[32|64]_defconfig

It looks these 2 configs are for U-Boot M-mode. How are they supposed to work, if they do not work with OpenSBI?

They work with BBL(riscv-pk).

Does BBL support /reserved-memory node add support ?
If not, riscv_fdt_copy_resv_mem_node should have returned in the first check unless
you added it manually for verification.

Quoted 6 lines

Thanks,
Rick

Quoted 3 lines

Regards,
Bin

Signature · 2 lines
Regards,
Atish

A message that is not in the archive (sent off-list or not yet received): [email protected]

#22 lore raw

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

Quoted 6 lines

From: Bin Meng [mailto:bmeng.cn at 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

Quoted 6 lines

From: Bin Meng <[email protected]>

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.

---

Quoted 37 lines
 arch/riscv/lib/fdt_fixup.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
arch/riscv/lib/fdt_fixup.c +10 -5
@@ -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