Skip to contentSkip to conversation

arm64: Setting up initrd_hi at run time

PATCH New Michal Simek 2 participants 4 messages Sep 11, 2019 – Oct 8, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover arm64: Setting up initrd_hi at run time

Hi,

we are running one u-boot configurations on various boards with different amount of memory that setting up initrd_high is problematic. There shouldn't be a problem to setup initrd_high at run time based on DDR size detection.
The same changes are done for ZynqMP and Versal.

Thanks,
Michal

Siva Durga Prasad Paladugu (1):
arm64: versal: Set initrd_high to as high as possible

T Karthik Reddy (1):
arm64: zynqmp: Set initrd_high to as high as possible

 arch/arm/Kconfig                | 16 ++++++++++++++++
 board/xilinx/versal/board.c     |  6 ++++++
 board/xilinx/zynqmp/zynqmp.c    |  6 ++++++
 include/configs/xilinx_versal.h |  1 -
 include/configs/xilinx_zynqmp.h |  1 -
 5 files changed, 28 insertions(+), 2 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 arm64: versal: Set initrd_high to as high as possible

From: Siva Durga Prasad Paladugu <[email protected]>

This patch is setting up the initrd_high to as high as possible by leaving max stack size for u-boot so that bigger rootfs can also be loaded by u-boot for booting kernel.

---

 arch/arm/Kconfig                | 16 ++++++++++++++++
 board/xilinx/versal/board.c     |  6 ++++++
 include/configs/xilinx_versal.h |  1 -
 3 files changed, 22 insertions(+), 1 deletion(-)
arch/arm/Kconfig +16 -0
index a93138aa0ada..33cb3e065830 100644
@@ -462,6 +462,22 @@ config TPL_USE_ARCH_MEMSET
 	  Such implementation may be faster under some conditions
 	  but may increase the binary size.
 
+config SET_STACK_SIZE
+	bool "Enable an option to set max stack size that can be used"
+	default y if ARCH_VERSAL
+	help
+	  This will enable an option to set max stack size that can be
+	  used by u-boot.
+
+config STACK_SIZE
+	hex "Define max stack size that can be used by u-boot"
+	depends on SET_STACK_SIZE
+	default 0x4000000 if ARCH_VERSAL
+	help
+	  Defines Max stack size that can be used by u-boot so that the
+	  initrd_high will be calculated as base stack pointer minus this
+	  stack size.
+
 config ARM64_SUPPORT_AARCH32
 	bool "ARM64 system support AArch32 execution state"
 	depends on ARM64
board/xilinx/versal/board.c +6 -0
index a2b00aa0b662..2b4edd8738b4 100644
@@ -12,6 +12,7 @@
 #include <dm/device.h>
 #include <dm/uclass.h>
 #include <versalpl.h>
+#include <linux/sizes.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -88,6 +89,7 @@ int board_late_init(void)
 	const char *mode;
 	char *new_targets;
 	char *env_targets;
+	ulong initrd_hi;
 
 	if (!(gd->flags & GD_FLG_ENV_DEFAULT)) {
 		debug("Saved variables - Skipping\n");
@@ -183,6 +185,10 @@ int board_late_init(void)
 
 	env_set("boot_targets", new_targets);
 
+	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);
+
 	return 0;
 }
 
include/configs/xilinx_versal.h +0 -1
index 296f4502c652..1e0951c1d92d 100644
@@ -65,7 +65,6 @@
 
 #define ENV_MEM_LAYOUT_SETTINGS \
 	"fdt_high=10000000\0" \
-	"initrd_high=10000000\0" \
 	"fdt_addr_r=0x40000000\0" \
 	"pxefile_addr_r=0x10000000\0" \
 	"kernel_addr_r=0x18000000\0" \
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/2 arm64: zynqmp: Set initrd_high to as high as possible

In reply to Michal Simek

From: T Karthik Reddy <[email protected]>

