Skip to content

Commit f3fda21

Browse files
committed
lib: alloc: Use aligned allocation for L3_HEAP usage.
L3_HEAP is used in library manager for library storage buffer allocation and in D3 enter/exit flows to allocate IMR context storage buffer. Both buffers should be aligned so use rballoc_align() routine to get correctly aligned buffers. Signed-off-by: Jaroslaw Stelter <Jaroslaw.Stelter@intel.com>
1 parent 3b97c0a commit f3fda21

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

src/library_manager/lib_manager.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -539,16 +539,14 @@ static void __sparse_cache *lib_manager_allocate_store_mem(uint32_t size,
539539
void __sparse_cache *local_add;
540540
#if CONFIG_L3_HEAP
541541
uint32_t caps = SOF_MEM_CAPS_L3 | SOF_MEM_CAPS_DMA;
542-
543-
/* allocate new buffer: cached alias */
544-
local_add = (__sparse_force void __sparse_cache *)rmalloc(SOF_MEM_ZONE_SYS, 0, caps, size);
545542
#else
546-
uint32_t addr_align = PAGE_SZ;
547543
uint32_t caps = SOF_MEM_CAPS_DMA;
544+
#endif
548545

546+
uint32_t addr_align = PAGE_SZ;
549547
/* allocate new buffer: cached alias */
550548
local_add = (__sparse_force void __sparse_cache *)rballoc_align(0, caps, size, addr_align);
551-
#endif
549+
552550
if (!local_add) {
553551
tr_err(&lib_manager_tr, "lib_manager_allocate_store_mem(): alloc failed");
554552
return NULL;

zephyr/lib/cpu.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,16 @@ void cpu_notify_state_entry(enum pm_state state)
9696
storage_buffer_size += LP_SRAM_SIZE;
9797

9898
/* allocate IMR buffer and store it in the global pointer */
99-
global_imr_ram_storage = rmalloc(SOF_MEM_ZONE_SYS_RUNTIME,
100-
0,
101-
SOF_MEM_CAPS_L3,
102-
storage_buffer_size);
99+
global_imr_ram_storage = rballoc_align(0, SOF_MEM_CAPS_L3,
100+
storage_buffer_size,
101+
PLATFORM_DCACHE_ALIGN);
102+
103+
/* If no IMR buffer we can not recover */
104+
if (!global_imr_ram_storage) {
105+
tr_err(&zephyr_tr, "failed to allocate global_imr_ram_storage");
106+
k_panic();
107+
}
108+
103109
#endif /* CONFIG_ADSP_IMR_CONTEXT_SAVE */
104110
}
105111
}

0 commit comments

Comments
 (0)