Skip to content

Commit 61d6919

Browse files
committed
use RTIO to signal DP audio and IPCs
We should be able to run DP threads in user-space mode, for this we need to move audio and IPC signalling to RTIO. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent eee93fe commit 61d6919

9 files changed

Lines changed: 442 additions & 75 deletions

File tree

app/boards/intel_adsp_ace15_mtpm.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ CONFIG_WATCHDOG=y
8383
CONFIG_TIMESLICE_PER_THREAD=y
8484
CONFIG_THREAD_RUNTIME_STATS=y
8585
CONFIG_SCHED_THREAD_USAGE=y
86+
CONFIG_RTIO=y
8687

8788
# Zephyr / device drivers
8889
CONFIG_CLOCK_CONTROL=y

app/boards/intel_adsp_ace20_lnl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ CONFIG_LLEXT_STORAGE_WRITABLE=y
6363
CONFIG_LLEXT_EXPERIMENTAL=y
6464
CONFIG_MODULES=y
6565
CONFIG_TIMING_FUNCTIONS=y
66+
CONFIG_RTIO=y
6667

6768
# Zephyr / device drivers
6869
CONFIG_CLOCK_CONTROL=y

app/boards/intel_adsp_ace30_ptl.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ CONFIG_LLEXT=y
6363
CONFIG_LLEXT_STORAGE_WRITABLE=y
6464
CONFIG_LLEXT_EXPERIMENTAL=y
6565
CONFIG_MODULES=y
66+
CONFIG_RTIO=y
6667

6768
# Zephyr / device drivers
6869
CONFIG_CLOCK_CONTROL=y

src/audio/module_adapter/module/generic.c

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
*/
1313

1414
#include <rtos/symbol.h>
15-
1615
#include <sof/audio/module_adapter/module/generic.h>
16+
#include <sof/schedule/dp_schedule.h>
1717

1818
LOG_MODULE_DECLARE(module_adapter, CONFIG_SOF_LOG_LEVEL);
1919

@@ -95,7 +95,11 @@ int module_init(struct processing_module *mod)
9595
list_init(&md->memory.mem_list);
9696

