From a84e3e3f5ad4b6797925c8abeb124ef8ab6de2e8 Mon Sep 17 00:00:00 2001 From: Adrian Bonislawski Date: Mon, 1 Dec 2025 11:22:14 +0100 Subject: [PATCH] zephyr: alloc: fix L3 heap restore after power state change Fix L3 heap restoration logic to ensure MMU mapping is always configured before restoring the heap state from l3_heap_copy. Signed-off-by: Adrian Bonislawski --- zephyr/lib/alloc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/zephyr/lib/alloc.c b/zephyr/lib/alloc.c index c93ffcd80dab..579427f11e33 100644 --- a/zephyr/lib/alloc.c +++ b/zephyr/lib/alloc.c @@ -657,9 +657,7 @@ static int heap_init(void) #endif #if CONFIG_L3_HEAP - if (l3_heap_copy.heap.heap) { - l3_heap = l3_heap_copy; - } else if (ace_imr_used()) { + if (ace_imr_used()) { void *l3_heap_start = UINT_TO_POINTER(get_l3_heap_start()); size_t l3_heap_size = get_l3_heap_size(); #if CONFIG_MMU @@ -668,7 +666,10 @@ static int heap_init(void) arch_mem_map(l3_heap_start, va, l3_heap_size, K_MEM_PERM_RW | K_MEM_CACHE_WB); #endif - sys_heap_init(&l3_heap.heap, l3_heap_start, l3_heap_size); + if (l3_heap_copy.heap.heap) + l3_heap = l3_heap_copy; + else + sys_heap_init(&l3_heap.heap, l3_heap_start, l3_heap_size); } #endif