Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ manifest:

- name: zephyr
repo-path: zephyr
revision: f3b9d1871104b0d69abf6182ef7d262652b13729
revision: af974c307477f4e0e093abbfca768419f14a865f
remote: zephyrproject

# Import some projects listed in zephyr/west.yml@revision
Expand Down
24 changes: 19 additions & 5 deletions zephyr/lib/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@

#define SHARED_BUFFER_HEAP_MEM_SIZE 0

#if CONFIG_L3_HEAP && CONFIG_MMU
#include <kernel_arch_interface.h>
#endif

#if CONFIG_VIRTUAL_HEAP
#include <sof/lib/regions_mm.h>
#include <zephyr/drivers/mm/mm_drv_intel_adsp_mtl_tlb.h>
Expand Down Expand Up @@ -217,7 +221,9 @@ static inline size_t get_l3_heap_size(void)
* - IMR base address
* - actual IMR heap start
*/
return ROUND_DOWN(IMR_L3_HEAP_SIZE, L3_MEM_PAGE_SIZE);
size_t offset = IMR_L3_HEAP_BASE - L3_MEM_BASE_ADDR;

return ROUND_DOWN(ace_imr_get_mem_size() - offset, L3_MEM_PAGE_SIZE);
}

void l3_heap_save(void)
Expand Down Expand Up @@ -651,11 +657,19 @@ static int heap_init(void)
#endif

#if CONFIG_L3_HEAP
if (l3_heap_copy.heap.heap)
if (l3_heap_copy.heap.heap) {
l3_heap = l3_heap_copy;
else
sys_heap_init(&l3_heap.heap, UINT_TO_POINTER(get_l3_heap_start()),
get_l3_heap_size());
} else 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
void *cached_ptr = sys_cache_cached_ptr_get(l3_heap_start);
uintptr_t va = POINTER_TO_UINT(cached_ptr);

arch_mem_map(l3_heap_start, va, l3_heap_size, K_MEM_PERM_RW | K_MEM_CACHE_WB);
Copy link
Collaborator

Choose a reason for hiding this comment

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

btw, why not sys_mm_drv_map_region()?

Copy link
Member Author

@abonislawski abonislawski Nov 26, 2025

Choose a reason for hiding this comment

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

They are not equivalent, just like the lib/llext manager - we are using both of them. In short, the MM TLB driver is for SRAM memory. I assume in the future we will get some nicer API instead of arch_mem_map.

#endif
sys_heap_init(&l3_heap.heap, l3_heap_start, l3_heap_size);
}
#endif

return 0;
Expand Down
Loading