Skip to content
Merged
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
22 changes: 20 additions & 2 deletions zephyr/lib/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,13 @@ void *rmalloc_align(uint32_t flags, size_t bytes, uint32_t alignment)
ptr = heap_alloc_aligned(heap, alignment, bytes);
}

#if CONFIG_VIRTUAL_HEAP
if (!ptr && heap == &sof_heap && virtual_buffers_heap) {
tr_warn(&zephyr_tr, "system heap allocation of %zu failed, trying VMH", bytes);
ptr = virtual_heap_alloc(virtual_buffers_heap, flags, bytes, alignment);
}
#endif

return ptr;
}
EXPORT_SYMBOL(rmalloc_align);
Expand Down Expand Up @@ -781,10 +788,21 @@ void *z_impl_sof_heap_alloc(struct k_heap *heap, uint32_t flags, size_t bytes,
heap = &sof_heap;
}

void *ptr;

if (flags & SOF_MEM_FLAG_COHERENT)
return heap_alloc_aligned(heap, alignment, bytes);
ptr = heap_alloc_aligned(heap, alignment, bytes);
else
ptr = (__sparse_force void *)heap_alloc_aligned_cached(heap, alignment, bytes);

return (__sparse_force void *)heap_alloc_aligned_cached(heap, alignment, bytes);
#if CONFIG_VIRTUAL_HEAP
if (!ptr && heap == &sof_heap && virtual_buffers_heap) {
tr_warn(&zephyr_tr, "system heap allocation of %zu failed, trying VMH", bytes);
ptr = virtual_heap_alloc(virtual_buffers_heap, flags, bytes, alignment);
}
#endif

return ptr;
}

void z_impl_sof_heap_free(struct k_heap *heap, void *addr)
Expand Down
Loading