2727LOG_MODULE_DECLARE (dp_schedule , CONFIG_SOF_LOG_LEVEL );
2828extern struct tr_ctx dp_tr ;
2929
30- #if CONFIG_USERSPACE
3130static 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 */
203201void 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 */
388386void 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 */
402399int 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
558544e_dom :
559545 scheduler_dp_domain_free (mod );
560- #endif
561546e_thread :
562547 k_thread_abort (pdata -> thread_id );
563- #ifdef CONFIG_USERSPACE
564548e_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
569552e_stack :
570553 user_stack_free (p_stack );
571554e_tmem :
0 commit comments