spl: Add spl_early_init()
PATCH v4 1/2 spl: Add spl_early_init()
From: Eddie Cai <[email protected]>
At present malloc_base/_limit/_ptr are not initialised in spl_init() when we call spl_init() in board_init_f(). This is due to a recent change aimed at avoiding overwriting the malloc area set up on some boards by spl_relocate_stack_gd().
However if CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN is not defined, we now skip setting up the memory area in spl_init() which is obviously wrong.
To fix this, add a new function spl_early_init() which can be called in board_init_f().
Rewrote spl_{,early_}init() to avoid duplicate code:
Rewrite/expand commit message:
---
Changes in v4: None
Changes in v3: None
Changes in v2:
- Rewrote spl_{,early_}init() to avoid duplicate code
- Rewrite commit message
common/spl/spl.c | 46 +++++++++++++++++++++++++++++---------- include/asm-generic/global_data.h | 1 + include/spl.h | 24 +++++++++++++++++--- 3 files changed, 57 insertions(+), 14 deletions(-)
common/spl/spl.c +35 -11
@@ -170,22 +170,20 @@ __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)image_entry (); } -int spl_init (void ) +static int spl_common_init (bool setup_malloc) {int ret; -debug ("spl_init()\n" ); -/* -* with CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN we set malloc_base and -* malloc_limit in spl_relocate_stack_gd -*/ -#if defined(CONFIG_SYS_MALLOC_F_LEN ) && \ - !defined(CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN ) +debug ("spl_early_init()\n" ); + +#if defined(CONFIG_SYS_MALLOC_F_LEN ) +if (setup_malloc) {#ifdef CONFIG_MALLOC_F_ADDR - gd->malloc_base =CONFIG_MALLOC_F_ADDR ; + gd->malloc_base =CONFIG_MALLOC_F_ADDR ;#endif - gd->malloc_limit =CONFIG_SYS_MALLOC_F_LEN ; - gd->malloc_ptr =0 ; + gd->malloc_limit =CONFIG_SYS_MALLOC_F_LEN ; + gd->malloc_ptr =0 ; + }#endif if (CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA )) { ret =fdtdec_setup ();
@@ -202,6 +200,32 @@ int spl_init(void)return ret; } } + +return 0 ; +} + +int spl_early_init (void ) +{ +int ret; + + ret =spl_common_init (true); +if (ret) +return ret; + gd->flags |=GD_FLG_SPL_EARLY_INIT ; + +return 0 ; +} + +int spl_init (void ) +{ +int ret; + +if (!(gd->flags &GD_FLG_SPL_EARLY_INIT )) { + ret =spl_common_init ( + !IS_ENABLED (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN )); +if (ret) +return ret; + } gd->flags |=GD_FLG_SPL_INIT ;return 0 ;
include/asm-generic/global_data.h +1 -0
@@ -127,5 +127,6 @@ typedef struct global_data {#define GD_FLG_SKIP_RELOC 0x00800/* Don't relocate */ #define GD_FLG_RECORD 0x01000/* Record console */ #define GD_FLG_ENV_DEFAULT 0x02000/* Default variable flag */ +#define GD_FLG_SPL_EARLY_INIT 0x04000/* Early SPL init is done */ #endif /* __ASM_GENERIC_GBL_DATA_H */
include/spl.h +21 -3
@@ -213,11 +213,29 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image, struct blk_desc *block_dev, int partition);/** -* spl_init() - Set up device tree and driver model in SPL if enabled +* spl_early_init() - Set up device tree and driver model in SPL if enabled * * Call this function in board_init_f() if you want to use device tree and -* driver model early, before board_init_r() is called. This function will -* be called from board_init_r() if not called earlier. +* driver model early, before board_init_r() is called. +* +* If this is not called, then driver model will be inactive in SPL's +* board_init_f(), and no device tree will be available. +*/ +int spl_early_init (void ); + +/** +* spl_init() - Set up device tree and driver model in SPL if enabled +* +* You can optionally call spl_early_init(), then optionally call spl_init(). +* This function will be called from board_init_r() if not called earlier. +* +* Both spl_early_init() and spl_init() perform a similar function except that +* the latter will not set up the malloc() area if +* CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN is enabled, since it is assumed to +* already be done by a calll to spl_relocate_stack_gd() before board_init_r() +* is reached. +* +* This function will be called from board_init_r() if not called earlier. * * If this is not called, then driver model will be inactive in SPL's * board_init_f(), and no device tree will be available.
Signature · 1 line
2.12.0.367.g23dc2f6d3c-goog
PATCH v4 2/2 rockchip: rk3288: use spl_early_init() instead of spl_init()
From: Eddie Cai <[email protected]>
Use spl_early_init() to make sure that early malloc() is initialised. This fixes booting on firefly-rk3288, for example.
---
Changes in v4:
- Change debug() message to match new function name
Changes in v3:
- Rewrite both commit messages
Changes in v2:
- Add v2 to the series since this is a new version
arch/arm/mach-rockchip/rk3288-board-spl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/rk3288-board-spl.c +2 -2
@@ -185,9 +185,9 @@ void board_init_f(ulong dummy)debug_uart_init ();#endif - ret =spl_init (); + ret =spl_early_init ();if (ret) { -debug ("spl_init() failed: %d\n" , ret); +debug ("spl_early_init() failed: %d\n" , ret);hang (); }
Signature · 1 line
2.12.0.367.g23dc2f6d3c-goog
PATCH v4 2/2 rockchip: rk3288: use spl_early_init() instead of spl_init()
Hi Eddie, Simon,
Could you help to correct rk3188, rk3399 spl at the same time?
Thanks,
- Kever
Quoted 37 lines · Simon Glass
From: Eddie Cai <[email protected]>
Use
spl_early_init()to make sure that earlymalloc()is initialised. This fixes booting on firefly-rk3288, for example.Signed-off-by Eddie Cai <[email protected]>Signed-off-by Simon Glass <[email protected]>---
Changes in v4:
- Changedebug()message to match new function nameChanges in v3:
- Rewrite both commit messagesChanges in v2:
- Add v2 to the series since this is a new versionarch/arm/mach-rockchip/rk3288-board-spl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm/mach-rockchip/rk3288-board-spl.c +2
-2@@ -185,9 +185,9 @@ void board_init_f(ulong dummy)debug_uart_init ();#endif - ret =spl_init (); + ret =spl_early_init ();if (ret) { -debug ("spl_init() failed: %d\n" , ret); +debug ("spl_early_init() failed: %d\n" , ret);hang (); }
PATCH v4 2/2 rockchip: rk3288: use spl_early_init() instead of spl_init()
Hi Kever,
Quoted 3 lines · Kever Yang
Hi Eddie, Simon,
Could you help to correct rk3188, rk3399 spl at the same time?
I don't have boards to test with for these, sorry.
Regards,
Simon
PATCH v4 2/2 rockchip: rk3288: use spl_early_init() instead of spl_init()
In reply to Simon Glass2017-03-15 22:43 GMT+08:00 Simon Glass <[email protected]>:
Quoted 8 lines
From: Eddie Cai <[email protected]>
Use
spl_early_init()to make sure that earlymalloc()is initialised. This fixes booting on firefly-rk3288, for example.Signed-off-by Eddie Cai <[email protected]>Signed-off-by Simon Glass <[email protected]>
Quoted 35 lines
---
Changes in v4:
- Changedebug()message to match new function nameChanges in v3:
- Rewrite both commit messagesChanges in v2:
- Add v2 to the series since this is a new versionarch/arm/mach-rockchip/rk3288-board-spl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/arm/mach-rockchip/rk3288-board-spl.c +2
-3@@ -185,9 +185,9 @@ void board_init_f(ulong dummy)debug_uart_init ();#endif - ret =spl_init (); + ret =spl_early_init ();if (ret) { -debug ("spl_init() failed: %d\n" , ret); +debug ("spl_early_init() failed: %d\n" , ret);hang (); } --2.12.0.367.g23dc2f6d3c-goog
PATCH v4 2/2 rockchip: rk3288: use spl_early_init() instead of spl_init()
Quoted 6 lines · Eddie Cai
2017-03-15 22:43 GMT+08:00 Simon Glass <[email protected]>:
Quoted 3 lines
From: Eddie Cai <[email protected]>
Quoted 7 lines
Quoted 5 lines
Use
spl_early_init()to make sure that earlymalloc()is initialised. This fixes booting on firefly-rk3288, for example.Signed-off-by Eddie Cai <[email protected]>Signed-off-by Simon Glass <[email protected]>Reviewed-by Eddie Cai <[email protected]>
Applied to u-boot-rockchip.
PATCH v4 1/2 spl: Add spl_early_init()
In reply to Simon Glass2017-03-15 22:43 GMT+08:00 Simon Glass <[email protected]>:
Quoted 10 lines
From: Eddie Cai <[email protected]>
At present malloc_base/_limit/_ptr are not initialised in
spl_init()when we callspl_init()inboard_init_f(). This is due to a recent change aimed at avoiding overwriting the malloc area set up on some boards byspl_relocate_stack_gd().However if
CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LENis not defined, we now skip setting up the memory area inspl_init()which is obviously wrong.
Quoted 9 lines
To fix this, add a new function
spl_early_init()which can be called inboard_init_f().Fixes b3d2861e (spl: Remove overwrite of relocated malloc limit)Signed-off-by Eddie Cai <[email protected]>Rewrote spl_{,early_}init() to avoid duplicate code:
Rewrite/expand commit message:Signed-off-by Simon Glass <[email protected]>
Quoted 149 lines
---
Changes in v4: None
Changes in v3: None
Changes in v2:
- Rewrote spl_{,early_}init() to avoid duplicate code
- Rewrite commit messagecommon/spl/spl.c | 46 +++++++++++++++++++++++++++++- --------- include/asm-generic/global_data.h | 1 + include/spl.h | 24 +++++++++++++++++--- 3 files changed, 57 insertions(+), 14 deletions(-)common/spl/spl.c +9
-11@@ -170,22 +170,20 @@ __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)image_entry (); } -int spl_init (void ) +static int spl_common_init (bool setup_malloc) {int ret; -debug ("spl_init()\n" ); -/* -* with CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN we set malloc_base and -* malloc_limit in spl_relocate_stack_gd -*/ -#if defined(CONFIG_SYS_MALLOC_F_LEN ) && \ - !defined(CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN ) +debug ("spl_early_init()\n" ); + +#if defined(CONFIG_SYS_MALLOC_F_LEN ) +if (setup_malloc) {#ifdef CONFIG_MALLOC_F_ADDR - gd->malloc_base =CONFIG_MALLOC_F_ADDR ; + gd->malloc_base =CONFIG_MALLOC_F_ADDR ;#endif - gd->malloc_limit =CONFIG_SYS_MALLOC_F_LEN ; - gd->malloc_ptr =0 ; + gd->malloc_limit =CONFIG_SYS_MALLOC_F_LEN ; + gd->malloc_ptr =0 ; + }#endif if (CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA )){ ret = fdtdec_setup();common/spl/spl.c +26
-0@@ -202,6 +200,32 @@ int spl_init(void)return ret; } } + +return 0 ; +} + +int spl_early_init (void ) +{ +int ret; + + ret =spl_common_init (true); +if (ret) +return ret; + gd->flags |=GD_FLG_SPL_EARLY_INIT ; + +return 0 ; +} + +int spl_init (void ) +{ +int ret; + +if (!(gd->flags &GD_FLG_SPL_EARLY_INIT )) { + ret =spl_common_init ( + !IS_ENABLED(CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN )); +if (ret) +return ret; + } gd->flags |=GD_FLG_SPL_INIT ;return 0;include/asm-generic/global_data.h +1
-0@@ -127,5 +127,6 @@ typedef struct global_data {#define GD_FLG_SKIP_RELOC 0x00800/* Don't relocate */ #define GD_FLG_RECORD 0x01000/* Record console */ #define GD_FLG_ENV_DEFAULT 0x02000/* Default variable flag */ +#define GD_FLG_SPL_EARLY_INIT 0x04000/* Early SPL init is done */
#endif /*
__ASM_GENERIC_GBL_DATA_H*/include/spl.h +1
-1@@ -213,11 +213,29 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image, struct blk_desc *block_dev, int partition);/** -* spl_init() - Set up device tree and driver model in SPL if enabled +* spl_early_init() - Set up device tree and driver model in SPL if enabled
*
* Call this function inboard_init_f()if you want to use device tree and
- * driver model early, beforeboard_init_r()is called. This function will
- * be called fromboard_init_r()if not called earlier.
+ * driver model early, beforeboard_init_r()is called.
+ *
+ * If this is not called, then driver model will be inactive in SPL's
+ *board_init_f(), and no device tree will be available.
+ */include/spl.h +6
-0+int spl_early_init (void ); + +/** +* spl_init() - Set up device tree and driver model in SPL if enabled +* +* You can optionally call spl_early_init(), then optionally call
spl_init().
+ * This function will be called fromboard_init_r()if not called earlier.
+ *
+ * Bothspl_early_init()andspl_init()perform a similar function except that
+ * the latter will not set up themalloc()area if
+ *CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LENis enabled, since it is assumed to
+ * already be done by a calll tospl_relocate_stack_gd()beforeboard_init_r()
+ * is reached.
+ *
+ * This function will be called fromboard_init_r()if not called earlier. *
* If this is not called, then driver model will be inactive in SPL's
*board_init_f(), and no device tree will be available.
--
2.12.0.367.g23dc2f6d3c-goog
PATCH v4 1/2 spl: Add spl_early_init()
Quoted 17 lines · Eddie Cai
2017-03-15 22:43 GMT+08:00 Simon Glass <[email protected]>:
Quoted 14 lines
From: Eddie Cai <[email protected]>
At present malloc_base/_limit/_ptr are not initialised in
spl_init()when we callspl_init()inboard_init_f(). This is due to a recent change aimed at avoiding overwriting the malloc area set up on some boards byspl_relocate_stack_gd().However if
CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LENis not defined, we now skip setting up the memory area inspl_init()which is obviously wrong.To fix this, add a new function
spl_early_init()which can be called inboard_init_f().
Quoted 7 lines
Quoted 5 lines
Fixes b3d2861e (spl: Remove overwrite of relocated malloc limit)Signed-off-by Eddie Cai <[email protected]>Rewrote spl_{,early_}init() to avoid duplicate code:
Rewrite/expand commit message:Signed-off-by Simon Glass <[email protected]>Reviewed-by Eddie Cai <[email protected]>
Applied to u-boot-rockchip.
PATCH v4 1/2 spl: Add spl_early_init()
In reply to Simon GlassQuoted 10 lines · Simon Glass
From: Eddie Cai <[email protected]>
At present malloc_base/_limit/_ptr are not initialised in
spl_init()when we callspl_init()inboard_init_f(). This is due to a recent change aimed at avoiding overwriting the malloc area set up on some boards byspl_relocate_stack_gd().However if
CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LENis not defined, we now skip setting up the memory area inspl_init()which is obviously wrong.
Quoted 8 lines
To fix this, add a new function
spl_early_init()which can be called inboard_init_f().Fixes b3d2861e (spl: Remove overwrite of relocated malloc limit)Signed-off-by Eddie Cai <[email protected]>Rewrote spl_{,early_}init() to avoid duplicate code:
Rewrite/expand commit message:Signed-off-by Simon Glass <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170317/75e13861/attachment.sig>
PATCH v4 1/2 spl: Add spl_early_init()
In reply to Simon GlassHi Simon,
Quoted 84 lines · Simon Glass
From: Eddie Cai <[email protected]>
At present malloc_base/_limit/_ptr are not initialised in
spl_init()when we callspl_init()inboard_init_f(). This is due to a recent change aimed at avoiding overwriting the malloc area set up on some boards byspl_relocate_stack_gd().However if
CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LENis not defined, we now skip setting up the memory area inspl_init()which is obviously wrong.To fix this, add a new function
spl_early_init()which can be called inboard_init_f().Fixes b3d2861e (spl: Remove overwrite of relocated malloc limit)Signed-off-by Eddie Cai <[email protected]>Rewrote spl_{,early_}init() to avoid duplicate code:
Rewrite/expand commit message:Signed-off-by Simon Glass <[email protected]>---
Changes in v4: None
Changes in v3: None
Changes in v2:
- Rewrote spl_{,early_}init() to avoid duplicate code
- Rewrite commit messagecommon/spl/spl.c | 46 +++++++++++++++++++++++++++++---------- include/asm-generic/global_data.h | 1 + include/spl.h | 24 +++++++++++++++++--- 3 files changed, 57 insertions(+), 14 deletions(-)common/spl/spl.c +22
-11@@ -170,22 +170,20 @@ __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)image_entry (); } -int spl_init (void ) +static int spl_common_init (bool setup_malloc) {int ret; -debug ("spl_init()\n" ); -/* -* with CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN we set malloc_base and -* malloc_limit in spl_relocate_stack_gd -*/ -#if defined(CONFIG_SYS_MALLOC_F_LEN ) && \ - !defined(CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN ) +debug ("spl_early_init()\n" ); + +#if defined(CONFIG_SYS_MALLOC_F_LEN ) +if (setup_malloc) {#ifdef CONFIG_MALLOC_F_ADDR - gd->malloc_base =CONFIG_MALLOC_F_ADDR ; + gd->malloc_base =CONFIG_MALLOC_F_ADDR ;#endif - gd->malloc_limit =CONFIG_SYS_MALLOC_F_LEN ; - gd->malloc_ptr =0 ; + gd->malloc_limit =CONFIG_SYS_MALLOC_F_LEN ; + gd->malloc_ptr =0 ; + }#endif if (CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA )) { ret =fdtdec_setup ();@@ -202,6 +200,32 @@ int spl_init(void)return ret; } } + +return 0 ; +} + +int spl_early_init (void ) +{ +int ret; + + ret =spl_common_init (true); +if (ret) +return ret; + gd->flags |=GD_FLG_SPL_EARLY_INIT ; +
common/spl/spl.c int spl_init(void) · line 225
Quoted 10 lines
common/spl/spl.c +10
-0+return 0 ; +} + +int spl_init (void ) +{ +int ret; + +if (!(gd->flags &GD_FLG_SPL_EARLY_INIT )) { + ret =spl_common_init ( + !IS_ENABLED (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN ));
IS_ENABLED(CONFIG defined as hex) is always false. So this will always return true and overriding the malloc_limit, which is causing boot failures on DRA7xx based boards.:wq
Thanks and regards,
Lokesh
PATCH v4 1/2 spl: Add spl_early_init()
Quoted 93 lines · Lokesh Vutla
Hi Simon,
Quoted 90 lines · Simon Glass
From: Eddie Cai <[email protected]>
At present malloc_base/_limit/_ptr are not initialised in
spl_init()when we callspl_init()inboard_init_f(). This is due to a recent change aimed at avoiding overwriting the malloc area set up on some boards byspl_relocate_stack_gd().However if
CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LENis not defined, we now skip setting up the memory area inspl_init()which is obviously wrong.To fix this, add a new function
spl_early_init()which can be called inboard_init_f().Fixes b3d2861e (spl: Remove overwrite of relocated malloc limit)Signed-off-by Eddie Cai <[email protected]>Rewrote spl_{,early_}init() to avoid duplicate code:
Rewrite/expand commit message:Signed-off-by Simon Glass <[email protected]>---
Changes in v4: None
Changes in v3: None
Changes in v2:
- Rewrote spl_{,early_}init() to avoid duplicate code
- Rewrite commit messagecommon/spl/spl.c | 46 +++++++++++++++++++++++++++++---------- include/asm-generic/global_data.h | 1 + include/spl.h | 24 +++++++++++++++++--- 3 files changed, 57 insertions(+), 14 deletions(-)common/spl/spl.c +28
-11@@ -170,22 +170,20 @@ __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)image_entry (); } -int spl_init (void ) +static int spl_common_init (bool setup_malloc) {int ret; -debug ("spl_init()\n" ); -/* -* with CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN we set malloc_base and -* malloc_limit in spl_relocate_stack_gd -*/ -#if defined(CONFIG_SYS_MALLOC_F_LEN ) && \ - !defined(CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN ) +debug ("spl_early_init()\n" ); + +#if defined(CONFIG_SYS_MALLOC_F_LEN ) +if (setup_malloc) {#ifdef CONFIG_MALLOC_F_ADDR - gd->malloc_base =CONFIG_MALLOC_F_ADDR ; + gd->malloc_base =CONFIG_MALLOC_F_ADDR ;#endif - gd->malloc_limit =CONFIG_SYS_MALLOC_F_LEN ; - gd->malloc_ptr =0 ; + gd->malloc_limit =CONFIG_SYS_MALLOC_F_LEN ; + gd->malloc_ptr =0 ; + }#endif if (CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA )) { ret =fdtdec_setup ();@@ -202,6 +200,32 @@ int spl_init(void)return ret; } } + +return 0 ; +} + +int spl_early_init (void ) +{ +int ret; + + ret =spl_common_init (true); +if (ret) +return ret; + gd->flags |=GD_FLG_SPL_EARLY_INIT ; + +return 0 ; +} + +int spl_init (void ) +{ +int ret;
Quoted 8 lines
common/spl/spl.c int spl_init(void) · line 225
Quoted 4 lines
common/spl/spl.c +4
-0+ +if (!(gd->flags &GD_FLG_SPL_EARLY_INIT )) { + ret =spl_common_init ( + !IS_ENABLED (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN ));
IS_ENABLED(CONFIG defined as hex)is always false. So this will always return true and overriding themalloc_limit, which is causing boot failures on DRA7xx based boards.:wq
Maybe we should use a bool that we set based on (SPL_STACK_R && SPL_SYS_MALLOC_SIMPLE) being true or not as that's the gating condition for CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN being set.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170320/39e51107/attachment.sig>
PATCH v4 1/2 spl: Add spl_early_init()
Hi Tom,
Quoted 103 lines · Tom Rini
Quoted 93 lines · Lokesh Vutla
Hi Simon,
Quoted 90 lines · Simon Glass
From: Eddie Cai <[email protected]>
At present malloc_base/_limit/_ptr are not initialised in
spl_init()when we callspl_init()inboard_init_f(). This is due to a recent change aimed at avoiding overwriting the malloc area set up on some boards byspl_relocate_stack_gd().However if
CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LENis not defined, we now skip setting up the memory area inspl_init()which is obviously wrong.To fix this, add a new function
spl_early_init()which can be called inboard_init_f().Fixes b3d2861e (spl: Remove overwrite of relocated malloc limit)Signed-off-by Eddie Cai <[email protected]>Rewrote spl_{,early_}init() to avoid duplicate code:
Rewrite/expand commit message:Signed-off-by Simon Glass <[email protected]>---
Changes in v4: None
Changes in v3: None
Changes in v2:
- Rewrote spl_{,early_}init() to avoid duplicate code
- Rewrite commit messagecommon/spl/spl.c | 46 +++++++++++++++++++++++++++++---------- include/asm-generic/global_data.h | 1 + include/spl.h | 24 +++++++++++++++++--- 3 files changed, 57 insertions(+), 14 deletions(-)common/spl/spl.c +28
-11@@ -170,22 +170,20 @@ __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)image_entry (); } -int spl_init (void ) +static int spl_common_init (bool setup_malloc) {int ret; -debug ("spl_init()\n" ); -/* -* with CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN we set malloc_base and -* malloc_limit in spl_relocate_stack_gd -*/ -#if defined(CONFIG_SYS_MALLOC_F_LEN ) && \ - !defined(CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN ) +debug ("spl_early_init()\n" ); + +#if defined(CONFIG_SYS_MALLOC_F_LEN ) +if (setup_malloc) {#ifdef CONFIG_MALLOC_F_ADDR - gd->malloc_base =CONFIG_MALLOC_F_ADDR ; + gd->malloc_base =CONFIG_MALLOC_F_ADDR ;#endif - gd->malloc_limit =CONFIG_SYS_MALLOC_F_LEN ; - gd->malloc_ptr =0 ; + gd->malloc_limit =CONFIG_SYS_MALLOC_F_LEN ; + gd->malloc_ptr =0 ; + }#endif if (CONFIG_IS_ENABLED (OF_CONTROL ) && !CONFIG_IS_ENABLED (OF_PLATDATA )) { ret =fdtdec_setup ();@@ -202,6 +200,32 @@ int spl_init(void)return ret; } } + +return 0 ; +} + +int spl_early_init (void ) +{ +int ret; + + ret =spl_common_init (true); +if (ret) +return ret; + gd->flags |=GD_FLG_SPL_EARLY_INIT ; + +return 0 ; +} + +int spl_init (void ) +{ +int ret;Quoted 8 lines
common/spl/spl.c int spl_init(void) · line 225
Quoted 4 lines
common/spl/spl.c +4
-0+ +if (!(gd->flags &GD_FLG_SPL_EARLY_INIT )) { + ret =spl_common_init ( + !IS_ENABLED (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN ));
IS_ENABLED(CONFIG defined as hex)is always false. So this will always return true and overriding themalloc_limit, which is causing boot failures on DRA7xx based boards.:wq
Quoted 3 lines
Maybe we should use a bool that we set based on (
SPL_STACK_R&&SPL_SYS_MALLOC_SIMPLE) being true or not as that's the gating condition forCONFIG_SPL_STACK_R_MALLOC_SIMPLE_LENbeing set.
And it looks like you fixed this with:
cf334edfbb spl: Correct call to spl_common_init() withSPL_STACK_R_MALLOC_SIMPLE_LEN
Thanks!
- Simon