-
Notifications
You must be signed in to change notification settings - Fork 350
schedule: add support for user-space LL scheduler #10508
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
151f8af
bc6e416
9a465e5
9ecca3b
e57df1a
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 |
|---|---|---|
|
|
@@ -53,6 +53,11 @@ int zephyr_ll_task_init(struct task *task, | |
| #define scheduler_init_ll zephyr_ll_scheduler_init | ||
| #define schedule_task_init_ll zephyr_ll_task_init | ||
|
|
||
| struct task *zephyr_ll_task_alloc(void); | ||
| k_tid_t zephyr_ll_get_thread(int core); | ||
|
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. nitpick: I think we use |
||
| struct k_mem_domain *zephyr_ll_mem_domain(void); | ||
| struct k_heap *zephyr_ll_heap_init(void); | ||
|
|
||
| #endif | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -66,7 +66,11 @@ struct ll_schedule_domain_ops { | |||||||||||||||||
| struct ll_schedule_domain { | ||||||||||||||||||
| uint64_t next_tick; /**< ticks just set for next run */ | ||||||||||||||||||
| uint64_t new_target_tick; /**< for the next set, used during the reschedule stage */ | ||||||||||||||||||
| struct k_spinlock lock; /**< standard lock */ | ||||||||||||||||||
| #if defined(__ZEPHYR__) | ||||||||||||||||||
| struct k_mutex *lock; /**< standard lock */ | ||||||||||||||||||
| #else | ||||||||||||||||||
| struct k_spinlock lock; /**< standard lock */ | ||||||||||||||||||
| #endif | ||||||||||||||||||
|
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. note: this change actually modifies the current behaviour already.
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 @lyakh , discussed offline and I think I'll go back a step and keep the kernel LL build using spinlocks (and/or make it a separate PR). |
||||||||||||||||||
| atomic_t total_num_tasks; /**< total number of registered tasks */ | ||||||||||||||||||
| atomic_t enabled_cores; /**< number of enabled cores */ | ||||||||||||||||||
| uint32_t ticks_per_ms; /**< number of clock ticks per ms */ | ||||||||||||||||||
|
|
@@ -93,13 +97,30 @@ static inline struct ll_schedule_domain *dma_domain_get(void) | |||||||||||||||||
| return sof_get()->platform_dma_domain; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| #if defined(__ZEPHYR__) | ||||||||||||||||||
| struct ll_schedule_domain *zephyr_ll_domain(void); | ||||||||||||||||||
| struct ll_schedule_domain *zephyr_domain_init(int clk); | ||||||||||||||||||
|
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.
|
||||||||||||||||||
| #if CONFIG_SOF_USERSPACE_LL | ||||||||||||||||||
| struct k_heap *zephyr_ll_heap(void); | ||||||||||||||||||
| struct task *zephyr_ll_task_alloc(void); | ||||||||||||||||||
| void zephyr_ll_resources_init(void); | ||||||||||||||||||
| int zephyr_ll_mem_domain_add_partition(struct k_mem_partition *partition); | ||||||||||||||||||
| int zephyr_ll_mem_domain_add_thread(k_tid_t thread); | ||||||||||||||||||
| #endif /* CONFIG_SOF_USERSPACE_LL */ | ||||||||||||||||||
| #endif | ||||||||||||||||||
|
|
||||||||||||||||||
| static inline struct ll_schedule_domain *domain_init | ||||||||||||||||||
| (int type, int clk, bool synchronous, | ||||||||||||||||||
| const struct ll_schedule_domain_ops *ops) | ||||||||||||||||||
| { | ||||||||||||||||||
| struct ll_schedule_domain *domain; | ||||||||||||||||||
|
|
||||||||||||||||||
| #if defined(__ZEPHYR__) && CONFIG_SOF_USERSPACE_LL | ||||||||||||||||||
| domain = sof_heap_alloc(zephyr_ll_heap(), SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT, | ||||||||||||||||||
| sizeof(*domain), sizeof(void *)); | ||||||||||||||||||
|
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. Missing memset |
||||||||||||||||||
| #else | ||||||||||||||||||
| domain = rzalloc(SOF_MEM_FLAG_KERNEL | SOF_MEM_FLAG_COHERENT, sizeof(*domain)); | ||||||||||||||||||
| #endif | ||||||||||||||||||
| if (!domain) | ||||||||||||||||||
| return NULL; | ||||||||||||||||||
| domain->type = type; | ||||||||||||||||||
|
|
@@ -116,7 +137,23 @@ static inline struct ll_schedule_domain *domain_init | |||||||||||||||||
| domain->next_tick = UINT64_MAX; | ||||||||||||||||||
| domain->new_target_tick = UINT64_MAX; | ||||||||||||||||||
|
|
||||||||||||||||||
| #if defined(__ZEPHYR__) | ||||||||||||||||||
|
|
||||||||||||||||||
| #if defined(CONFIG_SOF_USERSPACE_LL) | ||||||||||||||||||
| /* Allocate mutex dynamically for userspace access */ | ||||||||||||||||||
| domain->lock = k_object_alloc(K_OBJ_MUTEX); | ||||||||||||||||||
|
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. I think this allocates cached? |
||||||||||||||||||
| #else /* !CONFIG_SOF_USERSPACE_LL */ | ||||||||||||||||||
| domain->lock = rzalloc(SOF_MEM_FLAG_KERNEL | SOF_MEM_FLAG_COHERENT, sizeof(*domain->lock)); | ||||||||||||||||||
| #endif | ||||||||||||||||||
| if (!domain->lock) { | ||||||||||||||||||
| rfree(domain); | ||||||||||||||||||
|
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.
|
||||||||||||||||||
| return NULL; | ||||||||||||||||||
| } | ||||||||||||||||||
| k_mutex_init(domain->lock); | ||||||||||||||||||
|
|
||||||||||||||||||
| #else /* !__ZEPHYR */ | ||||||||||||||||||
| k_spinlock_init(&domain->lock); | ||||||||||||||||||
| #endif | ||||||||||||||||||
| atomic_init(&domain->total_num_tasks, 0); | ||||||||||||||||||
| atomic_init(&domain->enabled_cores, 0); | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -243,9 +280,8 @@ struct ll_schedule_domain *zephyr_dma_domain_init(struct dma *dma_array, | |||||||||||||||||
| uint32_t num_dma, | ||||||||||||||||||
| int clk); | ||||||||||||||||||
| #endif /* CONFIG_DMA_DOMAIN */ | ||||||||||||||||||
| struct ll_schedule_domain *zephyr_ll_domain(void); | ||||||||||||||||||
| struct ll_schedule_domain *zephyr_domain_init(int clk); | ||||||||||||||||||
| #define timer_domain_init(timer, clk) zephyr_domain_init(clk) | ||||||||||||||||||
| k_tid_t zephyr_domain_thread_tid(struct ll_schedule_domain *domain); | ||||||||||||||||||
| #endif | ||||||||||||||||||
|
Comment on lines
283
to
285
|
||||||||||||||||||
| #define timer_domain_init(timer, clk) zephyr_domain_init(clk) | |
| k_tid_t zephyr_domain_thread_tid(struct ll_schedule_domain *domain); | |
| #endif | |
| #define timer_domain_init(timer, clk) zephyr_domain_init(clk) | |
| #if CONFIG_SOF_USERSPACE_LL | |
| k_tid_t zephyr_domain_thread_tid(struct ll_schedule_domain *domain); | |
| #endif | |
| #endif |
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.
also declared in ll_schedule_domain.h