9797
/* Now we can proceed with module specific initialization */
98-
ret = interface->init(mod);
98+
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP)
99+
ret = scheduler_dp_rtio_ipc(mod, SOF_IPC4_MOD_INIT_INSTANCE, NULL);
100+
else
101+
ret = interface->init(mod);
102+
99103
if (ret) {
100104
comp_err(dev, "module_init() error %d: module specific init failed, comp id %d",
101105
ret, dev_comp_id(dev));
@@ -242,7 +246,23 @@ int module_prepare(struct processing_module *mod,
242246
return -EPERM;
243247
#endif
244248
if (ops->prepare) {
245-
int ret = ops->prepare(mod, sources, num_of_sources, sinks, num_of_sinks);
249+
int ret;
250+
251+
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
252+
union scheduler_dp_rtio_ipc_param param = {
253+
.pipeline_state = {
254+
.trigger_cmd = COMP_TRIGGER_PREPARE,
255+
.state = SOF_IPC4_PIPELINE_STATE_RUNNING,
256+
.n_sources = num_of_sources,
257+
.sources = sources,
258+
.n_sinks = num_of_sinks,
259+
.sinks = sinks,
260+
},
261+
};
262+
ret = scheduler_dp_rtio_ipc(mod, SOF_IPC4_GLB_SET_PIPELINE_STATE, &param);
263+
} else {
264+
ret = ops->prepare(mod, sources, num_of_sources, sinks, num_of_sinks);
265+
}
246266

247267
if (ret) {
248268
comp_err(dev, "module_prepare() error %d: module specific prepare failed, comp_id %d",
@@ -366,11 +386,17 @@ int module_reset(struct processing_module *mod)
366386
if (md->state < MODULE_IDLE)
367387
return 0;
368388
#endif
369-
/* cancel task if DP task*/
370-
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP && mod->dev->task)
371-
schedule_task_cancel(mod->dev->task);
389+
372390
if (ops->reset) {
373-
ret = ops->reset(mod);
391+
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
392+
union scheduler_dp_rtio_ipc_param param = {
393+
.pipeline_state.trigger_cmd = COMP_TRIGGER_STOP,
394+
};
395+
ret = scheduler_dp_rtio_ipc(mod, SOF_IPC4_GLB_SET_PIPELINE_STATE, &param);
396+
} else {
397+
ret = ops->reset(mod);
398+
}
399+
374400
if (ret) {
375401
if (ret != PPL_STATUS_PATH_STOP)
376402
comp_err(mod->dev,
@@ -423,7 +449,7 @@ int module_free(struct processing_module *mod)
423449
struct module_data *md = &mod->priv;
424450
int ret = 0;
425451

426-
if (ops->free) {
452+
if (ops->free && mod->dev->ipc_config.proc_domain != COMP_PROCESSING_DOMAIN_DP) {
427453
ret = ops->free(mod);
428454
if (ret)
429455
comp_warn(mod->dev, "error: %d for %d",
@@ -570,8 +596,16 @@ int module_bind(struct processing_module *mod, struct bind_info *bind_data)
570596
if (ret)
571597
return ret;
572598

573-
if (ops->bind)
574-
ret = ops->bind(mod, bind_data);
599+
if (ops->bind) {
600+
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
601+
union scheduler_dp_rtio_ipc_param param = {
602+
.bind_data = bind_data,
603+
};
604+
ret = scheduler_dp_rtio_ipc(mod, SOF_IPC4_MOD_BIND, &param);
605+
} else {
606+
ret = ops->bind(mod, bind_data);
607+
}
608+
}
575609

576610
return ret;
577611
}

src/audio/module_adapter/module_adapter.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <sof/audio/source_api.h>
1919
#include <sof/audio/audio_buffer.h>
2020
#include <sof/audio/pipeline.h>
21+
#include <sof/schedule/dp_schedule.h>
2122
#include <sof/schedule/ll_schedule_domain.h>
2223
#include <sof/common.h>
2324
#include <sof/platform.h>
@@ -1207,8 +1208,17 @@ int module_adapter_trigger(struct comp_dev *dev, int cmd)
12071208
dev->state = COMP_STATE_ACTIVE;
12081209
return PPL_STATUS_PATH_STOP;
12091210
}
1210-
if (interface->trigger)
1211+
1212+
if (interface->trigger) {
1213+
if (dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
1214+
/* Process DP module's trigger */
1215+
union scheduler_dp_rtio_ipc_param param = {
1216+
.pipeline_state.trigger_cmd = cmd,
1217+
};
1218+
return scheduler_dp_rtio_ipc(mod, SOF_IPC4_GLB_SET_PIPELINE_STATE, &param);
1219+
}
12111220
return interface->trigger(mod, cmd);
1221+
}
12121222

12131223
return module_adapter_set_state(mod, dev, cmd);
12141224
}
@@ -1270,8 +1280,11 @@ void module_adapter_free(struct comp_dev *dev)
12701280

12711281
comp_dbg(dev, "start");
12721282

1273-
if (dev->task)
1283+
if (dev->task) {
1284+
/* Run DP module's .free() method in its thread context */
1285+
scheduler_dp_rtio_ipc(mod, SOF_IPC4_MOD_DELETE_INSTANCE, NULL);
12741286
schedule_task_cancel(dev->task);
1287+
}
12751288

12761289
ret = module_free(mod);
12771290
if (ret)

src/include/module/module/base.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ enum module_processing_type {
7070
MODULE_PROCESS_TYPE_RAW,
7171
};
7272

73+
struct rtio_sqe;
74+
7375
/*
7476
* A pointer to this structure is passed to module API functions (from struct module_interface).
7577
* This structure should contain only fields that should be available to a module.
@@ -103,6 +105,10 @@ struct processing_module {
103105
uint32_t num_of_sources;
104106
uint32_t num_of_sinks;
105107

108+
/* DP module RTIO SQE pointers, used to signal module's DP thread */
109+
struct rtio_sqe *ipc_sqe;
110+
struct rtio_sqe *audio_sqe;
111+
106112
/* sink and source handlers for the module */
107113
struct sof_sink *sinks[CONFIG_MODULE_MAX_CONNECTIONS];
108114
struct sof_source *sources[CONFIG_MODULE_MAX_CONNECTIONS];

src/include/sof/audio/component_ext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ static inline void comp_free(struct comp_dev *dev)
4646
{
4747
assert(dev->drv->ops.free);
4848

49+
dev->drv->ops.free(dev);
50+
4951
/* free task if shared component or DP task*/
5052
if ((dev->is_shared || dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) &&
5153
dev->task) {
5254
schedule_task_free(dev->task);
5355
rfree(dev->task);
5456
dev->task = NULL;
5557
}
56-
57-
dev->drv->ops.free(dev);
5858
}
5959

6060
/**

src/include/sof/schedule/dp_schedule.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <user/trace.h>
1414
#include <stdint.h>
1515
#include <ipc4/base_fw.h>
16+
#include <ipc4/pipeline.h>
1617

1718
struct processing_module;
1819

@@ -84,4 +85,22 @@ int scheduler_dp_task_init(struct task **task,
8485
void scheduler_get_task_info_dp(struct scheduler_props *scheduler_props,
8586
uint32_t *data_off_size);
8687

88+
struct bind_info;
89+
struct sof_source;
90+
struct sof_sink;
91+
union scheduler_dp_rtio_ipc_param {
92+
struct bind_info *bind_data;
93+
struct {
94+
unsigned int trigger_cmd;
95+
enum ipc4_pipeline_state state;
96+
int n_sources;
97+
struct sof_source **sources;
98+
int n_sinks;
99+
struct sof_sink **sinks;
100+
} pipeline_state;
101+
};
102+
103+
int scheduler_dp_rtio_ipc(struct processing_module *pmod, enum sof_ipc4_module_type cmd,
104+
union scheduler_dp_rtio_ipc_param *param);
105+
87106
#endif /* __SOF_SCHEDULE_DP_SCHEDULE_H__ */

0 commit comments

Comments
 (0)