[PATCH 0/4] 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(-)

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.
Signed-off-by: Michal Simek michal.simek@xilinx.com ---
include/configs/xilinx_versal.h | 1 - include/configs/xilinx_zynqmp.h | 1 - include/configs/zynq-common.h | 1 - 3 files changed, 3 deletions(-)
diff --git a/include/configs/xilinx_versal.h b/include/configs/xilinx_versal.h index 32cd5b21f7b7..d7255a05dff1 100644 --- a/include/configs/xilinx_versal.h +++ b/include/configs/xilinx_versal.h @@ -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" \ diff --git a/include/configs/xilinx_zynqmp.h b/include/configs/xilinx_zynqmp.h index 7c24bf632e3f..15ad4198a6be 100644 --- a/include/configs/xilinx_zynqmp.h +++ b/include/configs/xilinx_zynqmp.h @@ -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" \ diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h index 79c75784f2bf..1607a8d06518 100644 --- a/include/configs/zynq-common.h +++ b/include/configs/zynq-common.h @@ -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" \

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.
Signed-off-by: Michal Simek michal.simek@xilinx.com ---
board/xilinx/common/board.c | 6 ------ 1 file changed, 6 deletions(-)
diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index 0782d08ee3fe..901591ba2a85 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -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);

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.
Signed-off-by: Michal Simek michal.simek@xilinx.com ---
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(-)
diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index 901591ba2a85..581c88ad49a4 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -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; }

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.
Signed-off-by: Michal Simek michal.simek@xilinx.com ---
board/xilinx/common/board.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c index 581c88ad49a4..eab389d049f2 100644 --- a/board/xilinx/common/board.c +++ b/board/xilinx/common/board.c @@ -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__);

st 12. 8. 2020 v 12:42 odesÃlatel Michal Simek michal.simek@xilinx.com napsal:
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(-)
-- 2.28.0
Applied all. M
participants (2)
-
Michal Simek
-
Michal Simek