This patch is setting up the initrd_high to as high as possible by leaving max stack size for u-boot so that bigger rootfs can also be loaded by u-boot for booting kernel.

---

 arch/arm/Kconfig                | 4 ++--
 board/xilinx/zynqmp/zynqmp.c    | 6 ++++++
 include/configs/xilinx_zynqmp.h | 1 -
 3 files changed, 8 insertions(+), 3 deletions(-)
arch/arm/Kconfig +2 -2
index 33cb3e065830..257a98d795e5 100644
@@ -464,7 +464,7 @@ config TPL_USE_ARCH_MEMSET
 
 config SET_STACK_SIZE
 	bool "Enable an option to set max stack size that can be used"
-	default y if ARCH_VERSAL
+	default y if ARCH_VERSAL || ARCH_ZYNQMP
 	help
 	  This will enable an option to set max stack size that can be
 	  used by u-boot.
@@ -472,7 +472,7 @@ config SET_STACK_SIZE
 config STACK_SIZE
 	hex "Define max stack size that can be used by u-boot"
 	depends on SET_STACK_SIZE
-	default 0x4000000 if ARCH_VERSAL
+	default 0x4000000 if ARCH_VERSAL || ARCH_ZYNQMP
 	help
 	  Defines Max stack size that can be used by u-boot so that the
 	  initrd_high will be calculated as base stack pointer minus this
board/xilinx/zynqmp/zynqmp.c +6 -0
index d649daba96d4..0c331e332230 100644
@@ -22,6 +22,7 @@
 #include <dwc3-uboot.h>
 #include <zynqmppl.h>
 #include <g_dnl.h>
+#include <linux/sizes.h>
 
 #include "pm_cfg_obj.h"
 
@@ -530,6 +531,7 @@ int board_late_init(void)
 	char *new_targets;
 	char *env_targets;
 	int ret;
+	ulong initrd_hi;
 
 #if defined(CONFIG_USB_ETHER) && !defined(CONFIG_USB_GADGET_DOWNLOAD)
 	usb_ether_init();
@@ -647,6 +649,10 @@ int board_late_init(void)
 
 	env_set("boot_targets", new_targets);
 
+	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);
+
 	reset_reason();
 
 	return 0;
include/configs/xilinx_zynqmp.h +0 -1
index ddeb24a0af6e..cdcf853fceb3 100644
@@ -109,7 +109,6 @@
 
 #define ENV_MEM_LAYOUT_SETTINGS \
 	"fdt_high=10000000\0" \
-	"initrd_high=10000000\0" \
 	"fdt_addr_r=0x40000000\0" \
 	"pxefile_addr_r=0x10000000\0" \
 	"kernel_addr_r=0x18000000\0" \
Signature · 1 line
2.17.1
Applied
#3 lore raw

cover arm64: Setting up initrd_hi at run time

In reply to Michal Simek

st 11. 9. 2019 v 9:28 odesílatel Michal Simek <[email protected]> napsal:

Quoted 26 lines

Hi,

we are running one u-boot configurations on various boards with different amount of memory that setting up initrd_high is problematic. There shouldn't be a problem to setup initrd_high at run time based on DDR size detection.
The same changes are done for ZynqMP and Versal.

Thanks,
Michal

Siva Durga Prasad Paladugu (1):
arm64: versal: Set initrd_high to as high as possible

T Karthik Reddy (1):
arm64: zynqmp: Set initrd_high to as high as possible

 arch/arm/Kconfig                | 16 ++++++++++++++++
 board/xilinx/versal/board.c     |  6 ++++++
 board/xilinx/zynqmp/zynqmp.c    |  6 ++++++
 include/configs/xilinx_versal.h |  1 -
 include/configs/xilinx_zynqmp.h |  1 -
 5 files changed, 28 insertions(+), 2 deletions(-)
Quoted 3 lines

--
2.17.1

Applied.
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