diff options
| author | Marek Vasut <[email protected]> | 2026-07-21 21:48:02 +0200 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-08-10 14:48:11 -0600 |
| commit | 8da656ae6a9778ffe111c4a3b6a7795b2e7ee6d1 (patch) | |
| tree | 1b0c31b5cbd9b0ec846c08db8061902f0bd324c3 | |
| parent | 93926f630e486d3cb2f2278c2785b2e2e9a3d705 (diff) | |
board_f: Call initf_malloc() before fdtdec_setup()
In case MULTI_DTB_FIT_GZIP is enabled, fdtdec_setup() does uncompress
the compressed DTs in uncompress_blob() using gunzip(), which invokes
malloc() internally. The early simple malloc is initialized in board_f
initf_malloc() call, which sets up the early simple malloc limit and
offset pointer in global data. Currently, the initf_malloc() is called
after fdtdec_setup(), which leads to malloc failure in fdtdec_setup()
during the gzip decompression, because the early simple malloc is not
initialized yet.
Call initf_malloc() before fdtdec_setup() to assure fdtdec_setup() can
use malloc() during gzip decompression of the DTs.
The impact of this change on boot time is negligible, because the
initf_malloc() only assigns two fields in global data.
Signed-off-by: Marek Vasut <[email protected]>
Fixes: 95f4bbd581cf ("lib: fdt: Allow LZO and GZIP DT compression in U-Boot")
Reviewed-by: Simon Glass <[email protected]>
[trini: Update test/py/tests/test_trace.py]
Signed-off-by: Tom Rini <[email protected]>
| -rw-r--r-- | common/board_f.c | 2 | ||||
| -rw-r--r-- | test/py/tests/test_trace.py | 5 |
2 files changed, 2 insertions, 5 deletions
diff --git a/common/board_f.c b/common/board_f.c index 85b888d4bb8..9efcd9499a9 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -921,13 +921,13 @@ static void initcall_run_f(void) * For simplicity it should remain an ordered list of function calls. */ INITCALL(setup_mon_len); + INITCALL(initf_malloc); #if CONFIG_IS_ENABLED(OF_CONTROL) INITCALL(fdtdec_setup); #endif #if CONFIG_IS_ENABLED(TRACE_EARLY) INITCALL(trace_early_init); #endif - INITCALL(initf_malloc); INITCALL(initf_upl); INITCALL(log_init); INITCALL(initf_bootstage); /* uses its own timer, so does not need DM */ diff --git a/test/py/tests/test_trace.py b/test/py/tests/test_trace.py index 36a3c4e8fe9..a68851facc4 100644 --- a/test/py/tests/test_trace.py +++ b/test/py/tests/test_trace.py @@ -145,8 +145,6 @@ def check_function(ubman, fname, proftool, map_fname, trace_dat): out = utils.run_and_log(ubman, ['sh', '-c', cmd]) # Format: - # u-boot-1 0..... 60.805596: function: initf_malloc - # u-boot-1 0..... 60.805597: function: initf_malloc # u-boot-1 0..... 60.805601: function: initf_bootstage # u-boot-1 0..... 60.805607: function: initf_bootstage @@ -162,7 +160,7 @@ def check_function(ubman, fname, proftool, map_fname, trace_dat): # Check for some expected functions if ubman.config.buildconfig.get('config_trace_early'): - assert 'initf_malloc' in vals.keys() + assert 'initf_upl' in vals.keys() assert 'initr_watchdog' in vals.keys() assert 'initr_dm' in vals.keys() @@ -193,7 +191,6 @@ def check_funcgraph(ubman, fname, proftool, map_fname, trace_dat): out = utils.run_and_log(ubman, ['sh', '-c', cmd]) # First look for this: - # u-boot-1 0..... 282.101360: funcgraph_entry: 0.004 us | initf_malloc(); # ... # u-boot-1 0..... 282.101369: funcgraph_entry: | initf_bootstage() { # u-boot-1 0..... 282.101369: funcgraph_entry: | bootstage_init() { |
