Skip to content

Commit cb35122

Browse files
committed
userspace: dp: add a Kconfig option to simplify conditionals
Add an automatic (non-user selectable) Kconfig option to enable the "application variant" of the DP userspace implementation. Effectively it replaces (CONFIG_USERSPACE && !CONFIG_SOF_USERSPACE_PROXY) with a single new option. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent ee15b8c commit cb35122

File tree

6 files changed

+34
-27
lines changed

6 files changed

+34
-27
lines changed

src/audio/module_adapter/module/generic.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ int module_init(struct processing_module *mod)
120120
mod->priv.resources.rsrc_mngr = k_current_get();
121121
#endif
122122
/* Now we can proceed with module specific initialization */
123-
#if CONFIG_USERSPACE && !CONFIG_SOF_USERSPACE_PROXY
123+
#if CONFIG_SOF_USERSPACE_APPLICATION
124124
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP)
125125
ret = scheduler_dp_thread_ipc(mod, SOF_IPC4_MOD_INIT_INSTANCE, NULL);
126126
else
@@ -501,7 +501,7 @@ int module_prepare(struct processing_module *mod,
501501
if (ops->prepare) {
502502
int ret;
503503

504-
#if CONFIG_USERSPACE && !CONFIG_SOF_USERSPACE_PROXY
504+
#if CONFIG_SOF_USERSPACE_APPLICATION
505505
if (dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
506506
const union scheduler_dp_thread_ipc_param param = {
507507
.pipeline_state = {
@@ -638,11 +638,11 @@ int module_reset(struct processing_module *mod)
638638

639639
/* cancel task if DP task*/
640640
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP && mod->dev->task &&
641-
(IS_ENABLED(CONFIG_SOF_USERSPACE_PROXY) || !IS_ENABLED(CONFIG_USERSPACE)))
641+
!IS_ENABLED(CONFIG_SOF_USERSPACE_APPLICATION))
642642
schedule_task_cancel(mod->dev->task);
643643

644644
if (ops->reset) {
645-
#if CONFIG_USERSPACE && !CONFIG_SOF_USERSPACE_PROXY
645+
#if CONFIG_SOF_USERSPACE_APPLICATION
646646
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
647647
const union scheduler_dp_thread_ipc_param param = {
648648
.pipeline_state.trigger_cmd = COMP_TRIGGER_STOP,
@@ -723,7 +723,7 @@ int module_free(struct processing_module *mod)
723723
int ret = 0;
724724

725725
if (ops->free && (mod->dev->ipc_config.proc_domain != COMP_PROCESSING_DOMAIN_DP ||
726-
IS_ENABLED(CONFIG_SOF_USERSPACE_PROXY) || !IS_ENABLED(CONFIG_USERSPACE))) {
726+
!IS_ENABLED(CONFIG_SOF_USERSPACE_APPLICATION))) {
727727
ret = ops->free(mod);
728728
if (ret)
729729
comp_warn(mod->dev, "error: %d", ret);
@@ -869,7 +869,7 @@ int module_bind(struct processing_module *mod, struct bind_info *bind_data)
869869
return ret;
870870

871871
if (ops->bind) {
872-
#if CONFIG_USERSPACE && !CONFIG_SOF_USERSPACE_PROXY
872+
#if CONFIG_SOF_USERSPACE_APPLICATION
873873
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
874874
const union scheduler_dp_thread_ipc_param param = {
875875
.bind_data = bind_data,
@@ -902,7 +902,7 @@ int module_unbind(struct processing_module *mod, struct bind_info *unbind_data)
902902
return ret;
903903

904904
if (ops->unbind) {
905-
#if CONFIG_USERSPACE && !CONFIG_SOF_USERSPACE_PROXY
905+
#if CONFIG_SOF_USERSPACE_APPLICATION
906906
if (mod->dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
907907
const union scheduler_dp_thread_ipc_param param = {
908908
.bind_data = unbind_data,

src/audio/module_adapter/module_adapter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ int module_adapter_trigger(struct comp_dev *dev, int cmd)
13351335
}
13361336

13371337
if (interface->trigger) {
1338-
#if CONFIG_USERSPACE && !CONFIG_SOF_USERSPACE_PROXY
1338+
#if CONFIG_SOF_USERSPACE_APPLICATION
13391339
if (dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_DP) {
13401340
/* Process DP module's trigger */
13411341
const union scheduler_dp_thread_ipc_param param = {
@@ -1415,7 +1415,7 @@ void module_adapter_free(struct comp_dev *dev)
14151415
* thread context, then cancel the thread, and then execute
14161416
* final clean up
14171417
*/
1418-
#if CONFIG_USERSPACE && !CONFIG_SOF_USERSPACE_PROXY
1418+
#if CONFIG_SOF_USERSPACE_APPLICATION
14191419
scheduler_dp_thread_ipc(mod, SOF_IPC4_MOD_DELETE_INSTANCE, NULL);
14201420
#endif
14211421
schedule_task_free(dev->task);

src/schedule/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ else()
3838
)
3939
endif()
4040

41-
if (CONFIG_SOF_USERSPACE_PROXY OR NOT CONFIG_USERSPACE)
41+
if (CONFIG_SOF_USERSPACE_APPLICATION)
4242
zephyr_library_sources_ifdef(CONFIG_ZEPHYR_DP_SCHEDULER
4343
zephyr_dp_schedule.c
44-
zephyr_dp_schedule_thread.c
44+
zephyr_dp_schedule_application.c
4545
)
4646
else()
4747
zephyr_library_sources_ifdef(CONFIG_ZEPHYR_DP_SCHEDULER
4848
zephyr_dp_schedule.c
49-
zephyr_dp_schedule_application.c
49+
zephyr_dp_schedule_thread.c
5050
)
5151
endif()
5252

src/schedule/zephyr_dp_schedule.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ void scheduler_dp_ll_tick(void *receiver_data, enum notify_id event_type, void *
240240
scheduler_dp_unlock(lock_key);
241241
}
242242

243-
#if CONFIG_USERSPACE && !CONFIG_SOF_USERSPACE_PROXY
243+
#if CONFIG_SOF_USERSPACE_APPLICATION
244244
static int scheduler_dp_task_cancel(void *data, struct task *task)
245245
{
246246
/* Should never be called */
@@ -266,10 +266,10 @@ static int scheduler_dp_task_stop(void *data, struct task *task)
266266
schedule_task_cancel(&dp_sch->ll_tick_src);
267267

268268
/* if the task is waiting - let it run and self-terminate */
269-
#if CONFIG_SOF_USERSPACE_PROXY || !CONFIG_USERSPACE
270-
k_event_set(pdata->event, DP_TASK_EVENT_CANCEL);
271-
#else
269+
#if CONFIG_SOF_USERSPACE_APPLICATION
272270
k_sem_give(pdata->sem);
271+
#else
272+
k_event_set(pdata->event, DP_TASK_EVENT_CANCEL);
273273
#endif
274274
scheduler_dp_unlock(lock_key);
275275

@@ -350,10 +350,10 @@ static int scheduler_dp_task_shedule(void *data, struct task *task, uint64_t sta
350350

351351
static struct scheduler_ops schedule_dp_ops = {
352352
.schedule_task = scheduler_dp_task_shedule,
353-
#if CONFIG_SOF_USERSPACE_PROXY || !CONFIG_USERSPACE
354-
.schedule_task_cancel = scheduler_dp_task_stop,
355-
#else
353+
#if CONFIG_SOF_USERSPACE_APPLICATION
356354
.schedule_task_cancel = scheduler_dp_task_cancel,
355+
#else
356+
.schedule_task_cancel = scheduler_dp_task_stop,
357357
#endif
358358
.schedule_task_free = scheduler_dp_task_free,
359359
};

src/schedule/zephyr_dp_schedule.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ struct task_dp_pdata {
3838
k_thread_stack_t *p_stack; /* pointer to thread stack */
3939
struct processing_module *mod; /* the module to be scheduled */
4040
uint32_t ll_cycles_to_start; /* current number of LL cycles till delayed start */
41-
#if CONFIG_SOF_USERSPACE_PROXY || !CONFIG_USERSPACE
42-
struct k_event *event; /* pointer to event for task scheduling */
43-
struct k_event event_struct; /* event for task scheduling for kernel threads */
44-
#else
41+
#if CONFIG_SOF_USERSPACE_APPLICATION
4542
struct k_sem *sem; /* pointer to semaphore for task scheduling */
4643
struct k_sem sem_struct; /* semaphore for task scheduling for kernel threads */
4744
unsigned char pend_ipc;
4845
unsigned char pend_proc;
4946
struct k_mem_partition mpart[SOF_DP_PART_TYPE_COUNT];
47+
#else
48+
struct k_event *event; /* pointer to event for task scheduling */
49+
struct k_event event_struct; /* event for task scheduling for kernel threads */
5050
#endif
5151
};
5252

@@ -58,10 +58,10 @@ void scheduler_dp_grant(k_tid_t thread_id, uint16_t core);
5858
int scheduler_dp_task_init(struct task **task, const struct sof_uuid_entry *uid,
5959
const struct task_ops *ops, struct processing_module *mod,
6060
uint16_t core, size_t stack_size, uint32_t options);
61-
#if CONFIG_SOF_USERSPACE_PROXY || !CONFIG_USERSPACE
62-
static inline void scheduler_dp_domain_free(struct processing_module *pmod) {}
63-
static inline int scheduler_dp_domain_init(void) {return 0;}
64-
#else
61+
#if CONFIG_SOF_USERSPACE_APPLICATION
6562
void scheduler_dp_domain_free(struct processing_module *pmod);
6663
int scheduler_dp_domain_init(void);
64+
#else
65+
static inline void scheduler_dp_domain_free(struct processing_module *pmod) {}
66+
static inline int scheduler_dp_domain_init(void) {return 0;}
6767
#endif

zephyr/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ config SOF_USERSPACE_PROXY
113113
It is responsible for forwarding module function calls coming from sof running in
114114
kernelspace to the module code executed with user privileges.
115115

116+
config SOF_USERSPACE_APPLICATION
117+
bool
118+
default USERSPACE && !SOF_USERSPACE_PROXY
119+
help
120+
Not manually settable. This is effectively a shortcut to replace numerous
121+
checks for (CONFIG_USERSPACE && !CONFIG_SOF_USERSPACE_PROXY)
122+
116123
config ZEPHYR_NATIVE_DRIVERS
117124
bool "Use Zephyr native drivers"
118125
help

0 commit comments

Comments
 (0)