[PATCH v3 1/3] lmb: Fix lmb property's defination under struct lmb

From: Ashok Reddy Soma ashok.reddy.soma@xilinx.com
Under struct lmb {} the lmb property's should be defined only if CONFIG_LMB_MEMORY_REGIONS is defined.
Signed-off-by: Ashok Reddy Soma ashok.reddy.soma@xilinx.com Signed-off-by: Michal Simek michal.simek@xilinx.com
Signed-off-by: Michal Simek michal.simek@amd.com ---
(no changes since v2)
Changes in v2: - Also fix lib/lmb.c
include/lmb.h | 2 +- lib/lmb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/lmb.h b/include/lmb.h index ab277ca80004..1476d78c2823 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -68,7 +68,7 @@ struct lmb_region { struct lmb { struct lmb_region memory; struct lmb_region reserved; -#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS) +#if IS_ENABLED(CONFIG_LMB_MEMORY_REGIONS) struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS]; struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS]; #endif diff --git a/lib/lmb.c b/lib/lmb.c index f72996a4248e..f21fe672ae96 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -108,7 +108,7 @@ void lmb_init(struct lmb *lmb) #if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS) lmb->memory.max = CONFIG_LMB_MAX_REGIONS; lmb->reserved.max = CONFIG_LMB_MAX_REGIONS; -#else +#elif IS_ENABLED(CONFIG_LMB_MEMORY_REGIONS) lmb->memory.max = CONFIG_LMB_MEMORY_REGIONS; lmb->reserved.max = CONFIG_LMB_RESERVED_REGIONS; lmb->memory.region = lmb->memory_regions;

From: Ashok Reddy Soma ashok.reddy.soma@xilinx.com
With commit ce39ee28ec31 ("zynqmp: Do not place u-boot to reserved memory location"), the function board_get_usable_ram_top() is allocating MMU_SECTION_SIZE of about 2MB using lmb_alloc(). But we dont have this much memory in case of mini U-Boot.
Keep these functions which use lmb under CONFIG_LMB so that they are compiled and used only when LMB is enabled.
Signed-off-by: Ashok Reddy Soma ashok.reddy.soma@xilinx.com Signed-off-by: Michal Simek michal.simek@xilinx.com
Signed-off-by: Michal Simek michal.simek@amd.com ---
Changes in v3: - Update arch bootm implementation called image_setup_linux()
arch/arc/lib/bootm.c | 8 +++++--- arch/arm/lib/bootm.c | 2 +- arch/m68k/lib/bootm.c | 8 +++++--- arch/microblaze/lib/bootm.c | 2 +- arch/powerpc/lib/bootm.c | 8 +++++--- arch/riscv/lib/bootm.c | 2 +- arch/x86/lib/bootm.c | 5 ++--- board/xilinx/zynqmp/zynqmp.c | 3 +++ boot/image-board.c | 4 ++++ 9 files changed, 27 insertions(+), 15 deletions(-)
diff --git a/arch/arc/lib/bootm.c b/arch/arc/lib/bootm.c index ed6c5dfa5845..628addd87ed5 100644 --- a/arch/arc/lib/bootm.c +++ b/arch/arc/lib/bootm.c @@ -29,9 +29,11 @@ static int boot_prep_linux(bootm_headers_t *images) { int ret;
- ret = image_setup_linux(images); - if (ret) - return ret; + if (CONFIG_IS_ENABLED(LMB)) { + ret = image_setup_linux(images); + if (ret) + return ret; + }
return board_prep_linux(images); } diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index fc22befeac1f..9f086f3b904d 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -199,7 +199,7 @@ static void boot_prep_linux(bootm_headers_t *images) { char *commandline = env_get("bootargs");
- if (CONFIG_IS_ENABLED(OF_LIBFDT) && images->ft_len) { + if (CONFIG_IS_ENABLED(OF_LIBFDT) && CONFIG_IS_ENABLED(LMB) && images->ft_len) { debug("using: FDT\n"); if (image_setup_linux(images)) { panic("FDT creation failed!"); diff --git a/arch/m68k/lib/bootm.c b/arch/m68k/lib/bootm.c index 27729db67e27..9cade929541f 100644 --- a/arch/m68k/lib/bootm.c +++ b/arch/m68k/lib/bootm.c @@ -60,9 +60,11 @@ int do_bootm_linux(int flag, int argc, char *const argv[], } set_clocks_in_mhz(kbd);
- ret = image_setup_linux(images); - if (ret) - goto error; + if (CONFIG_IS_ENABLED(LMB)) { + ret = image_setup_linux(images); + if (ret) + goto error; + }
kernel = (void (*)(struct bd_info *, ulong, ulong, ulong, ulong))images->ep;
diff --git a/arch/microblaze/lib/bootm.c b/arch/microblaze/lib/bootm.c index af946b864282..31b6659cdf75 100644 --- a/arch/microblaze/lib/bootm.c +++ b/arch/microblaze/lib/bootm.c @@ -73,7 +73,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
static void boot_prep_linux(bootm_headers_t *images) { - if (CONFIG_IS_ENABLED(OF_LIBFDT) && images->ft_len) { + if (CONFIG_IS_ENABLED(OF_LIBFDT) && CONFIG_IS_ENABLED(LMB) && images->ft_len) { debug("using: FDT\n"); if (image_setup_linux(images)) { printf("FDT creation failed! hanging..."); diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c index d365705856dd..e52aa75703f3 100644 --- a/arch/powerpc/lib/bootm.c +++ b/arch/powerpc/lib/bootm.c @@ -214,9 +214,11 @@ static int boot_body_linux(bootm_headers_t *images) if (ret) return ret;
- ret = image_setup_linux(images); - if (ret) - return ret; + if (CONFIG_IS_ENABLED(LMB)) { + ret = image_setup_linux(images); + if (ret) + return ret; + }
return 0; } diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c index c1ac339283a6..670d9c9ebcfb 100644 --- a/arch/riscv/lib/bootm.c +++ b/arch/riscv/lib/bootm.c @@ -64,7 +64,7 @@ static void announce_and_cleanup(int fake)
static void boot_prep_linux(bootm_headers_t *images) { - if (CONFIG_IS_ENABLED(OF_LIBFDT) && images->ft_len) { + if (CONFIG_IS_ENABLED(OF_LIBFDT) && CONFIG_IS_ENABLED(LMB) && images->ft_len) { debug("using: FDT\n"); if (image_setup_linux(images)) { printf("FDT creation failed! hanging..."); diff --git a/arch/x86/lib/bootm.c b/arch/x86/lib/bootm.c index 57cba5c65d3b..1bcdb3e30d26 100644 --- a/arch/x86/lib/bootm.c +++ b/arch/x86/lib/bootm.c @@ -78,15 +78,14 @@ static int boot_prep_linux(bootm_headers_t *images) size_t len; int ret;
-#ifdef CONFIG_OF_LIBFDT - if (images->ft_len) { + if (CONFIG_IS_ENABLED(OF_LIBFDT) && CONFIG_IS_ENABLED(LMB) && images->ft_len) { debug("using: FDT\n"); if (image_setup_linux(images)) { puts("FDT creation failed! hanging..."); hang(); } } -#endif + if (images->legacy_hdr_valid) { hdr = images->legacy_hdr_os; if (image_check_type(hdr, IH_TYPE_MULTI)) { diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c index 106c3953e1fc..f7c6e3ed4e3f 100644 --- a/board/xilinx/zynqmp/zynqmp.c +++ b/board/xilinx/zynqmp/zynqmp.c @@ -253,6 +253,7 @@ int dram_init(void) return 0; }
+#if defined(CONFIG_LMB) ulong board_get_usable_ram_top(ulong total_size) { phys_size_t size; @@ -277,6 +278,8 @@ ulong board_get_usable_ram_top(ulong total_size)
return reg + size; } +#endif + #else int dram_init_banksize(void) { diff --git a/boot/image-board.c b/boot/image-board.c index cfc1c658e3a6..03c866b5fa8e 100644 --- a/boot/image-board.c +++ b/boot/image-board.c @@ -537,6 +537,7 @@ int boot_get_ramdisk(int argc, char *const argv[], bootm_headers_t *images, return 0; }
+#if defined(CONFIG_LMB) /** * boot_ramdisk_high - relocate init ramdisk * @lmb: pointer to lmb handle, will be used for memory mgmt @@ -630,6 +631,7 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len, error: return -1; } +#endif
int boot_get_setup(bootm_headers_t *images, u8 arch, ulong *setup_start, ulong *setup_len) @@ -823,6 +825,7 @@ int boot_get_loadable(int argc, char *const argv[], bootm_headers_t *images, return 0; }
+#if defined(CONFIG_LMB) #ifdef CONFIG_SYS_BOOT_GET_CMDLINE /** * boot_get_cmdline - allocate and initialize kernel cmdline @@ -932,6 +935,7 @@ int image_setup_linux(bootm_headers_t *images)
return 0; } +#endif
void genimg_print_size(uint32_t size) {

From: Michal Simek michal.simek@xilinx.com
There is no need to have LMB enabled that's why save some space by disabling it.
aarch64: (for 8/8 boards) all -1168.5 rodata -105.5 text -1063.0 xilinx_zynqmp_mini: all -2013 rodata -185 text -1828 xilinx_zynqmp_mini_qspi: all -2013 rodata -185 text -1828 xilinx_zynqmp_mini_emmc0: all -2661 rodata -237 text -2424 xilinx_zynqmp_mini_emmc1: all -2661 rodata -237 text -2424
Signed-off-by: Michal Simek michal.simek@xilinx.com Signed-off-by: Michal Simek michal.simek@amd.com ---
(no changes since v2)
Changes in v2: - new patch in series
configs/xilinx_zynqmp_mini_defconfig | 1 + configs/xilinx_zynqmp_mini_emmc0_defconfig | 1 + configs/xilinx_zynqmp_mini_emmc1_defconfig | 1 + configs/xilinx_zynqmp_mini_qspi_defconfig | 1 + 4 files changed, 4 insertions(+)
diff --git a/configs/xilinx_zynqmp_mini_defconfig b/configs/xilinx_zynqmp_mini_defconfig index 5963dd90f726..1474434fb8d2 100644 --- a/configs/xilinx_zynqmp_mini_defconfig +++ b/configs/xilinx_zynqmp_mini_defconfig @@ -63,3 +63,4 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_ARM_DCC=y CONFIG_PANIC_HANG=y # CONFIG_GZIP is not set +# CONFIG_LMB is not set diff --git a/configs/xilinx_zynqmp_mini_emmc0_defconfig b/configs/xilinx_zynqmp_mini_emmc0_defconfig index a248cbf3a37b..047ffb4a7859 100644 --- a/configs/xilinx_zynqmp_mini_emmc0_defconfig +++ b/configs/xilinx_zynqmp_mini_emmc0_defconfig @@ -80,3 +80,4 @@ CONFIG_ARM_DCC=y CONFIG_PANIC_HANG=y # CONFIG_GZIP is not set # CONFIG_EFI_LOADER is not set +# CONFIG_LMB is not set diff --git a/configs/xilinx_zynqmp_mini_emmc1_defconfig b/configs/xilinx_zynqmp_mini_emmc1_defconfig index df0365ba77f8..5c9d2e126545 100644 --- a/configs/xilinx_zynqmp_mini_emmc1_defconfig +++ b/configs/xilinx_zynqmp_mini_emmc1_defconfig @@ -80,3 +80,4 @@ CONFIG_ARM_DCC=y CONFIG_PANIC_HANG=y # CONFIG_GZIP is not set # CONFIG_EFI_LOADER is not set +# CONFIG_LMB is not set diff --git a/configs/xilinx_zynqmp_mini_qspi_defconfig b/configs/xilinx_zynqmp_mini_qspi_defconfig index 82510f190477..98e1227d206d 100644 --- a/configs/xilinx_zynqmp_mini_qspi_defconfig +++ b/configs/xilinx_zynqmp_mini_qspi_defconfig @@ -84,3 +84,4 @@ CONFIG_SPI=y CONFIG_ZYNQMP_GQSPI=y CONFIG_PANIC_HANG=y # CONFIG_GZIP is not set +# CONFIG_LMB is not set

On 7/7/22 10:45, Michal Simek wrote:
From: Ashok Reddy Soma ashok.reddy.soma@xilinx.com
Under struct lmb {} the lmb property's should be defined only if CONFIG_LMB_MEMORY_REGIONS is defined.
Signed-off-by: Ashok Reddy Soma ashok.reddy.soma@xilinx.com Signed-off-by: Michal Simek michal.simek@xilinx.com
Signed-off-by: Michal Simek michal.simek@amd.com
(no changes since v2)
Changes in v2:
Also fix lib/lmb.c
include/lmb.h | 2 +- lib/lmb.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/lmb.h b/include/lmb.h index ab277ca80004..1476d78c2823 100644 --- a/include/lmb.h +++ b/include/lmb.h @@ -68,7 +68,7 @@ struct lmb_region { struct lmb { struct lmb_region memory; struct lmb_region reserved; -#if !IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS) +#if IS_ENABLED(CONFIG_LMB_MEMORY_REGIONS) struct lmb_property memory_regions[CONFIG_LMB_MEMORY_REGIONS]; struct lmb_property reserved_regions[CONFIG_LMB_RESERVED_REGIONS]; #endif diff --git a/lib/lmb.c b/lib/lmb.c index f72996a4248e..f21fe672ae96 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -108,7 +108,7 @@ void lmb_init(struct lmb *lmb) #if IS_ENABLED(CONFIG_LMB_USE_MAX_REGIONS) lmb->memory.max = CONFIG_LMB_MAX_REGIONS; lmb->reserved.max = CONFIG_LMB_MAX_REGIONS; -#else +#elif IS_ENABLED(CONFIG_LMB_MEMORY_REGIONS) lmb->memory.max = CONFIG_LMB_MEMORY_REGIONS; lmb->reserved.max = CONFIG_LMB_RESERVED_REGIONS; lmb->memory.region = lmb->memory_regions;
applied all. M
participants (1)
-
Michal Simek