Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zephyr: lib: alloc: Use cached memory for L3 Heap #8632

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/library_manager/lib_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,16 +539,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();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this means: the DSP is being powered down and we try to allocate an IMR buffer to safe state, and if we fail, we panic. Would it be possible to just abort saving state and go for a clean power off? Also rather theoretical, but would probably be better not to bother the host with a DSP panic but just to make this a clean shut down? @ujfalusi Can be an incremental PR too

}

#endif /* CONFIG_ADSP_IMR_CONTEXT_SAVE */
}
}
Expand Down
Loading