Skip to contentSkip to conversation

xilinx: common: Fix fdt/initrd_high and bootm_* variables

PATCH New Michal Simek 2 participants 6 messages Aug 12, 2020 – Aug 20, 2020 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

cover xilinx: common: Fix fdt/initrd_high and bootm_* variables

Hi,

this series is removing fdt/initrd_high variables and tune bootm_size run time setup to match needs from Linux kernel.

Thanks,
Michal

Michal Simek (4):
xilinx: common: Get rid of fdt_high variable
xilinx: common: Get rid of initrd_high variable setup
xilinx: common: Check return value from variable setup
xilinx: common: Change bootm_size variable setting

 board/xilinx/common/board.c     | 17 ++++++++++-------
 include/configs/xilinx_versal.h |  1 -
 include/configs/xilinx_zynqmp.h |  1 -
 include/configs/zynq-common.h   |  1 -
 4 files changed, 10 insertions(+), 10 deletions(-)
Signature · 1 line
2.28.0
#1 lore raw

PATCH 1/4 xilinx: common: Get rid of fdt_high variable

There is no need to setup this variable if bootm_low and bootm_size variable are properly setup. If fdt_high variable is missing U-Boot is asking LMB to return free memory which is not used.

---

 include/configs/xilinx_versal.h | 1 -
 include/configs/xilinx_zynqmp.h | 1 -
 include/configs/zynq-common.h   | 1 -
 3 files changed, 3 deletions(-)
include/configs/xilinx_versal.h +0 -1
index 32cd5b21f7b7..d7255a05dff1 100644
@@ -79,7 +79,6 @@
 #define CONFIG_CLOCKS
 
 #define ENV_MEM_LAYOUT_SETTINGS \
-	"fdt_high=10000000\0" \
 	"fdt_addr_r=0x40000000\0" \
 	"fdt_size_r=0x400000\0" \
 	"pxefile_addr_r=0x10000000\0" \
include/configs/xilinx_zynqmp.h +0 -1
index 7c24bf632e3f..15ad4198a6be 100644
@@ -101,7 +101,6 @@
 #define CONFIG_CLOCKS
 
 #define ENV_MEM_LAYOUT_SETTINGS \
-	"fdt_high=10000000\0" \
 	"fdt_addr_r=0x40000000\0" \
 	"fdt_size_r=0x400000\0" \
 	"pxefile_addr_r=0x10000000\0" \
include/configs/zynq-common.h +0 -1
index 79c75784f2bf..1607a8d06518 100644
@@ -196,7 +196,6 @@
 /* Default environment */
 #ifndef CONFIG_EXTRA_ENV_SETTINGS
 #define CONFIG_EXTRA_ENV_SETTINGS	\
-	"fdt_high=0x20000000\0"		\
 	"scriptaddr=0x20000\0"	\
 	"script_size_f=0x40000\0"	\
 	"fdt_addr_r=0x1f00000\0"        \
Signature · 1 line
2.28.0
#2 lore raw

PATCH 2/4 xilinx: common: Get rid of initrd_high variable setup

In reply to Michal Simek

When bootm_low/bootm_size are setup properly there is no need to setup any initrd_high address. Location for initrd is determined through LMB.

---

 board/xilinx/common/board.c | 6 ------
 1 file changed, 6 deletions(-)
board/xilinx/common/board.c +0 -6
index 0782d08ee3fe..901591ba2a85 100644
@@ -77,14 +77,8 @@ void *board_fdt_blob_setup(void)
 
 int board_late_init_xilinx(void)
 {
-	ulong initrd_hi;
-
 	env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET);
 
-	initrd_hi = gd->start_addr_sp - CONFIG_STACK_SIZE;
-	initrd_hi = round_down(initrd_hi, SZ_16M);
-	env_set_addr("initrd_high", (void *)initrd_hi);
-
 	env_set_addr("bootm_low", (void *)gd->ram_base);
 	env_set_addr("bootm_size", (void *)gd->ram_size);
 
Signature · 1 line
2.28.0
#3 lore raw

PATCH 3/4 xilinx: common: Check return value from variable setup

In reply to Michal Simek

env_set..() can failed that's why check return status and report it back to make sure that user is aware that's something went wrong.

---

Change type to u32 to have defined bit operations (mentioned by Marek) Origin patch sent as https://lists.denx.de/pipermail/u-boot/2020-August/422508.html

---
 board/xilinx/common/board.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
board/xilinx/common/board.c +8 -3
index 901591ba2a85..581c88ad49a4 100644
@@ -77,10 +77,15 @@ void *board_fdt_blob_setup(void)
 
 int board_late_init_xilinx(void)
 {
-	env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET);
+	u32 ret = 0;
 
-	env_set_addr("bootm_low", (void *)gd->ram_base);
-	env_set_addr("bootm_size", (void *)gd->ram_size);
+	ret |= env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET);
+
+	ret |= env_set_addr("bootm_low", (void *)gd->ram_base);
+	ret |= env_set_addr("bootm_size", (void *)gd->ram_size);
+
+	if (ret)
+		printf("%s: Saving run time variables FAILED\n", __func__);
 
 	return 0;
 }
Signature · 1 line
2.28.0
#4 lore raw

PATCH 4/4 xilinx: common: Change bootm_size variable setting

In reply to Michal Simek

Linux kernel for arm32 requires dtb and initrd to be placed in low memory to work properly. This requirement is described in chapter 4b) and 5) in Linux documentation (Documentation/arm/booting.rst).

There is an issue on arm32 with 2GB of memory that bootm_size is bigger than Linux lowmem (for example with VMSPLIT_3G). That's why limit bootm size on these systems not to be above 768MB.

---

 board/xilinx/common/board.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
board/xilinx/common/board.c +5 -1
index 581c88ad49a4..eab389d049f2 100644
@@ -78,11 +78,15 @@ void *board_fdt_blob_setup(void)
 int board_late_init_xilinx(void)
 {
 	u32 ret = 0;
+	phys_size_t bootm_size = gd->ram_size;
+
+	if (CONFIG_IS_ENABLED(ARCH_ZYNQ))
+		bootm_size = min(bootm_size, (phys_size_t)(SZ_512M + SZ_256M));
 
 	ret |= env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET);
 
 	ret |= env_set_addr("bootm_low", (void *)gd->ram_base);
-	ret |= env_set_addr("bootm_size", (void *)gd->ram_size);
+	ret |= env_set_addr("bootm_size", (void *)bootm_size);
 
 	if (ret)
 		printf("%s: Saving run time variables FAILED\n", __func__);
Signature · 1 line
2.28.0
#5 lore raw

cover xilinx: common: Fix fdt/initrd_high and bootm_* variables

In reply to Michal Simek

st 12. 8. 2020 v 12:42 odes?latel Michal Simek <[email protected]> napsal:

Quoted 16 lines

Hi,

this series is removing fdt/initrd_high variables and tune bootm_size run time setup to match needs from Linux kernel.

Thanks,
Michal

Michal Simek (4):
xilinx: common: Get rid of fdt_high variable
xilinx: common: Get rid of initrd_high variable setup
xilinx: common: Check return value from variable setup
xilinx: common: Change bootm_size variable setting

Quoted 9 lines
 board/xilinx/common/board.c     | 17 ++++++++++-------
 include/configs/xilinx_versal.h |  1 -
 include/configs/xilinx_zynqmp.h |  1 -
 include/configs/zynq-common.h   |  1 -
 4 files changed, 10 insertions(+), 10 deletions(-)

--
2.28.0

Applied all.
M

Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs