Skip to content

Commit bf26fc1

Browse files
committed
dp: application: remove unused userspace checks
The application mode DP implementation always runs in userspace, remove all the redundant checks and the unused semaphore structure. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
1 parent c29d2dd commit bf26fc1

File tree

3 files changed

+15
-34
lines changed

3 files changed

+15
-34
lines changed

src/schedule/zephyr_dp_schedule.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,7 @@ static int scheduler_dp_task_free(void *data, struct task *task)
300300
if (pdata->event != &pdata->event_struct)
301301
k_object_free(pdata->event);
302302
#else
303-
if (pdata->sem != &pdata->sem_struct)
304-
k_object_free(pdata->sem);
303+
k_object_free(pdata->sem);
305304
#endif
306305
if (pdata->thread != &pdata->thread_struct)
307306
k_object_free(pdata->thread);

src/schedule/zephyr_dp_schedule.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ struct task_dp_pdata {
4040
uint32_t ll_cycles_to_start; /* current number of LL cycles till delayed start */
4141
#if CONFIG_SOF_USERSPACE_APPLICATION
4242
struct k_sem *sem; /* pointer to semaphore for task scheduling */
43-
struct k_sem sem_struct; /* semaphore for task scheduling for kernel threads */
4443
struct ipc4_flat *flat;
4544
unsigned char pend_ipc;
4645
unsigned char pend_proc;

src/schedule/zephyr_dp_schedule_application.c

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
LOG_MODULE_DECLARE(dp_schedule, CONFIG_SOF_LOG_LEVEL);
2828
extern struct tr_ctx dp_tr;
2929

30-
#if CONFIG_USERSPACE
3130
static struct k_mem_domain dp_mdom[CONFIG_CORE_COUNT];
32-
#endif
3331

3432
/* Synchronization semaphore for the scheduler thread to wait for DP startup */
3533
#define DP_SYNC_INIT(i, _) Z_SEM_INITIALIZER(dp_sync[i], 0, 1)
@@ -198,7 +196,7 @@ int scheduler_dp_thread_ipc(struct processing_module *pmod, unsigned int cmd,
198196
}
199197

200198
/* Go through all DP tasks and recalculate their readiness and deadlines
201-
* NOT REENTRANT, should be called with scheduler_dp_lock()
199+
* NOT REENTRANT, called with scheduler_dp_lock() held
202200
*/
203201
void scheduler_dp_recalculate(struct scheduler_dp_data *dp_sch, bool is_ll_post_run)
204202
{
@@ -387,7 +385,6 @@ void dp_thread_fn(void *p1, void *p2, void *p3)
387385
*/
388386
void scheduler_dp_domain_free(struct processing_module *pmod)
389387
{
390-
#if CONFIG_USERSPACE
391388
unsigned int core = pmod->dev->task->core;
392389

393390
llext_manager_rm_domain(pmod->dev->ipc_config.id, dp_mdom + core);
@@ -396,9 +393,9 @@ void scheduler_dp_domain_free(struct processing_module *pmod)
396393

397394
k_mem_domain_remove_partition(dp_mdom + core, pdata->mpart + SOF_DP_PART_HEAP);
398395
k_mem_domain_remove_partition(dp_mdom + core, pdata->mpart + SOF_DP_PART_CFG);
399-
#endif
400396
}
401397

398+
/* Called only in IPC context */
402399
int scheduler_dp_task_init(struct task **task, const struct sof_uuid_entry *uid,
403400
const struct task_ops *ops, struct processing_module *mod,
404401
uint16_t core, size_t stack_size, uint32_t options)
@@ -455,30 +452,22 @@ int scheduler_dp_task_init(struct task **task, const struct sof_uuid_entry *uid,
455452

456453
struct task_dp_pdata *pdata = &task_memory->pdata;
457454

458-
/* Point to event_struct event for kernel threads synchronization */
459-
/* It will be overwritten for K_USER threads to dynamic ones. */
460-
pdata->sem = &pdata->sem_struct;
461-
pdata->thread = &pdata->thread_struct;
462455
pdata->flat = &task_memory->flat;
463456

464-
#ifdef CONFIG_USERSPACE
465-
if (options & K_USER) {
466-
pdata->sem = k_object_alloc(K_OBJ_SEM);
467-
if (!pdata->sem) {
468-
tr_err(&dp_tr, "Event object allocation failed");
469-
ret = -ENOMEM;
470-
goto e_stack;
471-
}
457+
pdata->sem = k_object_alloc(K_OBJ_SEM);
458+
if (!pdata->sem) {
459+
tr_err(&dp_tr, "Event object allocation failed");
460+
ret = -ENOMEM;
461+
goto e_stack;
462+
}
472463

473-
pdata->thread = k_object_alloc(K_OBJ_THREAD);
474-
if (!pdata->thread) {
475-
tr_err(&dp_tr, "Thread object allocation failed");
476-
ret = -ENOMEM;
477-
goto e_kobj;
478-
}
479-
memset(&pdata->thread->arch, 0, sizeof(pdata->thread->arch));
464+
pdata->thread = k_object_alloc(K_OBJ_THREAD);
465+
if (!pdata->thread) {
466+
tr_err(&dp_tr, "Thread object allocation failed");
467+
ret = -ENOMEM;
468+
goto e_kobj;
480469
}
481-
#endif /* CONFIG_USERSPACE */
470+
memset(&pdata->thread->arch, 0, sizeof(pdata->thread->arch));
482471

483472
/* success, fill the structures */
484473
pdata->p_stack = p_stack;
@@ -503,7 +492,6 @@ int scheduler_dp_task_init(struct task **task, const struct sof_uuid_entry *uid,
503492
goto e_thread;
504493
}
505494

506-
#if CONFIG_USERSPACE
507495
k_thread_access_grant(pdata->thread_id, pdata->sem, &dp_sync[core]);
508496
scheduler_dp_grant(pdata->thread_id, core);
509497

@@ -546,26 +534,21 @@ int scheduler_dp_task_init(struct task **task, const struct sof_uuid_entry *uid,
546534
tr_err(&dp_tr, "failed to add thread to domain %d", ret);
547535
goto e_dom;
548536
}
549-
#endif /* CONFIG_USERSPACE */
550537

551538
/* start the thread, it should immediately stop at the semaphore */
552539
k_sem_init(pdata->sem, 0, 1);
553540
k_thread_start(pdata->thread_id);
554541

555542
return 0;
556543

557-
#ifdef CONFIG_USERSPACE
558544
e_dom:
559545
scheduler_dp_domain_free(mod);
560-
#endif
561546
e_thread:
562547
k_thread_abort(pdata->thread_id);
563-
#ifdef CONFIG_USERSPACE
564548
e_kobj:
565549
/* k_object_free looks for a pointer in the list, any invalid value can be passed */
566550
k_object_free(pdata->thread);
567551
k_object_free(pdata->sem);
568-
#endif
569552
e_stack:
570553
user_stack_free(p_stack);
571554
e_tmem:

0 commit comments

Comments
 (0)