board_init: Fix the logic to setup malloc_base
PATCH 1/2 board_init: Fix the logic to setup malloc_base
From: Fabio Estevam <[email protected]>
Prior to commit 5ba534d247d418 ("arm: Switch 32-bit ARM to using generic global_data setup") we used to have assembly code that configured the malloc_base address.
After this commit we use the board_init_f_mem() function in C to setup malloc_base address.
However the ifdef logic has a problem that prevents malloc_base to be configured in the SPL case.
This issue has been observed in a Congatec board, where we need to retrieve the manufacturing information from the SPI NOR (the SPI API calls malloc) prior to configuring the DRAM. In this case as malloc_base was not configured we always see malloc to fail.
Adjust the ifdef logic so that malloc_base is always configured when CONFIG_SYS_MALLOC_F is set.
--- common/init/board_init.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
common/init/board_init.c +1 -2
@@ -50,8 +50,7 @@ ulong board_init_f_mem(ulong top)#endif arch_setup_gd (gd_ptr); -#if defined(CONFIG_SYS_MALLOC_F ) && \ - (!defined(CONFIG_SPL_BUILD ) || !defined(CONFIG_SYS_SPL_MALLOC_START )) +#if defined(CONFIG_SYS_MALLOC_F ) top -=CONFIG_SYS_MALLOC_F_LEN ; gd->malloc_base = top;#endif
Signature · 1 line
1.9.1
PATCH 2/2 README: Add more clarification about CONFIG_SYS_SPL_MALLOC_START
From: Fabio Estevam <[email protected]>
Make clear that when the user selects CONFIG_SYS_SPL_MALLOC_START the full malloc will be used in SPL and also that this malloc pool can be used prior to configuring SPL.
--- README | 2 ++ 1 file changed, 2 insertions(+)
README +2 -0
@@ -3568,6 +3568,8 @@ FIT uImage format: CONFIG_SYS_SPL_MALLOC_START Starting address of the malloc pool used in SPL. + When this option is set the full malloc is used in SPL. + This malloc pool can be used prior to DRAM initialization. CONFIG_SYS_SPL_MALLOC_SIZE The size of the malloc pool used in SPL.
Signature · 1 line
1.9.1
PATCH 2/2 README: Add more clarification about CONFIG_SYS_SPL_MALLOC_START
Hi Fabio,
Quoted 16 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Make clear that when the user selects
CONFIG_SYS_SPL_MALLOC_STARTthe full malloc will be used in SPL and also that this malloc pool can be used prior to configuring SPL.Signed-off-by Fabio Estevam <[email protected]>--- README | 2 ++ 1 file changed, 2 insertions(+)README +0
-0
README FIT uImage format: · line 3572
Quoted 5 lines
README +2
-0@@ -3568,6 +3568,8 @@ FIT uImage format: CONFIG_SYS_SPL_MALLOC_START Starting address of the malloc pool used in SPL. + When this option is set the full malloc is used in SPL. + This malloc pool can be used prior to DRAM initialization.
This is the 'full' malloc(). So I think you need to mention that this is set up by spl_init(), and before that, the simple malloc() can be used if CONFIG_SYS_MALLOC_F is defined.
There is great potential for confusion so I'd like the docs to be very clear.
Quoted 6 lines
README +0
-1CONFIG_SYS_SPL_MALLOC_SIZE The size of the malloc pool used in SPL. --1.9.1
Regards,
Simon
PATCH 1/2 board_init: Fix the logic to setup malloc_base
In reply to Fabio EstevamHi Fabio,
Quoted 11 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Prior to commit
5ba534d247d418("arm: Switch 32-bit ARM to using genericglobal_datasetup") we used to have assembly code that configured themalloc_baseaddress.After this commit we use the
board_init_f_mem()function in C to setupmalloc_baseaddress.However the ifdef logic has a problem that prevents
malloc_baseto be configured in the SPL case.
Would you mind rewording this a bit to avoid confusion? The point here is that a deliberate choice was made to support only early malloc() or full malloc() in SPL, but not both. The point of your change is to allow both to be used, one after the other, in SPL.
Quoted 29 lines
This issue has been observed in a Congatec board, where we need to retrieve the manufacturing information from the SPI NOR (the SPI API calls malloc) prior to configuring the DRAM. In this case as
malloc_basewas not configured we always see malloc to fail.Adjust the ifdef logic so that
malloc_baseis always configured whenCONFIG_SYS_MALLOC_Fis set.Signed-off-by Fabio Estevam <[email protected]>--- common/init/board_init.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)common/init/board_init.c +1
-3@@ -50,8 +50,7 @@ ulong board_init_f_mem(ulong top)#endif arch_setup_gd (gd_ptr); -#if defined(CONFIG_SYS_MALLOC_F ) && \ - (!defined(CONFIG_SPL_BUILD ) || !defined(CONFIG_SYS_SPL_MALLOC_START )) +#if defined(CONFIG_SYS_MALLOC_F ) top -=CONFIG_SYS_MALLOC_F_LEN ; gd->malloc_base = top;#endif --
Quoted 2 lines
1.9.1
Regards,
Simon