diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index fdcc5d3c3af9..7edc018dabb4 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -70,8 +70,10 @@ static struct k_heap *module_adapter_dp_heap_new(const struct comp_ipc_config *c void *mod_heap_buf = mod_heap_mem + heap_prefix_size; k_heap_init(mod_heap, mod_heap_buf, heap_size - heap_prefix_size); +#ifdef __ZEPHYR__ mod_heap->heap.init_mem = mod_heap_buf; mod_heap->heap.init_bytes = heap_size - heap_prefix_size; +#endif return mod_heap; } diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index 700aa96944f6..3edaa5fb06ed 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -612,8 +612,10 @@ __cold int ipc_comp_connect(struct ipc *ipc, ipc_pipe_comp_connect *_connect) sink_get_min_free_space(snk), audio_buffer_is_shared(&buffer->audio_buffer), buf_get_id(buffer)); - if (!ring_buffer) - goto free_unlocked; + if (!ring_buffer) { + buffer_free(buffer); + return IPC4_OUT_OF_MEMORY; + } /* data destination module needs to use ring_buffer */ audio_buffer_attach_secondary_buffer(&buffer->audio_buffer, dp_on_source, @@ -698,7 +700,6 @@ __cold int ipc_comp_connect(struct ipc *ipc, ipc_pipe_comp_connect *_connect) pipeline_disconnect(source, buffer, PPL_CONN_DIR_COMP_TO_BUFFER); free: ll_unblock(cross_core_bind, flags); -free_unlocked: buffer_free(buffer); return IPC4_INVALID_RESOURCE_STATE; } diff --git a/zephyr/lib/alloc.c b/zephyr/lib/alloc.c index e0028e098422..e8b997139053 100644 --- a/zephyr/lib/alloc.c +++ b/zephyr/lib/alloc.c @@ -167,7 +167,7 @@ static bool is_heap_pointer(const struct k_heap *heap, void *ptr) POINTER_TO_UINT(sys_cache_cached_ptr_get(heap->heap.init_mem)); uintptr_t heap_end = heap_start + heap->heap.init_bytes; - if (!is_cached(ptr)) + if (!sys_cache_is_ptr_cached(ptr)) ptr = (__sparse_force void *)sys_cache_cached_ptr_get(ptr); return ((POINTER_TO_UINT(ptr) >= heap_start) && @@ -182,7 +182,7 @@ static bool is_shared_buffer_heap_pointer(void *ptr) uintptr_t shd_heap_start = POINTER_TO_UINT(shared_heapmem); uintptr_t shd_heap_end = POINTER_TO_UINT(shared_heapmem + SHARED_BUFFER_HEAP_MEM_SIZE); - if (is_cached(ptr)) + if (sys_cache_is_ptr_cached(ptr)) ptr = sys_cache_uncached_ptr_get((__sparse_force void __sparse_cache *)ptr); return (POINTER_TO_UINT(ptr) >= shd_heap_start) && (POINTER_TO_UINT(ptr) < shd_heap_end); @@ -341,7 +341,7 @@ static bool is_virtual_heap_pointer(void *ptr) POINTER_TO_UINT(sys_cache_cached_ptr_get(&_unused_ram_start_marker)); uintptr_t virtual_heap_end = CONFIG_KERNEL_VM_BASE + CONFIG_KERNEL_VM_SIZE; - if (!is_cached(ptr)) + if (!sys_cache_is_ptr_cached(ptr)) ptr = (__sparse_force void *)sys_cache_cached_ptr_get(ptr); return ((POINTER_TO_UINT(ptr) >= virtual_heap_start) && @@ -463,7 +463,7 @@ static void heap_free(struct k_heap *h, void *mem) #ifdef CONFIG_SOF_ZEPHYR_HEAP_CACHED void *mem_uncached; - if (is_cached(mem)) { + if (sys_cache_is_ptr_cached(mem)) { mem_uncached = sys_cache_uncached_ptr_get((__sparse_force void __sparse_cache *)mem); sys_cache_data_flush_and_invd_range(mem, sys_heap_usable_size(&h->heap, mem_uncached));