Skip to content

Commit 25c06b8

Browse files
revert: Cross core Virtual heaps, invalidation of cross core buffers in unbind call #10044
1 parent 179f826 commit 25c06b8

25 files changed

Lines changed: 274 additions & 357 deletions

File tree

src/audio/buffers/audio_buffer.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <stdint.h>
88
#include <stddef.h>
99
#include <errno.h>
10-
#include <rtos/panic.h>
1110
#include <rtos/alloc.h>
1211
#include <ipc/stream.h>
1312
#include <sof/audio/audio_buffer.h>
@@ -93,8 +92,9 @@ void audio_buffer_free(struct sof_audio_buffer *buffer)
9392
audio_buffer_free(buffer->secondary_buffer_sink);
9493
audio_buffer_free(buffer->secondary_buffer_source);
9594
#endif /* CONFIG_PIPELINE_2_0 */
96-
/* "virtual destructor": free the buffer internals and buffer memory */
97-
buffer->ops->free(buffer);
95+
if (buffer->ops->free)
96+
buffer->ops->free(buffer);
97+
rfree(buffer);
9898
}
9999

100100
static
@@ -196,7 +196,6 @@ void audio_buffer_init(struct sof_audio_buffer *buffer, uint32_t buffer_type, bo
196196
CORE_CHECK_STRUCT_INIT(&buffer, is_shared);
197197
buffer->buffer_type = buffer_type;
198198
buffer->ops = audio_buffer_ops;
199-
assert(audio_buffer_ops->free);
200199
buffer->audio_stream_params = audio_stream_params;
201200
buffer->is_shared = is_shared;
202201

src/audio/buffers/comp_buffer.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ static void comp_buffer_free(struct sof_audio_buffer *audio_buffer)
158158
notifier_unregister_all(NULL, buffer);
159159

160160
rfree(buffer->stream.addr);
161-
rfree(buffer);
162161
}
163162

164163
static struct source_ops comp_buffer_source_ops = {

src/audio/buffers/ring_buffer.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ static void ring_buffer_free(struct sof_audio_buffer *audio_buffer)
9696
container_of(audio_buffer, struct ring_buffer, audio_buffer);
9797

9898
rfree((__sparse_force void *)ring_buffer->_data_buffer);
99-
rfree(ring_buffer);
10099
}
101100

102101
static void ring_buffer_reset(struct sof_audio_buffer *audio_buffer)
@@ -240,21 +239,6 @@ static int ring_buffer_release_data(struct sof_source *source, size_t free_size)
240239
return 0;
241240
}
242241

