-
Notifications
You must be signed in to change notification settings - Fork 364
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 |
|---|---|---|
|
|
@@ -22,12 +22,23 @@ SOF_DEFINE_REG_UUID(schedule); | |
|
|
||
| DECLARE_TR_CTX(sch_tr, SOF_UUID(schedule_uuid), LOG_LEVEL_INFO); | ||
|
|
||
| static inline bool scheduler_is_user(int type) | ||
| { | ||
| /* | ||
| * currently only LL managed in user-space, but longterm | ||
| * goal is to move all audio application level scheduling | ||
| * to user-space and only keep Zephyr scheduler logic in | ||
| * kernel | ||
| */ | ||
| return type == SOF_SCHEDULE_LL_TIMER; | ||
| } | ||
|
|
||
| int schedule_task_init(struct task *task, | ||
| const struct sof_uuid_entry *uid, uint16_t type, | ||
| uint16_t priority, enum task_state (*run)(void *data), | ||
| void *data, uint16_t core, uint32_t flags) | ||
| { | ||
| struct schedulers *schedulers = *arch_schedulers_get(); | ||
| struct schedulers *schedulers; | ||
| struct schedule_data *sch = NULL; | ||
| struct list_item *slist; | ||
|
|
||
|
|
@@ -36,6 +47,11 @@ int schedule_task_init(struct task *task, | |
| return -EINVAL; | ||
| } | ||
|
|
||
| if (IS_ENABLED(CONFIG_SOF_USERSPACE_LL) && scheduler_is_user(type)) | ||
| schedulers = *arch_user_schedulers_get_for_core(core); | ||
| else | ||
| schedulers = *arch_schedulers_get(); | ||
|
|
||
| if (!schedulers) | ||
| return -ENODEV; | ||
|
|
||
|
|
@@ -68,15 +84,21 @@ 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; | ||
|
|
||
| if (IS_ENABLED(CONFIG_SOF_USERSPACE_LL) && scheduler_is_user(scheduler->type)) { | ||
| sch = arch_user_schedulers_get(); | ||
| heap = sof_sys_user_heap_get(); | ||
| } | ||
|
|
||
| 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); | ||
| } | ||
|
|
||
|
|
@@ -86,16 +108,21 @@ 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; | ||
|
|
||
| if (IS_ENABLED(CONFIG_SOF_USERSPACE_LL) && scheduler_is_user(type)) | ||
| heap = sof_sys_user_heap_get(); | ||
|
|
||
| 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, SOF_MEM_FLAG_KERNEL, 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.
...at some point would be good to have all these converted to
just to reduce the number of arrows that we carry around