-
Notifications
You must be signed in to change notification settings - Fork 358
schedule: allocate the scheduler objects with sof_heap_alloc() #10821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,15 +47,20 @@ int schedule_task_init(struct task *task, | |
| static void scheduler_register(struct schedule_data *scheduler) | ||
| { | ||
| struct schedulers **sch = arch_schedulers_get(); | ||
| struct k_heap *heap = NULL; | ||
|
|
||
| #ifdef CONFIG_SOF_USERSPACE_LL | ||
| heap = sof_sys_user_heap_get(); | ||
| #endif | ||
|
|
||
| if (!*sch) { | ||
| /* init schedulers list */ | ||
| *sch = rzalloc(SOF_MEM_FLAG_KERNEL, | ||
| sizeof(**sch)); | ||
| *sch = sof_heap_alloc(heap, 0, sizeof(**sch), 0); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this would mean, that userspace code now effectively has access to all schedulers, also kernel ones
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ack. This does leave a gap with EDF currently, so this is not safe yet for production use. So in short, generic scheduler logic (Zephyr scheduling) in kernel, audio task scheduling in user-space (if SOF built for LL userspace). |
||
| if (!*sch) { | ||
| tr_err(&sch_tr, "allocation failed"); | ||
| return; | ||
| } | ||
| memset(*sch, 0, sizeof(**sch)); | ||
| list_init(&(*sch)->list); | ||
| } | ||
|
|
||
|
|
@@ -65,16 +70,22 @@ static void scheduler_register(struct schedule_data *scheduler) | |
| void scheduler_init(int type, const struct scheduler_ops *ops, void *data) | ||
| { | ||
| struct schedule_data *sch; | ||
| struct k_heap *heap = NULL; | ||
|
|
||
| #ifdef CONFIG_SOF_USERSPACE_LL | ||
| heap = sof_sys_user_heap_get(); | ||
| #endif | ||
|
|
||
| if (!ops || !ops->schedule_task || !ops->schedule_task_cancel || | ||
| !ops->schedule_task_free) | ||
| return; | ||
|
|
||
| sch = rzalloc(SOF_MEM_FLAG_KERNEL, sizeof(*sch)); | ||
| sch = sof_heap_alloc(heap, 0, sizeof(*sch), 0); | ||
| if (!sch) { | ||
| tr_err(&sch_tr, "allocation failed"); | ||
| sof_panic(SOF_IPC_PANIC_IPC); | ||
| } | ||
| memset(sch, 0, sizeof(*sch)); | ||
| list_init(&sch->list); | ||
| sch->type = type; | ||
| sch->ops = ops; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats the split between kernel/user memory for scheduler APIs for LL user ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lgirdwood The idea here is the audio schedulers (i.e. SOF schedule.h) are owned by the system LL thread (that can be now in user-space). This means we move other audio schedulers (DP, EDF) also to user-space. Only initial setup (and cleanup) is done from kernel.