Skip to content

Commit

Permalink
lib: alloc: Use aligned allocation for L3_HEAP usage.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jxstelter authored and kv2019i committed Feb 1, 2024
1 parent 58a42e5 commit 8cad5be
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
8 changes: 3 additions & 5 deletions src/library_manager/lib_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,16 +671,14 @@ static void __sparse_cache *lib_manager_allocate_store_mem(uint32_t size,
void __sparse_cache *local_add;
#if CONFIG_L3_HEAP
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
uint32_t addr_align = PAGE_SZ;
uint32_t caps = SOF_MEM_CAPS_DMA;
#endif

uint32_t addr_align = PAGE_SZ;
/* allocate new buffer: cached alias */
local_add = (__sparse_force void __sparse_cache *)rballoc_align(0, caps, size, addr_align);
#endif

if (!local_add) {
tr_err(&lib_manager_tr, "lib_manager_allocate_store_mem(): alloc failed");
return NULL;
Expand Down
14 changes: 10 additions & 4 deletions zephyr/lib/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,16 @@ void cpu_notify_state_entry(enum pm_state state)
storage_buffer_size += LP_SRAM_SIZE;

/* allocate IMR buffer and store it in the global pointer */
global_imr_ram_storage = rmalloc(SOF_MEM_ZONE_SYS_RUNTIME,
0,
SOF_MEM_CAPS_L3,
storage_buffer_size);
global_imr_ram_storage = rballoc_align(0, SOF_MEM_CAPS_L3,
storage_buffer_size,
PLATFORM_DCACHE_ALIGN);

/* 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 */
}
}
Expand Down

0 comments on commit 8cad5be

Please sign in to comment.