diff --git a/src/audio/buffer.c b/src/audio/buffer.c index c9c86cf8dc61..32ade5781c0b 100644 --- a/src/audio/buffer.c +++ b/src/audio/buffer.c @@ -27,7 +27,8 @@ DECLARE_SOF_RT_UUID("buffer", buffer_uuid, 0x42544c92, 0x8e92, 0x4e41, 0xb6, 0x79, 0x34, 0x51, 0x9f, 0x1c, 0x1d, 0x28); DECLARE_TR_CTX(buffer_tr, SOF_UUID(buffer_uuid), LOG_LEVEL_INFO); -struct comp_buffer *buffer_alloc(uint32_t size, uint32_t caps, uint32_t flags, uint32_t align) +struct comp_buffer *buffer_alloc(uint32_t size, uint32_t caps, uint32_t flags, uint32_t align, + bool is_shared) { struct comp_buffer *buffer; struct comp_buffer __sparse_cache *buffer_c; @@ -42,16 +43,19 @@ struct comp_buffer *buffer_alloc(uint32_t size, uint32_t caps, uint32_t flags, u return NULL; } - /* - * allocate new buffer, align the allocation size to a cache line for - * the coherent API - */ - buffer = coherent_init_thread(struct comp_buffer, c); + /* allocate new buffer */ + enum mem_zone zone = is_shared ? SOF_MEM_ZONE_RUNTIME_SHARED : SOF_MEM_ZONE_RUNTIME; + + buffer = rzalloc(zone, 0, SOF_MEM_CAPS_RAM, sizeof(*buffer)); + if (!buffer) { tr_err(&buffer_tr, "buffer_alloc(): could not alloc structure"); return NULL; } + CORE_CHECK_STRUCT_INIT(buffer, is_shared); + + buffer->is_shared = is_shared; stream_addr = rballoc_align(0, caps, size, align); if (!stream_addr) { rfree(buffer); @@ -70,18 +74,6 @@ struct comp_buffer *buffer_alloc(uint32_t size, uint32_t caps, uint32_t flags, u buffer_release(buffer_c); - /* - * The buffer hasn't yet been marked as shared, hence buffer_release() - * hasn't written back and invalidated the cache. Therefore we have to - * do this manually now before adding to the lists. Buffer list - * structures are always accessed uncached and they're never modified at - * run-time, i.e. buffers are never relinked. So we have to make sure, - * that what we have written into buffer's cache is in RAM before - * modifying that RAM bypassing cache, and that after this cache is - * re-loaded again. - */ - dcache_writeback_invalidate_region(uncache_to_cache(buffer), sizeof(*buffer)); - list_init(&buffer->source_list); list_init(&buffer->sink_list); @@ -91,6 +83,7 @@ struct comp_buffer *buffer_alloc(uint32_t size, uint32_t caps, uint32_t flags, u void buffer_zero(struct comp_buffer __sparse_cache *buffer) { buf_dbg(buffer, "stream_zero()"); + CORE_CHECK_STRUCT(buffer); bzero(audio_stream_get_addr(&buffer->stream), audio_stream_get_size(&buffer->stream)); if (buffer->caps & SOF_MEM_CAPS_DMA) @@ -103,6 +96,8 @@ int buffer_set_size(struct comp_buffer __sparse_cache *buffer, uint32_t size, ui { void *new_ptr = NULL; + CORE_CHECK_STRUCT(buffer); + /* validate request */ if (size == 0) { buf_err(buffer, "resize size = %u is invalid", size); @@ -141,6 +136,8 @@ int buffer_set_params(struct comp_buffer __sparse_cache *buffer, int ret; int i; + CORE_CHECK_STRUCT(buffer); + if (!params) { buf_err(buffer, "buffer_set_params(): !params"); return -EINVAL; @@ -168,6 +165,7 @@ bool buffer_params_match(struct comp_buffer __sparse_cache *buffer, struct sof_ipc_stream_params *params, uint32_t flag) { assert(params); + CORE_CHECK_STRUCT(buffer); if ((flag & BUFF_PARAMS_FRAME_FMT) && audio_stream_get_frm_fmt(&buffer->stream) != params->frame_fmt) @@ -191,6 +189,8 @@ void buffer_free(struct comp_buffer *buffer) .buffer = buffer, }; + CORE_CHECK_STRUCT(buffer); + if (!buffer) return; @@ -206,18 +206,6 @@ void buffer_free(struct comp_buffer *buffer) coherent_free_thread(buffer, c); } -/* - * comp_update_buffer_produce() and comp_update_buffer_consume() send - * NOTIFIER_ID_BUFFER_PRODUCE and NOTIFIER_ID_BUFFER_CONSUME notifier events - * respectively. The only recipient of those notifications is probes. The - * target for those notifications is always the current core, therefore notifier - * callbacks will be called synchronously from notifier_event() calls. Therefore - * we cannot pass unlocked buffer pointers to probes, because if they try to - * acquire the buffer, that can cause a deadlock. In general locked objects - * shouldn't be passed to potentially asynchronous contexts, but here we have no - * choice but to use our knowledge of the local notifier behaviour and pass - * locked buffers to notification recipients. - */ void comp_update_buffer_produce(struct comp_buffer __sparse_cache *buffer, uint32_t bytes) { struct buffer_cb_transact cb_data = { @@ -240,8 +228,7 @@ void comp_update_buffer_produce(struct comp_buffer __sparse_cache *buffer, uint3 audio_stream_produce(&buffer->stream, bytes); - /* Notifier looks for the pointer value to match it against registration */ - notifier_event(cache_to_uncache(buffer), NOTIFIER_ID_BUFFER_PRODUCE, + notifier_event((__sparse_force void *)buffer, NOTIFIER_ID_BUFFER_PRODUCE, NOTIFIER_TARGET_CORE_LOCAL, &cb_data, sizeof(cb_data)); #if CONFIG_SOF_LOG_DBG_BUFFER @@ -265,6 +252,8 @@ void comp_update_buffer_consume(struct comp_buffer __sparse_cache *buffer, uint3 .transaction_begin_address = audio_stream_get_rptr(&buffer->stream), }; + CORE_CHECK_STRUCT(buffer); + /* return if no bytes */ if (!bytes) { #if CONFIG_SOF_LOG_DBG_BUFFER @@ -279,7 +268,7 @@ void comp_update_buffer_consume(struct comp_buffer __sparse_cache *buffer, uint3 audio_stream_consume(&buffer->stream, bytes); - notifier_event(cache_to_uncache(buffer), NOTIFIER_ID_BUFFER_CONSUME, + notifier_event((__sparse_force void *)buffer, NOTIFIER_ID_BUFFER_CONSUME, NOTIFIER_TARGET_CORE_LOCAL, &cb_data, sizeof(cb_data)); #if CONFIG_SOF_LOG_DBG_BUFFER @@ -303,30 +292,8 @@ void comp_update_buffer_consume(struct comp_buffer __sparse_cache *buffer, uint3 void buffer_attach(struct comp_buffer *buffer, struct list_item *head, int dir) { struct list_item *list = buffer_comp_list(buffer, dir); - struct list_item __sparse_cache *needs_sync; - bool further_buffers_exist; - - /* - * There can already be buffers on the target list. If we just link this - * buffer, we modify the first buffer's list header via uncached alias, - * so its cached copy can later be written back, overwriting the - * modified header. FIXME: this is still a problem with different cores. - */ - further_buffers_exist = !list_is_empty(head); - needs_sync = uncache_to_cache(head->next); - if (further_buffers_exist) - dcache_writeback_region(needs_sync, sizeof(struct list_item)); - /* The cache line can be prefetched here, invalidate it after prepending */ + CORE_CHECK_STRUCT(buffer); list_item_prepend(list, head); - if (further_buffers_exist) - dcache_invalidate_region(needs_sync, sizeof(struct list_item)); -#if CONFIG_INTEL - /* - * Until now the buffer object wasn't in cache, but uncached access to it could have - * triggered a cache prefetch. Drop that cache line to avoid using stale data in it. - */ - dcache_invalidate_region(uncache_to_cache(list), sizeof(*list)); -#endif } /* @@ -335,32 +302,7 @@ void buffer_attach(struct comp_buffer *buffer, struct list_item *head, int dir) */ void buffer_detach(struct comp_buffer *buffer, struct list_item *head, int dir) { - struct list_item __sparse_cache *needs_sync_prev, *needs_sync_next; - bool buffers_after_exist, buffers_before_exist; struct list_item *buf_list = buffer_comp_list(buffer, dir); - - /* - * There can be more buffers linked together with this one, that will - * still be staying on their respective pipelines and might get used via - * their cached aliases. If we just unlink this buffer, we modify their - * list header via uncached alias, so their cached copy can later be - * written back, overwriting the modified header. FIXME: this is still a - * problem with different cores. - */ - buffers_after_exist = head != buf_list->next; - buffers_before_exist = head != buf_list->prev; - needs_sync_prev = uncache_to_cache(buf_list->prev); - needs_sync_next = uncache_to_cache(buf_list->next); - if (buffers_after_exist) - dcache_writeback_region(needs_sync_next, sizeof(struct list_item)); - if (buffers_before_exist) - dcache_writeback_region(needs_sync_prev, sizeof(struct list_item)); - dcache_writeback_region(uncache_to_cache(buf_list), sizeof(*buf_list)); - /* buffers before or after can be prefetched here */ + CORE_CHECK_STRUCT(buffer); list_item_del(buf_list); - dcache_invalidate_region(uncache_to_cache(buf_list), sizeof(*buf_list)); - if (buffers_after_exist) - dcache_invalidate_region(needs_sync_next, sizeof(struct list_item)); - if (buffers_before_exist) - dcache_invalidate_region(needs_sync_prev, sizeof(struct list_item)); } diff --git a/src/audio/chain_dma.c b/src/audio/chain_dma.c index b8cf7ded072a..f2fbf3cdbfbb 100644 --- a/src/audio/chain_dma.c +++ b/src/audio/chain_dma.c @@ -588,8 +588,8 @@ static int chain_task_init(struct comp_dev *dev, uint8_t host_dma_id, uint8_t li } fifo_size = ALIGN_UP_INTERNAL(fifo_size, addr_align); - - cd->dma_buffer = buffer_alloc(fifo_size, SOF_MEM_CAPS_DMA, 0, addr_align); + /* allocate not shared buffer */ + cd->dma_buffer = buffer_alloc(fifo_size, SOF_MEM_CAPS_DMA, 0, addr_align, false); if (!cd->dma_buffer) { comp_err(dev, "chain_task_init(): failed to alloc dma buffer"); diff --git a/src/audio/copier/copier_generic.c b/src/audio/copier/copier_generic.c index c610d05a049d..13794b19bccd 100644 --- a/src/audio/copier/copier_generic.c +++ b/src/audio/copier/copier_generic.c @@ -204,8 +204,8 @@ int create_endpoint_buffer(struct comp_dev *dev, ipc_buf.size = buf_size; ipc_buf.comp.pipeline_id = config->pipeline_id; ipc_buf.comp.core = config->core; - - buffer = buffer_new(&ipc_buf); + /* allocate not shared buffer */ + buffer = buffer_new(&ipc_buf, false); if (!buffer) return -ENOMEM; diff --git a/src/audio/dai-legacy.c b/src/audio/dai-legacy.c index 884f2b00f2fc..446ae0c83c08 100644 --- a/src/audio/dai-legacy.c +++ b/src/audio/dai-legacy.c @@ -600,7 +600,7 @@ int dai_common_params(struct dai_data *dd, struct comp_dev *dev, } } else { dd->dma_buffer = buffer_alloc(buffer_size, SOF_MEM_CAPS_DMA, 0, - addr_align); + addr_align, false); if (!dd->dma_buffer) { comp_err(dev, "dai_params(): failed to alloc dma buffer"); return -ENOMEM; diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index bcbfd91dd2ad..f83bf3d27f94 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -977,8 +977,9 @@ int dai_common_params(struct dai_data *dd, struct comp_dev *dev, return err; } } else { + /* allocate not shared buffer */ dd->dma_buffer = buffer_alloc(buffer_size, SOF_MEM_CAPS_DMA, 0, - addr_align); + addr_align, false); if (!dd->dma_buffer) { comp_err(dev, "dai_common_params(): failed to alloc dma buffer"); return -ENOMEM; diff --git a/src/audio/host-legacy.c b/src/audio/host-legacy.c index b9a112583586..546cc6edbfc1 100644 --- a/src/audio/host-legacy.c +++ b/src/audio/host-legacy.c @@ -788,7 +788,7 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev, } } else { hd->dma_buffer = buffer_alloc(buffer_size, SOF_MEM_CAPS_DMA, 0, - addr_align); + addr_align, false); if (!hd->dma_buffer) { comp_err(dev, "host_params(): failed to alloc dma buffer"); err = -ENOMEM; diff --git a/src/audio/host-zephyr.c b/src/audio/host-zephyr.c index d62ad4b424fc..5a2a57438536 100644 --- a/src/audio/host-zephyr.c +++ b/src/audio/host-zephyr.c @@ -857,8 +857,9 @@ int host_common_params(struct host_data *hd, struct comp_dev *dev, goto out; } } else { + /* allocate not shared buffer */ hd->dma_buffer = buffer_alloc(buffer_size, SOF_MEM_CAPS_DMA, 0, - addr_align); + addr_align, false); if (!hd->dma_buffer) { comp_err(dev, "host_params(): failed to alloc dma buffer"); err = -ENOMEM; diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index e28541560403..81b0cb890bf8 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -448,8 +448,9 @@ int module_adapter_prepare(struct comp_dev *dev) /* allocate buffer for all sinks */ if (list_is_empty(&mod->sink_buffer_list)) { for (i = 0; i < mod->num_output_buffers; i++) { + /* allocate not shared buffer */ struct comp_buffer *buffer = buffer_alloc(buff_size, SOF_MEM_CAPS_RAM, - 0, PLATFORM_DCACHE_ALIGN); + 0, PLATFORM_DCACHE_ALIGN, false); uint32_t flags; if (!buffer) { diff --git a/src/audio/pipeline/pipeline-graph.c b/src/audio/pipeline/pipeline-graph.c index 71645c69fa84..160e14e15441 100644 --- a/src/audio/pipeline/pipeline-graph.c +++ b/src/audio/pipeline/pipeline-graph.c @@ -176,10 +176,6 @@ static void buffer_set_comp(struct comp_buffer *buffer, struct comp_dev *comp, buffer_c->sink = comp; buffer_release(buffer_c); - - /* The buffer might be marked as shared later, write back the cache */ - if (!buffer->c.shared) - dcache_writeback_invalidate_region(uncache_to_cache(buffer), sizeof(*buffer)); } int pipeline_connect(struct comp_dev *comp, struct comp_buffer *buffer, diff --git a/src/include/sof/audio/buffer.h b/src/include/sof/audio/buffer.h index 2eeef2d9f80a..51a505b209cf 100644 --- a/src/include/sof/audio/buffer.h +++ b/src/include/sof/audio/buffer.h @@ -133,9 +133,9 @@ extern struct tr_ctx buffer_tr; * 5) write back cached data and release lock using uncache pointer. */ struct comp_buffer { - struct coherent c; - /* data buffer */ + CORE_CHECK_STRUCT_FIELD; + struct audio_stream stream; /* configuration */ @@ -144,6 +144,7 @@ struct comp_buffer { uint32_t caps; uint32_t core; struct tr_ctx tctx; /* trace settings */ + bool is_shared; /* buffer structure is shared between 2 cores */ /* connected components */ struct comp_dev *source; /* source component */ @@ -188,8 +189,9 @@ struct buffer_cb_free { } while (0) /* pipeline buffer creation and destruction */ -struct comp_buffer *buffer_alloc(uint32_t size, uint32_t caps, uint32_t flags, uint32_t align); -struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc); +struct comp_buffer *buffer_alloc(uint32_t size, uint32_t caps, uint32_t flags, uint32_t align, + bool is_shared); +struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc, bool is_shared); int buffer_set_size(struct comp_buffer __sparse_cache *buffer, uint32_t size, uint32_t alignment); void buffer_free(struct comp_buffer *buffer); void buffer_zero(struct comp_buffer __sparse_cache *buffer); @@ -209,32 +211,27 @@ bool buffer_params_match(struct comp_buffer __sparse_cache *buffer, static inline void buffer_stream_invalidate(struct comp_buffer __sparse_cache *buffer, uint32_t bytes) { - if (!is_coherent_shared(buffer, c)) - return; - - audio_stream_invalidate(&buffer->stream, bytes); + if (buffer->is_shared) + audio_stream_invalidate(&buffer->stream, bytes); } static inline void buffer_stream_writeback(struct comp_buffer __sparse_cache *buffer, uint32_t bytes) { - if (!is_coherent_shared(buffer, c)) - return; - - audio_stream_writeback(&buffer->stream, bytes); + if (buffer->is_shared) + audio_stream_writeback(&buffer->stream, bytes); } +/* stubs for acquire/release for compilation, to be removed at last step */ __must_check static inline struct comp_buffer __sparse_cache *buffer_acquire( struct comp_buffer *buffer) { - struct coherent __sparse_cache *c = coherent_acquire_thread(&buffer->c, sizeof(*buffer)); - - return attr_container_of(c, struct comp_buffer __sparse_cache, c, __sparse_cache); + return (struct comp_buffer __sparse_cache *)buffer; } static inline void buffer_release(struct comp_buffer __sparse_cache *buffer) { - coherent_release_thread(&buffer->c, sizeof(*buffer)); + (void)buffer; } /* diff --git a/src/include/sof/coherent.h b/src/include/sof/coherent.h index 4ca5120cfee9..8e06fb466a66 100644 --- a/src/include/sof/coherent.h +++ b/src/include/sof/coherent.h @@ -80,9 +80,23 @@ struct coherent { /* debug sharing amongst cores */ #ifdef COHERENT_CHECK_NONSHARED_CORES + +#define CORE_CHECK_STRUCT_FIELD uint32_t __core; bool __is_shared +#define CORE_CHECK_STRUCT_INIT(_c, is_shared) { (_c)->__core = cpu_get_id(); \ + (_c)->__is_shared = is_shared; } +#define CORE_CHECK_STRUCT(_c) { assert(!!(_c)->__is_shared == !!is_uncached(_c)); \ + assert(cpu_get_id() == (_c)->__core || (_c)->__is_shared); } + #define CHECK_COHERENT_CORE(_c) assert((_c)->core == cpu_get_id()) + #else + +#define CORE_CHECK_STRUCT_FIELD +#define CORE_CHECK_STRUCT_INIT(_c, is_shared) +#define CORE_CHECK_STRUCT(_c) + #define CHECK_COHERENT_CORE(_c) + #endif #ifdef __ZEPHYR__ diff --git a/src/ipc/ipc-helper.c b/src/ipc/ipc-helper.c index bbcec49698f0..d71045139d82 100644 --- a/src/ipc/ipc-helper.c +++ b/src/ipc/ipc-helper.c @@ -36,7 +36,7 @@ LOG_MODULE_DECLARE(ipc, CONFIG_SOF_LOG_LEVEL); /* create a new component in the pipeline */ -struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc) +struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc, bool is_shared) { struct comp_buffer *buffer; @@ -44,7 +44,8 @@ struct comp_buffer *buffer_new(const struct sof_ipc_buffer *desc) desc->size, desc->comp.pipeline_id, desc->comp.id, desc->flags); /* allocate buffer */ - buffer = buffer_alloc(desc->size, desc->caps, desc->flags, PLATFORM_DCACHE_ALIGN); + buffer = buffer_alloc(desc->size, desc->caps, desc->flags, PLATFORM_DCACHE_ALIGN, + is_shared); if (buffer) { buffer->id = desc->comp.id; buffer->pipeline_id = desc->comp.pipeline_id; @@ -174,8 +175,8 @@ int comp_buffer_connect(struct comp_dev *comp, uint32_t comp_core, { /* check if it's a connection between cores */ if (buffer->core != comp_core) { - /* set the buffer as a coherent object */ - coherent_shared_thread(buffer, c); + /* buffer must be shared */ + assert(buffer->is_shared); if (!comp->is_shared) comp_make_shared(comp); diff --git a/src/ipc/ipc3/helper.c b/src/ipc/ipc3/helper.c index 4a723b9539a7..2bd55ec22717 100644 --- a/src/ipc/ipc3/helper.c +++ b/src/ipc/ipc3/helper.c @@ -454,7 +454,7 @@ int ipc_buffer_new(struct ipc *ipc, const struct sof_ipc_buffer *desc) } /* register buffer with pipeline */ - buffer = buffer_new(desc); + buffer = buffer_new(desc, false); if (!buffer) { tr_err(&ipc_tr, "ipc_buffer_new(): buffer_new() failed"); return -ENOMEM; @@ -572,6 +572,12 @@ static int ipc_comp_to_buffer_connect(struct ipc_comp_dev *comp, tr_dbg(&ipc_tr, "ipc: comp sink %d, source %d -> connect", buffer->id, comp->id); +#if CONFIG_INCOHERENT + if (comp->core != buffer->cb->core) { + tr_err(&ipc_tr, "ipc: shared buffers are not supported for IPC3 incoherent architectures"); + return -ENOTSUP; + } +#endif return comp_buffer_connect(comp->cd, comp->core, buffer->cb, PPL_CONN_DIR_COMP_TO_BUFFER); } @@ -582,6 +588,12 @@ static int ipc_buffer_to_comp_connect(struct ipc_comp_dev *buffer, tr_dbg(&ipc_tr, "ipc: comp sink %d, source %d -> connect", comp->id, buffer->id); +#if CONFIG_INCOHERENT + if (comp->core != buffer->cb->core) { + tr_err(&ipc_tr, "ipc: shared buffers are not supported for IPC3 incoherent architectures"); + return -ENOTSUP; + } +#endif return comp_buffer_connect(comp->cd, comp->core, buffer->cb, PPL_CONN_DIR_BUFFER_TO_COMP); } diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index 46a4ff1e3f1b..1d2838c1ed57 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -315,7 +315,7 @@ int ipc_pipeline_free(struct ipc *ipc, uint32_t comp_id) return IPC4_SUCCESS; } -static struct comp_buffer *ipc4_create_buffer(struct comp_dev *src, struct comp_dev *sink, +static struct comp_buffer *ipc4_create_buffer(struct comp_dev *src, bool is_shared, uint32_t src_obs, uint32_t src_queue, uint32_t dst_queue) { @@ -330,7 +330,7 @@ static struct comp_buffer *ipc4_create_buffer(struct comp_dev *src, struct comp_ ipc_buf.comp.id = IPC4_COMP_ID(src_queue, dst_queue); ipc_buf.comp.pipeline_id = src->ipc_config.pipeline_id; ipc_buf.comp.core = src->ipc_config.core; - return buffer_new(&ipc_buf); + return buffer_new(&ipc_buf, is_shared); } int ipc_comp_connect(struct ipc *ipc, ipc_pipe_comp_connect *_connect) @@ -344,6 +344,7 @@ int ipc_comp_connect(struct ipc *ipc, ipc_pipe_comp_connect *_connect) struct ipc4_base_module_cfg sink_src_cfg; uint32_t flags; int src_id, sink_id; + bool is_shared; int ret; bu = (struct ipc4_module_bind_unbind *)_connect; @@ -360,6 +361,7 @@ int ipc_comp_connect(struct ipc *ipc, ipc_pipe_comp_connect *_connect) /* Pass IPC to target core if both modules has the same target core */ if (!cpu_is_me(source->ipc_config.core) && source->ipc_config.core == sink->ipc_config.core) return ipc4_process_on_core(source->ipc_config.core, false); + is_shared = (source->ipc_config.core != sink->ipc_config.core); ret = comp_get_attribute(source, COMP_ATTR_BASE_CONFIG, &source_src_cfg); if (ret < 0) { @@ -373,8 +375,8 @@ int ipc_comp_connect(struct ipc *ipc, ipc_pipe_comp_connect *_connect) return IPC4_FAILURE; } - buffer = ipc4_create_buffer(source, sink, source_src_cfg.obs, bu->extension.r.src_queue, - bu->extension.r.dst_queue); + buffer = ipc4_create_buffer(source, is_shared, source_src_cfg.obs, + bu->extension.r.src_queue, bu->extension.r.dst_queue); if (!buffer) { tr_err(&ipc_tr, "failed to allocate buffer to bind %d to %d", src_id, sink_id); return IPC4_OUT_OF_MEMORY; diff --git a/test/cmocka/src/audio/buffer/buffer_copy.c b/test/cmocka/src/audio/buffer/buffer_copy.c index 1983d92edfdf..be1500cb66f0 100644 --- a/test/cmocka/src/audio/buffer/buffer_copy.c +++ b/test/cmocka/src/audio/buffer/buffer_copy.c @@ -29,8 +29,8 @@ static void test_audio_buffer_copy_underrun(void **state) .size = 256 }; - struct comp_buffer *src = buffer_new(&test_buf_desc); - struct comp_buffer *snk = buffer_new(&test_buf_desc); + struct comp_buffer *src = buffer_new(&test_buf_desc, false); + struct comp_buffer *snk = buffer_new(&test_buf_desc, false); assert_non_null(src); assert_non_null(snk); @@ -56,8 +56,8 @@ static void test_audio_buffer_copy_overrun(void **state) .size = 256 }; - struct comp_buffer *src = buffer_new(&test_buf_desc); - struct comp_buffer *snk = buffer_new(&test_buf_desc); + struct comp_buffer *src = buffer_new(&test_buf_desc, false); + struct comp_buffer *snk = buffer_new(&test_buf_desc, false); assert_non_null(src); assert_non_null(snk); @@ -85,8 +85,8 @@ static void test_audio_buffer_copy_success(void **state) .size = 256 }; - struct comp_buffer *src = buffer_new(&test_buf_desc); - struct comp_buffer *snk = buffer_new(&test_buf_desc); + struct comp_buffer *src = buffer_new(&test_buf_desc, false); + struct comp_buffer *snk = buffer_new(&test_buf_desc, false); assert_non_null(src); assert_non_null(snk); @@ -111,8 +111,8 @@ static void test_audio_buffer_copy_fit_space_constraint(void **state) .size = 256 }; - struct comp_buffer *src = buffer_new(&test_buf_desc); - struct comp_buffer *snk = buffer_new(&test_buf_desc); + struct comp_buffer *src = buffer_new(&test_buf_desc, false); + struct comp_buffer *snk = buffer_new(&test_buf_desc, false); assert_non_null(src); assert_non_null(snk); @@ -139,8 +139,8 @@ static void test_audio_buffer_copy_fit_no_space_constraint(void **state) .size = 256 }; - struct comp_buffer *src = buffer_new(&test_buf_desc); - struct comp_buffer *snk = buffer_new(&test_buf_desc); + struct comp_buffer *src = buffer_new(&test_buf_desc, false); + struct comp_buffer *snk = buffer_new(&test_buf_desc, false); assert_non_null(src); assert_non_null(snk); diff --git a/test/cmocka/src/audio/buffer/buffer_new.c b/test/cmocka/src/audio/buffer/buffer_new.c index 2f78033a5fc1..e2ce0c274b57 100644 --- a/test/cmocka/src/audio/buffer/buffer_new.c +++ b/test/cmocka/src/audio/buffer/buffer_new.c @@ -27,7 +27,7 @@ static void test_audio_buffer_new(void **state) .size = 256 }; - struct comp_buffer *buf = buffer_new(&test_buf_desc); + struct comp_buffer *buf = buffer_new(&test_buf_desc, false); assert_non_null(buf); assert_int_equal(audio_stream_get_avail_bytes(&buf->stream), 0); diff --git a/test/cmocka/src/audio/buffer/buffer_wrap.c b/test/cmocka/src/audio/buffer/buffer_wrap.c index 210bce1a2ef0..b0c7d11ce555 100644 --- a/test/cmocka/src/audio/buffer/buffer_wrap.c +++ b/test/cmocka/src/audio/buffer/buffer_wrap.c @@ -27,7 +27,7 @@ static void test_audio_buffer_write_fill_10_bytes_and_write_5(void **state) .size = 10 }; - struct comp_buffer *buf = buffer_new(&test_buf_desc); + struct comp_buffer *buf = buffer_new(&test_buf_desc, false); assert_non_null(buf); assert_int_equal(audio_stream_get_avail_bytes(&buf->stream), 0); diff --git a/test/cmocka/src/audio/buffer/buffer_write.c b/test/cmocka/src/audio/buffer/buffer_write.c index 8c4fc185c2db..8c3e437d612a 100644 --- a/test/cmocka/src/audio/buffer/buffer_write.c +++ b/test/cmocka/src/audio/buffer/buffer_write.c @@ -28,7 +28,7 @@ static void test_audio_buffer_write_10_bytes_out_of_256_and_read_back .size = 256 }; - struct comp_buffer *buf = buffer_new(&test_buf_desc); + struct comp_buffer *buf = buffer_new(&test_buf_desc, false); assert_non_null(buf); assert_int_equal(audio_stream_get_avail_bytes(&buf->stream), 0); @@ -63,7 +63,7 @@ static void test_audio_buffer_fill_10_bytes(void **state) .size = 10 }; - struct comp_buffer *buf = buffer_new(&test_buf_desc); + struct comp_buffer *buf = buffer_new(&test_buf_desc, false); assert_non_null(buf); assert_int_equal(audio_stream_get_avail_bytes(&buf->stream), 0); diff --git a/test/cmocka/src/math/fft/fft.c b/test/cmocka/src/math/fft/fft.c index 653212c7bfc2..cfb2ec8d98bb 100644 --- a/test/cmocka/src/math/fft/fft.c +++ b/test/cmocka/src/math/fft/fft.c @@ -265,8 +265,8 @@ static void test_math_fft_256(void **state) struct sof_ipc_buffer test_buf_desc = { .size = 256 * 2 * sizeof(int32_t), }; - struct comp_buffer *source = buffer_new(&test_buf_desc); - struct comp_buffer *sink = buffer_new(&test_buf_desc); + struct comp_buffer *source = buffer_new(&test_buf_desc, false); + struct comp_buffer *sink = buffer_new(&test_buf_desc, false); struct icomplex32 *out = (struct icomplex32 *)sink->stream.addr; int32_t *in = (int32_t *)source->stream.addr; int fft_size = 256; @@ -307,8 +307,8 @@ static void test_math_fft_512(void **state) struct sof_ipc_buffer test_buf_desc = { .size = 512 * 2 * sizeof(int32_t), }; - struct comp_buffer *source = buffer_new(&test_buf_desc); - struct comp_buffer *sink = buffer_new(&test_buf_desc); + struct comp_buffer *source = buffer_new(&test_buf_desc, false); + struct comp_buffer *sink = buffer_new(&test_buf_desc, false); struct icomplex32 *out = (struct icomplex32 *)sink->stream.addr; int32_t *in = (int32_t *)source->stream.addr; int fft_size = 512; @@ -349,8 +349,8 @@ static void test_math_fft_1024(void **state) struct sof_ipc_buffer test_buf_desc = { .size = 1024 * 2 * sizeof(int32_t), }; - struct comp_buffer *source = buffer_new(&test_buf_desc); - struct comp_buffer *sink = buffer_new(&test_buf_desc); + struct comp_buffer *source = buffer_new(&test_buf_desc, false); + struct comp_buffer *sink = buffer_new(&test_buf_desc, false); struct icomplex32 *out = (struct icomplex32 *)sink->stream.addr; int32_t *in = (int32_t *)source->stream.addr; int fft_size = 1024; @@ -391,9 +391,9 @@ static void test_math_fft_1024_ifft(void **state) struct sof_ipc_buffer test_buf_desc = { .size = 1024 * 4 * 2, }; - struct comp_buffer *source = buffer_new(&test_buf_desc); - struct comp_buffer *intm = buffer_new(&test_buf_desc); - struct comp_buffer *sink = buffer_new(&test_buf_desc); + struct comp_buffer *source = buffer_new(&test_buf_desc, false); + struct comp_buffer *intm = buffer_new(&test_buf_desc, false); + struct comp_buffer *sink = buffer_new(&test_buf_desc, false); struct icomplex32 *out = (struct icomplex32 *)sink->stream.addr; float db; int64_t signal = 0; @@ -432,9 +432,9 @@ static void test_math_fft_512_2ch(void **state) struct sof_ipc_buffer test_buf_desc = { .size = 512 * 4 * 2, }; - struct comp_buffer *source = buffer_new(&test_buf_desc); - struct comp_buffer *sink1 = buffer_new(&test_buf_desc); - struct comp_buffer *sink2 = buffer_new(&test_buf_desc); + struct comp_buffer *source = buffer_new(&test_buf_desc, false); + struct comp_buffer *sink1 = buffer_new(&test_buf_desc, false); + struct comp_buffer *sink2 = buffer_new(&test_buf_desc, false); struct icomplex32 *out1 = (struct icomplex32 *)sink1->stream.addr; struct icomplex32 *out2 = (struct icomplex32 *)sink2->stream.addr; uint32_t fft_size = 512; @@ -625,8 +625,8 @@ static void test_math_fft_256_16(void **state) struct sof_ipc_buffer test_buf_desc = { .size = 256 * 2 * sizeof(int16_t), }; - struct comp_buffer *source = buffer_new(&test_buf_desc); - struct comp_buffer *sink = buffer_new(&test_buf_desc); + struct comp_buffer *source = buffer_new(&test_buf_desc, false); + struct comp_buffer *sink = buffer_new(&test_buf_desc, false); struct icomplex16 *out = (struct icomplex16 *)sink->stream.addr; int16_t *in = (int16_t *)source->stream.addr; int fft_size = 256; @@ -667,8 +667,8 @@ static void test_math_fft_512_16(void **state) struct sof_ipc_buffer test_buf_desc = { .size = 512 * 2 * sizeof(int16_t), }; - struct comp_buffer *source = buffer_new(&test_buf_desc); - struct comp_buffer *sink = buffer_new(&test_buf_desc); + struct comp_buffer *source = buffer_new(&test_buf_desc, false); + struct comp_buffer *sink = buffer_new(&test_buf_desc, false); struct icomplex16 *out = (struct icomplex16 *)sink->stream.addr; int16_t *in = (int16_t *)source->stream.addr; int fft_size = 512; @@ -709,8 +709,8 @@ static void test_math_fft_1024_16(void **state) struct sof_ipc_buffer test_buf_desc = { .size = 1024 * 2 * sizeof(int16_t), }; - struct comp_buffer *source = buffer_new(&test_buf_desc); - struct comp_buffer *sink = buffer_new(&test_buf_desc); + struct comp_buffer *source = buffer_new(&test_buf_desc, false); + struct comp_buffer *sink = buffer_new(&test_buf_desc, false); struct icomplex16 *out = (struct icomplex16 *)sink->stream.addr; int16_t *in = (int16_t *)source->stream.addr; int fft_size = 1024; @@ -751,9 +751,9 @@ static void test_math_fft_1024_ifft_16(void **state) struct sof_ipc_buffer test_buf_desc = { .size = 1024 * 2 * sizeof(int16_t), }; - struct comp_buffer *source = buffer_new(&test_buf_desc); - struct comp_buffer *intm = buffer_new(&test_buf_desc); - struct comp_buffer *sink = buffer_new(&test_buf_desc); + struct comp_buffer *source = buffer_new(&test_buf_desc, false); + struct comp_buffer *intm = buffer_new(&test_buf_desc, false); + struct comp_buffer *sink = buffer_new(&test_buf_desc, false); struct icomplex16 *out = (struct icomplex16 *)sink->stream.addr; float db; int64_t signal = 0; diff --git a/test/cmocka/src/util.h b/test/cmocka/src/util.h index be540359395c..5ef231ceba64 100644 --- a/test/cmocka/src/util.h +++ b/test/cmocka/src/util.h @@ -23,7 +23,7 @@ static inline struct comp_buffer *create_test_sink(struct comp_dev *dev, }, .size = buffer_size, }; - struct comp_buffer *buffer = buffer_new(&desc); + struct comp_buffer *buffer = buffer_new(&desc, false); memset(buffer->stream.addr, 0, buffer_size); @@ -58,7 +58,7 @@ static inline struct comp_buffer *create_test_source(struct comp_dev *dev, }, .size = buffer_size, }; - struct comp_buffer *buffer = buffer_new(&desc); + struct comp_buffer *buffer = buffer_new(&desc, false); memset(buffer->stream.addr, 0, buffer_size);