[PATCH 0/2] make CONFIG_SPL_SYS_MALLOC_SIMPLE && CONFIG_SYS_SPL_MALLOC actually work
Rasmus Villemoes
rasmus.villemoes at prevas.dk
Fri Sep 15 19:50:48 CEST 2023
Currently, setting both CONFIG_SPL_SYS_MALLOC_SIMPLE and
CONFIG_SYS_SPL_MALLOC (but not CONFIG_SPL_STACK_R) doesn't work as
expected: The SIMPLE option means that all malloc etc. calls are
directed at build-time to the implementation in malloc_simple.c, but
the mem_alloc_init() call which is done in board_init_f() currently
calls into dlmalloc.c, and updates the variables describing the
dlmalloc arena - which is of course completely unused. And the
malloc() implementation continues to hand out allocations from the
initial SPL_SYS_MALLOC_F_LEN bytes.
These two patches are an attempt at making the combination in $subject
actually work as one would expect: define an area of sdram to be used
as a malloc arena, but still manage that using the malloc_simple()
implementation.
Since this now changes the mem_alloc_init() from being a harmless
no-op call to actually doing something, there's a risk of some boards
breaking. The solution for those boards will probably be to just drop
CONFIG_SYS_SPL_MALLOC, since that hasn't actually done anything.
Rasmus Villemoes (2):
spl: make SYS_SPL_MALLOC depend on !(SPL_STACK_R &&
SPL_SYS_MALLOC_SIMPLE)
malloc_simple: add mem_malloc_init_simple()
common/dlmalloc.c | 2 +-
common/malloc_simple.c | 7 +++++++
common/spl/Kconfig | 1 +
include/malloc.h | 7 +++++--
4 files changed, 14 insertions(+), 3 deletions(-)
--
2.37.2
More information about the U-Boot
mailing list