@@ -198,6 +198,10 @@ struct schedulers {
198198 */
199199struct schedulers * * arch_schedulers_get (void );
200200
201+ #if CONFIG_SOF_USERSPACE_LL
202+ struct schedulers * * arch_schedulers_get_for_core (int core );
203+ #endif
204+
201205/**
202206 * Retrieves scheduler's data.
203207 * @param type SOF_SCHEDULE_ type.
@@ -218,10 +222,39 @@ static inline void *scheduler_get_data(uint16_t type)
218222 return NULL ;
219223}
220224
225+ #if CONFIG_SOF_USERSPACE_LL
226+ /**
227+ * Retrieves scheduler's data for a specific core.
228+ * @param type SOF_SCHEDULE_ type.
229+ * @param core Core ID to get scheduler data for.
230+ * @return Pointer to scheduler's data.
231+ *
232+ * Safe to call from user-space context — does not use cpu_get_id().
233+ */
234+ static inline void * scheduler_get_data_for_core (uint16_t type , int core )
235+ {
236+ struct schedulers * schedulers = * arch_schedulers_get_for_core (core );
237+ struct schedule_data * sch ;
238+ struct list_item * slist ;
239+
240+ list_for_item (slist , & schedulers -> list ) {
241+ sch = container_of (slist , struct schedule_data , list );
242+ if (type == sch -> type )
243+ return sch -> data ;
244+ }
245+
246+ return NULL ;
247+ }
248+ #endif
249+
221250/** See scheduler_ops::schedule_task_running */
222251static inline int schedule_task_running (struct task * task )
223252{
253+ #if CONFIG_SOF_USERSPACE_LL
254+ struct schedulers * schedulers = * arch_schedulers_get_for_core (task -> core );
255+ #else
224256 struct schedulers * schedulers = * arch_schedulers_get ();
257+ #endif
225258 struct schedule_data * sch ;
226259 struct list_item * slist ;
227260
@@ -243,7 +276,11 @@ static inline int schedule_task_running(struct task *task)
243276static inline int schedule_task (struct task * task , uint64_t start ,
244277 uint64_t period )
245278{
279+ #if CONFIG_SOF_USERSPACE_LL
280+ struct schedulers * schedulers = * arch_schedulers_get_for_core (task -> core );
281+ #else
246282 struct schedulers * schedulers = * arch_schedulers_get ();
283+ #endif
247284 struct schedule_data * sch ;
248285 struct list_item * slist ;
249286
@@ -264,7 +301,11 @@ static inline int schedule_task(struct task *task, uint64_t start,
264301static inline int schedule_task_before (struct task * task , uint64_t start ,
265302 uint64_t period , struct task * before )
266303{
304+ #if CONFIG_SOF_USERSPACE_LL
305+ struct schedulers * schedulers = * arch_schedulers_get_for_core (task -> core );
306+ #else
267307 struct schedulers * schedulers = * arch_schedulers_get ();
308+ #endif
268309 struct schedule_data * sch ;
269310 struct list_item * slist ;
270311
@@ -290,7 +331,11 @@ static inline int schedule_task_before(struct task *task, uint64_t start,
290331static inline int schedule_task_after (struct task * task , uint64_t start ,
291332 uint64_t period , struct task * after )
292333{
334+ #if CONFIG_SOF_USERSPACE_LL
335+ struct schedulers * schedulers = * arch_schedulers_get_for_core (task -> core );
336+ #else
293337 struct schedulers * schedulers = * arch_schedulers_get ();
338+ #endif
294339 struct schedule_data * sch ;
295340 struct list_item * slist ;
296341
@@ -315,7 +360,11 @@ static inline int schedule_task_after(struct task *task, uint64_t start,
315360/** See scheduler_ops::reschedule_task */
316361static inline int reschedule_task (struct task * task , uint64_t start )
317362{
363+ #if CONFIG_SOF_USERSPACE_LL
364+ struct schedulers * schedulers = * arch_schedulers_get_for_core (task -> core );
365+ #else
318366 struct schedulers * schedulers = * arch_schedulers_get ();
367+ #endif
319368 struct schedule_data * sch ;
320369 struct list_item * slist ;
321370
@@ -337,7 +386,11 @@ static inline int reschedule_task(struct task *task, uint64_t start)
337386/** See scheduler_ops::schedule_task_cancel */
338387static inline int schedule_task_cancel (struct task * task )
339388{
389+ #if CONFIG_SOF_USERSPACE_LL
390+ struct schedulers * schedulers = * arch_schedulers_get_for_core (task -> core );
391+ #else
340392 struct schedulers * schedulers = * arch_schedulers_get ();
393+ #endif
341394 struct schedule_data * sch ;
342395 struct list_item * slist ;
343396
@@ -353,7 +406,11 @@ static inline int schedule_task_cancel(struct task *task)
353406/** See scheduler_ops::schedule_task_free */
354407static inline int schedule_task_free (struct task * task )
355408{
409+ #if CONFIG_SOF_USERSPACE_LL
410+ struct schedulers * schedulers = * arch_schedulers_get_for_core (task -> core );
411+ #else
356412 struct schedulers * schedulers = * arch_schedulers_get ();
413+ #endif
357414 struct schedule_data * sch ;
358415 struct list_item * slist ;
359416
@@ -402,7 +459,11 @@ static inline int schedulers_restore(void)
402459/** See scheduler_ops::scheduler_init_context */
403460static inline struct k_thread * scheduler_init_context (struct task * task )
404461{
462+ #if CONFIG_SOF_USERSPACE_LL
463+ struct schedulers * schedulers = * arch_schedulers_get_for_core (task -> core );
464+ #else
405465 struct schedulers * schedulers = * arch_schedulers_get ();
466+ #endif
406467 struct schedule_data * sch ;
407468 struct list_item * slist ;
408469
0 commit comments