zephyr: trigger system panic if MEM_ZONE_SYS alloc fails

As per documentation in include/sof/lib/alloc.h, rmalloc from
MEM_ZONE_SYS will always succeed. In the unlikely case the alloc
fails, trigger a system panic in rmalloc().

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
This commit is contained in:
Kai Vehmanen 2021-10-18 15:17:41 +03:00 committed by Liam Girdwood
parent 15885b76e1
commit de408a2349
1 changed files with 15 additions and 7 deletions

View File

@ -188,14 +188,22 @@ static inline bool zone_is_cached(enum mem_zone zone)
void *rmalloc(enum mem_zone zone, uint32_t flags, uint32_t caps, size_t bytes)
{
if (zone_is_cached(zone))
return heap_alloc_aligned_cached(&sof_heap, 0, bytes);
void *ptr;
/*
* XTOS alloc implementation has used dcache alignment,
* so SOF application code is expecting this behaviour.
*/
return heap_alloc_aligned(&sof_heap, PLATFORM_DCACHE_ALIGN, bytes);
if (zone_is_cached(zone)) {
ptr = heap_alloc_aligned_cached(&sof_heap, 0, bytes);
} else {
/*
* XTOS alloc implementation has used dcache alignment,
* so SOF application code is expecting this behaviour.
*/
ptr = heap_alloc_aligned(&sof_heap, PLATFORM_DCACHE_ALIGN, bytes);
}
if (!ptr && zone == SOF_MEM_ZONE_SYS)
k_panic();
return ptr;
}
/* Use SOF_MEM_ZONE_BUFFER at the moment */