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>
This commit is contained in:
Jaroslaw Stelter 2024-01-31 11:24:55 +01:00 committed by Kai Vehmanen
parent 58a42e5fdb
commit 8cad5bea57
2 changed files with 13 additions and 9 deletions

View File

@ -671,16 +671,14 @@ static void __sparse_cache *lib_manager_allocate_store_mem(uint32_t size,
void __sparse_cache *local_add; void __sparse_cache *local_add;
#if CONFIG_L3_HEAP #if CONFIG_L3_HEAP
uint32_t caps = SOF_MEM_CAPS_L3 | SOF_MEM_CAPS_DMA; uint32_t caps = SOF_MEM_CAPS_L3 | SOF_MEM_CAPS_DMA;
/* allocate new buffer: cached alias */
local_add = (__sparse_force void __sparse_cache *)rmalloc(SOF_MEM_ZONE_SYS, 0, caps, size);
#else #else
uint32_t addr_align = PAGE_SZ;
uint32_t caps = SOF_MEM_CAPS_DMA; uint32_t caps = SOF_MEM_CAPS_DMA;
#endif
uint32_t addr_align = PAGE_SZ;
/* allocate new buffer: cached alias */ /* allocate new buffer: cached alias */
local_add = (__sparse_force void __sparse_cache *)rballoc_align(0, caps, size, addr_align); local_add = (__sparse_force void __sparse_cache *)rballoc_align(0, caps, size, addr_align);
#endif
if (!local_add) { if (!local_add) {
tr_err(&lib_manager_tr, "lib_manager_allocate_store_mem(): alloc failed"); tr_err(&lib_manager_tr, "lib_manager_allocate_store_mem(): alloc failed");
return NULL; return NULL;

View File

@ -96,10 +96,16 @@ void cpu_notify_state_entry(enum pm_state state)
storage_buffer_size += LP_SRAM_SIZE; storage_buffer_size += LP_SRAM_SIZE;
/* allocate IMR buffer and store it in the global pointer */ /* allocate IMR buffer and store it in the global pointer */
global_imr_ram_storage = rmalloc(SOF_MEM_ZONE_SYS_RUNTIME, global_imr_ram_storage = rballoc_align(0, SOF_MEM_CAPS_L3,
0, storage_buffer_size,
SOF_MEM_CAPS_L3, PLATFORM_DCACHE_ALIGN);
storage_buffer_size);
/* If no IMR buffer we can not recover */
if (!global_imr_ram_storage) {
tr_err(&zephyr_tr, "failed to allocate global_imr_ram_storage");
k_panic();
}
#endif /* CONFIG_ADSP_IMR_CONTEXT_SAVE */ #endif /* CONFIG_ADSP_IMR_CONTEXT_SAVE */
} }
} }