[PATCH 1/2] spl: make SYS_SPL_MALLOC depend on !(SPL_STACK_R && SPL_SYS_MALLOC_SIMPLE)

Rasmus Villemoes rasmus.villemoes at prevas.dk
Fri Sep 15 19:50:49 CEST 2023


Currently, one can have both SYS_SPL_MALLOC=y and
SPL_SYS_MALLOC_SIMPLE=y.

However, while the former does make board_init_r() in spl.c call
mem_malloc_init(), that has no effect at all, because that just
updates a few bookkeeping variables, but as the linker map shows, the
latter setting has (as expected) caused most of dlmalloc.o to be
garbage-collected. That is, those bookkeeping variables are not used
for anything.

IOWs, with SYS_SPL_MALLOC=y and SPL_SYS_MALLOC_SIMPLE=y, the value of
CONFIG_SYS_SPL_MALLOC_SIZE is irrelevant, and one still only has the
small, SRAM-backed, malloc arena available.

Now I want to change that so that the mem_malloc_init() instead
updates the gd->malloc* variables to point at the SDRAM area.

However, there's a small complication, namely when SPL_STACK_R=y is
also in the mix. In that case, the "simple" malloc arena is indeed
updated to point at the SDRAM area carved out of the new stack (see
spl_relocate_stack_gd()). So that case works in the sense that one
does get a "large" "simple" malloc arena (of size
SPL_STACK_R_MALLOC_SIMPLE_LEN) - but CONFIG_SYS_SPL_MALLOC_SIZE is
still irrelevant. Once I change the mem_malloc_init() logic, this
would then break, because the gd->malloc* variables would be updated
again. Also, it doesn't really make sense to allow the .config to
essentially specify two different SDRAM-backed malloc arenas.

So since CONFIG_SYS_SPL_MALLOC and its dependent options are no-ops
currently when SPL_STACK_R && SPL_SYS_MALLOC_SIMPLE, simply forbid
that combination.

Simple grepping suggests that these boards/configs are affected, in
that they become a tiny bit smaller, and the defconfig will need
refreshing:

  am62ax_evm_r5_defconfig
  am62x_evm_r5_defconfig
  am64x_evm_a53_defconfig
  am64x_evm_r5_defconfig
  am65x_evm_a53_defconfig
  am65x_hs_evm_a53_defconfig
  iot2050_defconfig
  j7200_evm_a72_defconfig
  j721e_evm_a72_defconfig
  j721s2_evm_a72_defconfig
  j721s2_evm_r5_defconfig
  verdin-am62_r5_defconfig

Signed-off-by: Rasmus Villemoes <rasmus.villemoes at prevas.dk>
---
 common/spl/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index c5dd476db5..fca9ada337 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -405,6 +405,7 @@ config SPL_SEPARATE_BSS
 config SYS_SPL_MALLOC
 	bool "Enable malloc pool in SPL"
 	depends on SPL_FRAMEWORK
+	depends on !(SPL_STACK_R && SPL_SYS_MALLOC_SIMPLE)
 
 config HAS_CUSTOM_SPL_MALLOC_START
 	bool "For the SPL malloc pool, define a custom starting address"
-- 
2.37.2



More information about the U-Boot mailing list