diff mbox series

[v2,1/4] common: Only mark malloc initialized after mem_malloc_init

Message ID 20230808225320.310926-2-sean.anderson@seco.com
State Changes Requested
Delegated to: Tom Rini
Headers show
Series [v2,1/4] common: Only mark malloc initialized after mem_malloc_init | expand

Commit Message

Sean Anderson Aug. 8, 2023, 10:53 p.m. UTC
Instead of marking malloc as initialized as soon as relocation is done,
defer it until after we call mem_malloc_init. This ensures that malloc
initialization is done before we switch away from simple_malloc, and
matches the SPL behavior.

Fixes: c9356be3074 ("dm: Split the simple malloc() implementation into its own file")
Signed-off-by: Sean Anderson <sean.anderson@seco.com>
---

Changes in v2:
- New

 common/board_r.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Simon Glass Aug. 9, 2023, 2:03 a.m. UTC | #1
On Tue, 8 Aug 2023 at 16:53, Sean Anderson <sean.anderson@seco.com> wrote:
>
> Instead of marking malloc as initialized as soon as relocation is done,
> defer it until after we call mem_malloc_init. This ensures that malloc
> initialization is done before we switch away from simple_malloc, and
> matches the SPL behavior.
>
> Fixes: c9356be3074 ("dm: Split the simple malloc() implementation into its own file")
> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
> ---
>
> Changes in v2:
> - New
>
>  common/board_r.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/common/board_r.c b/common/board_r.c
index d798c00a80a..58a5986aa54 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -98,7 +98,7 @@  static int initr_trace(void)
 static int initr_reloc(void)
 {
 	/* tell others: relocation done */
-	gd->flags |= GD_FLG_RELOC | GD_FLG_FULL_MALLOC_INIT;
+	gd->flags |= GD_FLG_RELOC;
 
 	return 0;
 }
@@ -210,6 +210,7 @@  static int initr_malloc(void)
 	malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN;
 	mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN),
 			TOTAL_MALLOC_LEN);
+	gd->flags |= GD_FLG_FULL_MALLOC_INIT;
 	return 0;
 }