243-
int ring_buffer_module_unbind(struct sof_sink *sink)
244-
{
245-
struct ring_buffer *ring_buffer = ring_buffer_from_sink(sink);
246-
247-
CORE_CHECK_STRUCT(&ring_buffer->audio_buffer);
248-
249-
/* in case of disconnection, invalidate all cache. This method is guaranteed be called on
250-
* core that have been using sink API
251-
*/
252-
ring_buffer_invalidate_shared(ring_buffer, ring_buffer->_data_buffer,
253-
ring_buffer->data_buffer_size);
254-
255-
return 0;
256-
}
257-
258242
static struct source_ops ring_buffer_source_ops = {
259243
.get_data_available = ring_buffer_get_data_available,
260244
.get_data = ring_buffer_get_data,
@@ -265,7 +249,6 @@ static struct sink_ops ring_buffer_sink_ops = {
265249
.get_free_size = ring_buffer_get_free_size,
266250
.get_buffer = ring_buffer_get_buffer,
267251
.commit_buffer = ring_buffer_commit_buffer,
268-
.on_unbind = ring_buffer_module_unbind,
269252
};
270253

271254
static const struct audio_buffer_ops audio_buffer_ops = {

src/audio/copier/copier.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,9 +1173,9 @@ __cold static int copier_get_hw_params(struct comp_dev *dev, struct sof_ipc_stre
11731173
return dai_common_get_hw_params(dd, dev, params, dir);
11741174
}
11751175

1176-
__cold static int copier_bind(struct processing_module *mod, struct bind_info *bind_data)
1176+
__cold static int copier_bind(struct processing_module *mod, void *data)
11771177
{
1178-
const struct ipc4_module_bind_unbind *const bu = bind_data->ipc4_data;
1178+
const struct ipc4_module_bind_unbind *const bu = (struct ipc4_module_bind_unbind *)data;
11791179
const uint32_t src_id = IPC4_COMP_ID(bu->primary.r.module_id, bu->primary.r.instance_id);
11801180
const uint32_t src_queue_id = bu->extension.r.src_queue;
11811181
struct copier_data *cd = module_get_private_data(mod);
@@ -1202,7 +1202,7 @@ __cold static int copier_bind(struct processing_module *mod, struct bind_info *b
12021202
return -ENODEV;
12031203
}
12041204

1205-
__cold static int copier_unbind(struct processing_module *mod, struct bind_info *unbind_data)
1205+
__cold static int copier_unbind(struct processing_module *mod, void *data)
12061206
{
12071207
struct copier_data *cd = module_get_private_data(mod);
12081208
struct comp_dev *dev = mod->dev;
@@ -1212,7 +1212,7 @@ __cold static int copier_unbind(struct processing_module *mod, struct bind_info
12121212
if (dev->ipc_config.type == SOF_COMP_DAI) {
12131213
struct dai_data *dd = cd->dd[0];
12141214

1215-
return dai_zephyr_unbind(dd, dev, unbind_data);
1215+
return dai_zephyr_unbind(dd, dev, data);
12161216
}
12171217

12181218
return 0;

src/audio/copier/dai_copier.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static inline int dai_zephyr_unbind(struct dai_data *dd, struct comp_dev *dev, v
6969
int dai_zephyr_multi_endpoint_copy(struct dai_data **dd, struct comp_dev *dev,
7070
struct comp_buffer *multi_endpoint_buffer,
7171
int num_endpoints);
72-
int dai_zephyr_unbind(struct dai_data *dd, struct comp_dev *dev, struct bind_info *unbind_data);
72+
int dai_zephyr_unbind(struct dai_data *dd, struct comp_dev *dev, void *data);
7373
#endif
7474

7575

src/audio/dai-zephyr.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,15 +1961,14 @@ static uint64_t dai_get_processed_data(struct comp_dev *dev, uint32_t stream_no,
19611961
}
19621962

19631963
#ifdef CONFIG_IPC_MAJOR_4
1964-
__cold
1965-
int dai_zephyr_unbind(struct dai_data *dd, struct comp_dev *dev, struct bind_info *unbind_data)
1964+
__cold int dai_zephyr_unbind(struct dai_data *dd, struct comp_dev *dev, void *data)
19661965
{
19671966
struct ipc4_module_bind_unbind *bu;
19681967
int buf_id;
19691968

19701969
assert_can_be_cold();
19711970

1972-
bu = unbind_data->ipc4_data;
1971+
bu = (struct ipc4_module_bind_unbind *)data;
19731972
buf_id = IPC4_COMP_ID(bu->extension.r.src_queue, bu->extension.r.dst_queue);
19741973

19751974
if (dd && dd->local_buffer) {

src/audio/kpb.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,10 @@ static int kpb_get_attribute(struct comp_dev *dev,
333333
/**
334334
* \brief Initialize KPB sinks when binding.
335335
* \param[in] dev - component device pointer.
336-
* \param[in] bind_data - bind/unbind data.
336+
* \param[in] data - ipc4 bind/unbind data.
337337
* \return: none.
338338
*/
339-
static int kpb_bind(struct comp_dev *dev, struct bind_info *bind_data)
339+
static int kpb_bind(struct comp_dev *dev, void *data)
340340
{
341341
struct comp_data *kpb = comp_get_drvdata(dev);
342342
struct ipc4_module_bind_unbind *bu;
@@ -345,7 +345,7 @@ static int kpb_bind(struct comp_dev *dev, struct bind_info *bind_data)
345345

346346
comp_dbg(dev, "kpb_bind()");
347347

348-
bu = bind_data->ipc4_data;
348+
bu = (struct ipc4_module_bind_unbind *)data;
349349
buf_id = IPC4_COMP_ID(bu->extension.r.src_queue, bu->extension.r.dst_queue);
350350

351351
/* We're assuming here that KPB Real Time sink (kpb->sel_sink) is
@@ -383,15 +383,15 @@ static int kpb_bind(struct comp_dev *dev, struct bind_info *bind_data)
383383
* \param[in] data - ipc4 bind/unbind data.
384384
* \return: none.
385385
*/
386-
static int kpb_unbind(struct comp_dev *dev, struct bind_info *unbind_data)
386+
static int kpb_unbind(struct comp_dev *dev, void *data)
387387
{
388388
struct comp_data *kpb = comp_get_drvdata(dev);
389389
struct ipc4_module_bind_unbind *bu;
390390
int buf_id;
391391

392392
comp_dbg(dev, "kpb_unbind()");
393393

394-
bu = unbind_data->ipc4_data;
394+
bu = (struct ipc4_module_bind_unbind *)data;
395395
buf_id = IPC4_COMP_ID(bu->extension.r.src_queue, bu->extension.r.dst_queue);
396396

397397
/* Reset sinks when unbinding */

src/audio/mixin_mixout/mixin_mixout.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -784,15 +784,17 @@ static int mixout_prepare(struct processing_module *mod,
784784
return 0;
785785
}
786786

787-
static int mixout_bind(struct processing_module *mod, struct bind_info *bind_data)
787+
static int mixout_bind(struct processing_module *mod, void *data)
788788
{
789789
struct ipc4_module_bind_unbind *bu;
790790
struct comp_dev *mixin;
791791
struct pending_frames *pending_frames;
792792
int src_id;
793793
struct mixout_data *mixout_data;
794794

795-
bu = bind_data->ipc4_data;
795+
comp_dbg(mod->dev, "mixout_bind() %p", data);
796+
797+
bu = (struct ipc4_module_bind_unbind *)data;
796798
src_id = IPC4_COMP_ID(bu->primary.r.module_id, bu->primary.r.instance_id);
797799

798800
/* we are only interested in bind for mixin -> mixout pair */
@@ -831,7 +833,7 @@ static int mixout_bind(struct processing_module *mod, struct bind_info *bind_dat
831833
return 0;
832834
}
833835

834-
static int mixout_unbind(struct processing_module *mod, struct bind_info *unbind_data)
836+
static int mixout_unbind(struct processing_module *mod, void *data)
835837
{
836838
struct ipc4_module_bind_unbind *bu;
837839
struct comp_dev *mixin;
@@ -841,7 +843,7 @@ static int mixout_unbind(struct processing_module *mod, struct bind_info *unbind
841843

842844
comp_dbg(mod->dev, "mixout_unbind()");
843845

844-
bu = unbind_data->ipc4_data;
846+
bu = (struct ipc4_module_bind_unbind *)data;
845847
src_id = IPC4_COMP_ID(bu->primary.r.module_id, bu->primary.r.instance_id);
846848

847849
/* we are only interested in unbind for mixin -> mixout pair */

src/audio/module_adapter/module/generic.c

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -493,52 +493,22 @@ int module_set_configuration(struct processing_module *mod,
493493
}
494494
EXPORT_SYMBOL(module_set_configuration);
495495

496-
int module_bind(struct processing_module *mod, struct bind_info *bind_data)
496+
int module_bind(struct processing_module *mod, void *data)
497497
{
498-
int ret;
499498
const struct module_interface *const ops = mod->dev->drv->adapter_ops;
500499

501-
switch (bind_data->bind_type) {
502-
case COMP_BIND_TYPE_SINK:
503-
ret = sink_bind(bind_data->sink, mod);
504-
break;
505-
case COMP_BIND_TYPE_SOURCE:
506-
ret = source_bind(bind_data->source, mod);
507-
break;
508-
default:
509-
ret = -EINVAL;
510-
}
511-
if (ret)
512-
return ret;
513-
514500
if (ops->bind)
515-
ret = ops->bind(mod, bind_data);
516-
517-
return ret;
501+
return ops->bind(mod, data);
502+
return 0;
518503
}
519504

520-
int module_unbind(struct processing_module *mod, struct bind_info *unbind_data)
505+
int module_unbind(struct processing_module *mod, void *data)
521506
{
522-
int ret;
523507
const struct module_interface *const ops = mod->dev->drv->adapter_ops;
524508

525-
switch (unbind_data->bind_type) {
526-
case COMP_BIND_TYPE_SINK:
527-
ret = sink_unbind(unbind_data->sink);
528-
break;
529-
case COMP_BIND_TYPE_SOURCE:
530-
ret = source_unbind(unbind_data->source);
531-
break;
532-
default:
533-
ret = -EINVAL;
534-
}
535-
if (ret)
536-
return ret;
537-
538509
if (ops->unbind)
539-
ret = ops->unbind(mod, unbind_data);
540-
541-
return ret;
510+
return ops->unbind(mod, data);
511+
return 0;
542512
}
543513

544514
void module_update_buffer_position(struct input_stream_buffer *input_buffers,

src/audio/module_adapter/module_adapter_ipc4.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ static bool module_adapter_multi_sink_source_prepare(struct comp_dev *dev)
242242
return false;
243243
}
244244

245-
int module_adapter_bind(struct comp_dev *dev, struct bind_info *bind_data)
245+
int module_adapter_bind(struct comp_dev *dev, void *data)
246246
{
247247
struct processing_module *mod = comp_mod(dev);
248248
int ret;
249249

250-
ret = module_bind(mod, bind_data);
250+
ret = module_bind(mod, data);
251251
if (ret < 0)
252252
return ret;
253253

@@ -257,12 +257,12 @@ int module_adapter_bind(struct comp_dev *dev, struct bind_info *bind_data)
257257
}
258258
EXPORT_SYMBOL(module_adapter_bind);
259259

260-
int module_adapter_unbind(struct comp_dev *dev, struct bind_info *unbind_data)
260+
int module_adapter_unbind(struct comp_dev *dev, void *data)
261261
{
262262
struct processing_module *mod = comp_mod(dev);
263263
int ret;
264264

265-
ret = module_unbind(mod, unbind_data);
265+
ret = module_unbind(mod, data);
266266
if (ret < 0)
267267
return ret;
268268

0 commit comments

Comments
 (0)