@@ -363,17 +363,7 @@ static int zephyr_ll_task_schedule_common(struct zephyr_ll *sch, struct task *ta
363363
364364 ret = domain_register (sch -> ll_domain , task , & schedule_ll_callback , sch );
365365 if (ret < 0 )
366- tr_err (& ll_tr , "cannot register domain %d" ,
367- ret );
368-
369- #if CONFIG_SOF_USERSPACE_LL
370- k_thread_access_grant (zephyr_domain_thread_tid (sch -> ll_domain ), sch -> lock );
371-
372- tr_dbg (& ll_tr , "granting access to lock %p for thread %p" , sch -> lock ,
373- zephyr_domain_thread_tid (sch -> ll_domain ));
374- tr_dbg (& ll_tr , "granting access to domain lock %p for thread %p" , & sch -> ll_domain -> lock ,
375- zephyr_domain_thread_tid (sch -> ll_domain ));
376- #endif
366+ tr_err (& ll_tr , "cannot register domain %d" , ret );
377367
378368 return 0 ;
379369}
@@ -518,13 +508,49 @@ static void zephyr_ll_scheduler_free(void *data, uint32_t flags)
518508 sch -> n_tasks );
519509}
520510
511+ #if CONFIG_SOF_USERSPACE_LL
512+ struct k_thread * zephyr_ll_init_context (void * data , struct task * task )
513+ {
514+ struct zephyr_ll * sch = data ;
515+ int ret ;
516+
517+ ret = domain_register (sch -> ll_domain , task , & schedule_ll_callback , sch );
518+ if (ret < 0 ) {
519+ tr_err (& ll_tr , "cannot init_context %d" , ret );
520+ return NULL ;
521+ }
522+
523+ if (!k_is_user_context ()) {
524+ k_thread_access_grant (zephyr_domain_thread_tid (sch -> ll_domain ), sch -> lock );
525+
526+ tr_dbg (& ll_tr , "granting access to lock %p for thread %p" , sch -> lock ,
527+ zephyr_domain_thread_tid (sch -> ll_domain ));
528+ tr_dbg (& ll_tr , "granting access to domain lock %p for thread %p" , & sch -> ll_domain -> lock ,
529+ zephyr_domain_thread_tid (sch -> ll_domain ));
530+ }
531+
532+ return zephyr_domain_thread_tid (sch -> ll_domain );
533+ }
534+
535+ void zephyr_ll_free_context (void * data )
536+ {
537+ struct zephyr_ll * sch = data ;
538+
539+ (void * )sch ;
540+ }
541+ #endif
542+
521543static const struct scheduler_ops zephyr_ll_ops = {
522544 .schedule_task = zephyr_ll_task_schedule ,
523545 .schedule_task_before = zephyr_ll_task_schedule_before ,
524546 .schedule_task_after = zephyr_ll_task_schedule_after ,
525547 .schedule_task_free = zephyr_ll_task_sched_free ,
526548 .schedule_task_cancel = zephyr_ll_task_cancel ,
527549 .scheduler_free = zephyr_ll_scheduler_free ,
550+ #if CONFIG_SOF_USERSPACE_LL
551+ .scheduler_init_context = zephyr_ll_init_context ,
552+ .scheduler_free_context = zephyr_ll_free_context ,
553+ #endif
528554};
529555
530556#if CONFIG_SOF_USERSPACE_LL
0 commit comments