|
Sound Open Firmware
|
Real-time task schedulers (Low-Latency Timer/DMA, Data Processing preemptible threads, Thread With Budget), scheduling domains, and task state machines. More...

Files | |
| file | schedule.h |
| Host IPC message dispatch and scheduling task interface. | |
| file | dp_schedule.h |
| Data Processing (DP) preemptible worker thread scheduler. | |
| file | edf_schedule.h |
| Legacy Earliest Deadline First (EDF) workqueue scheduler interface. | |
| file | ll_schedule.h |
| Low-Latency (LL) timer and DMA-driven deterministic task scheduler interface. | |
| file | ll_schedule_domain.h |
| Low-Latency (LL) scheduling domain architecture, timer/DMA drivers, and core domain operations. | |
| file | schedule.h |
| Generic scheduler interface, scheduler operations, and task management. | |
| file | twb_schedule.h |
| Thread With Budget (TWB) scheduler interface and cycle accounting. | |
| file | task.h |
| Core task descriptor, task operations, and task execution state machine. | |
Data Structures | |
| union | scheduler_dp_thread_ipc_param |
| struct | edf_task_pdata |
| Legacy EDF task private data container. More... | |
| struct | ll_task_pdata |
| Low-Latency task private scheduling parameters. More... | |
| struct | ll_schedule_domain_ops |
| Low-Latency schedule domain operations table. More... | |
| struct | ll_schedule_domain |
| Low-Latency scheduling domain instance descriptor. More... | |
| struct | scheduler_ops |
| Scheduler operations interface table. More... | |
| struct | schedule_data |
| Descriptor container representing a registered scheduler instance. More... | |
| struct | schedulers |
| Container holding the linked list of all registered schedulers on a core. More... | |
| struct | task_ops |
| Operations and callbacks associated with a scheduling task. More... | |
| struct | task |
| Core task structure managed by SOF schedulers. More... | |
Macros | |
| #define | IPC_PERIOD_USEC 100 |
| Scheduling period for host IPC worker task in microseconds. | |
| #define | edf_sch_set_pdata(task, data) (task->priv_data = data) |
| Set private data pointer of an EDF task. | |
| #define | edf_sch_get_pdata(task) task->priv_data |
| Retrieve private data pointer of an EDF task. | |
| #define | ll_sch_set_pdata(task, data) do { (task)->priv_data = (data); } while (0) |
| Set the private data pointer of a Low-Latency task. | |
| #define | ll_sch_get_pdata(task) ((task)->priv_data) |
| Retrieve the private data pointer of a Low-Latency task. | |
| #define | scheduler_init_ll zephyr_ll_scheduler_init |
| #define | schedule_task_init_ll zephyr_ll_task_init |
| #define | LL_TIMER_PERIOD_US 1000ULL |
| Default Low-Latency timer scheduling period in microseconds (1000us / 1ms). | |
| #define | LL_WATCHDOG_TIMEOUT_US (2 * LL_TIMER_PERIOD_US) |
| Default Low-Latency watchdog timeout in microseconds. | |
| #define | ll_sch_domain_set_pdata(domain, data) ((domain)->priv_data = (data)) |
| Set the private data pointer of a Low-Latency scheduling domain. | |
| #define | ll_sch_domain_get_pdata(domain) ((domain)->priv_data) |
| Retrieve the private data pointer of a Low-Latency scheduling domain. | |
| #define | timer_domain_init(timer, clk) zephyr_domain_init(clk) |
| #define | SOF_SCHEDULER_FREE_IRQ_ONLY BIT(0) |
| Scheduler free available flags. | |
| #define | ZEPHYR_TWB_STACK_SIZE 8192 |
| Default static stack size in bytes for each TWB worker thread. | |
| #define | ZEPHYR_TWB_BUDGET_MAX (CONFIG_SYS_CLOCK_TICKS_PER_SEC / 1000) |
| Maximum budget limit in system clock ticks per period. | |
| #define | SYS_TICKS_TO_HW_CYCLES(x) (x * CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / CONFIG_SYS_CLOCK_TICKS_PER_SEC) |
| Convert Zephyr system clock ticks to DSP hardware clock cycles. | |
| #define | HW_CYCLES_TO_SYS_TICKS(x) (x * CONFIG_SYS_CLOCK_TICKS_PER_SEC / CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC) |
| Convert DSP hardware clock cycles to Zephyr system clock ticks. | |
| #define | SOF_TASK_PRI_HIGH 0 |
| Predefined Low-Latency task priority levels. | |
| #define | SOF_TASK_PRI_MED 4 |
| Priority level 4 - medium. | |
| #define | SOF_TASK_PRI_LOW 9 |
| Priority level 9 - low (background/idle). | |
| #define | SOF_TASK_DEADLINE_IDLE UINT64_MAX |
| Predefined EDF task deadlines. | |
| #define | SOF_TASK_DEADLINE_ALMOST_IDLE (SOF_TASK_DEADLINE_IDLE - 1) |
| Almost idle deadline. | |
| #define | SOF_TASK_DEADLINE_NOW 0 |
| Immediate deadline; run as soon as possible. | |
| #define | SOF_TASK_SKIP_COUNT 0xFFFFu |
| Task counter initial value. | |
Enumerations | |
| enum | { DP_TASK_EVENT_PROCESS = BIT(0) , DP_TASK_EVENT_CANCEL = BIT(1) , DP_TASK_EVENT_IPC = BIT(2) , DP_TASK_EVENT_IPC_DONE = BIT(3) } |
| Events signaled to Data Processing (DP) worker threads. More... | |
| enum | { SOF_SCHEDULE_EDF = 0 , SOF_SCHEDULE_LL_TIMER , SOF_SCHEDULE_LL_DMA , SOF_SCHEDULE_DP , SOF_SCHEDULE_TWB , SOF_SCHEDULE_COUNT } |
| enum | task_state { SOF_TASK_STATE_INIT = 0 , SOF_TASK_STATE_QUEUED , SOF_TASK_STATE_PENDING , SOF_TASK_STATE_RUNNING , SOF_TASK_STATE_PREEMPTED , SOF_TASK_STATE_COMPLETED , SOF_TASK_STATE_FREE , SOF_TASK_STATE_CANCEL , SOF_TASK_STATE_RESCHEDULE } |
| Lifecycle and execution states of an SOF task. More... | |
Functions | |
| static uint64_t | ipc_task_deadline (void *data) |
| Retrieve IPC command processing deadline. | |
| void | ipc_schedule_process (struct ipc *ipc) |
| Schedule processing of the next pending IPC command received from host. | |
| int | scheduler_dp_init (void) |
| Initialize the Data Processing (DP) scheduler on the calling core. | |
| int | scheduler_dp_task_init (struct task **task, const struct sof_uuid_entry *uid, const struct task_ops *ops, struct processing_module *mod, uint16_t core, size_t stack_size, uint32_t options) |
| Initialize a Data Processing task and attach a dedicated Zephyr worker thread. | |
| void | scheduler_dp_internal_free (struct task *task) |
| Free kernel-side internal resources associated with a DP task. | |
| void | scheduler_dp_ll_tick (void) |
| Tick notification from the Low-Latency (LL) timer domain to the DP scheduler. | |
| void | scheduler_get_task_info_dp (struct scheduler_props *scheduler_props, uint32_t *data_off_size) |
| Extract telemetry information about Data Processing scheduler tasks. | |
| static int | scheduler_dp_thread_ipc (struct processing_module *pmod, unsigned int cmd, union scheduler_dp_thread_ipc_param *param) |
| Dispatch an IPC command synchronously to a Data Processing (DP) worker thread. | |
| int | scheduler_init_edf (void) |
| Initialize the Earliest Deadline First (EDF) workqueue scheduler. | |
| int | schedule_task_init_edf (struct task *task, const struct sof_uuid_entry *uid, const struct task_ops *ops, void *data, uint16_t core, uint32_t flags) |
| Initialize a task for Earliest Deadline First (EDF) workqueue execution. | |
| int | zephyr_ll_scheduler_init (struct ll_schedule_domain *domain) |
| Initialize the Zephyr Low-Latency scheduler domain. | |
| int | zephyr_ll_task_init (struct task *task, const struct sof_uuid_entry *uid, uint16_t type, int16_t priority, enum task_state(*run)(void *data), void *data, uint16_t core, uint32_t flags) |
| Initialize a Zephyr Low-Latency task. | |
| void | scheduler_get_task_info_ll (struct scheduler_props *scheduler_props, uint32_t *data_off_size) |
| Extract telemetry information about Low-Latency scheduler tasks. | |
| static struct ll_schedule_domain * | timer_domain_get (void) |
| Get the primary platform timer scheduling domain. | |
| static struct ll_schedule_domain * | dma_domain_get (void) |
| Get the primary platform DMA scheduling domain. | |
| static struct ll_schedule_domain * | domain_init (int type, int clk, bool synchronous, const struct ll_schedule_domain_ops *ops) |
| Initialize a Low-Latency scheduling domain descriptor. | |
| static void | domain_set (struct ll_schedule_domain *domain, uint64_t start) |
| Configure the next interrupt or tick timestamp for the domain. | |
| static void | domain_clear (struct ll_schedule_domain *domain) |
| Clear/disarm the interrupt tick for the domain. | |
| static void | domain_task_cancel (struct ll_schedule_domain *domain, struct task *task) |
| Notify the domain that a task has been cancelled. | |
| static int | domain_register (struct ll_schedule_domain *domain, struct task *task, void(*handler)(void *arg), void *arg) |
| Register a real-time task with the scheduling domain. | |
| static void | domain_unregister (struct ll_schedule_domain *domain, struct task *task, uint32_t num_tasks) |
| Unregister a real-time task from the scheduling domain. | |
| static void | domain_enable (struct ll_schedule_domain *domain, int core) |
| Enable Low-Latency scheduling domain execution on the specified core. | |
| static void | domain_disable (struct ll_schedule_domain *domain, int core) |
| Disable Low-Latency scheduling domain execution on the specified core. | |
| static bool | domain_is_pending (struct ll_schedule_domain *domain, struct task *task, struct comp_dev **comp) |
| Query whether a task in the domain has pending execution work. | |
| struct ll_schedule_domain * | zephyr_ll_domain (void) |
| Retrieve the global Low-Latency timer scheduling domain descriptor on Zephyr. | |
| struct ll_schedule_domain * | zephyr_domain_init (int clk) |
| Initialize the primary timer-driven Low-Latency scheduling domain on Zephyr. | |
| int | zephyr_ll_task_sem_alloc (struct task *task) |
| Allocate a completion semaphore for a Low-Latency task. | |
| int | zephyr_ll_task_sem_free (struct task *task) |
| Free a completion semaphore for a Low-Latency task. | |
| struct ll_schedule_domain * | dma_multi_chan_domain_init (struct dma *dma_array, uint32_t num_dma, int clk, bool aggregated_irq) |
| Initialize multi-channel DMA scheduling domain. | |
| struct ll_schedule_domain * | dma_single_chan_domain_init (struct dma *dma_array, uint32_t num_dma, int clk) |
| Initialize single-channel DMA scheduling domain. | |
| struct schedulers ** | arch_schedulers_get (void) |
| Retrieve the array of registered kernel-space schedulers for the current core. | |
| struct schedulers ** | arch_user_schedulers_get (void) |
| Retrieve registered schedulers for user-space threads on the current core. | |
| struct schedulers ** | arch_user_schedulers_get_for_core (int core) |
| Retrieve registered schedulers for user-space threads on a specific core. | |
| static void * | scheduler_list_get_data (struct schedulers *schedulers, uint16_t type) |
| Lookup scheduler private context data by scheduler type from a schedulers container. | |
| static void * | scheduler_get_data (uint16_t type) |
| Retrieve private data of a registered kernel scheduler on the current core. | |
| static void * | scheduler_get_user_data (uint16_t type) |
| Retrieve private data of a registered user-space scheduler on the current core. | |
| static int | schedule_task_running (struct task *task) |
| Notify the scheduler that a task is transitioning to the running state. | |
| static int | schedule_task (struct task *task, uint64_t start, uint64_t period) |
| Schedule a task for execution with start delay and period. | |
| static int | schedule_task_before (struct task *task, uint64_t start, uint64_t period, struct task *before) |
| Schedule a task to execute before a specified reference task. | |
| static int | schedule_task_after (struct task *task, uint64_t start, uint64_t period, struct task *after) |
| Schedule a task to execute after a specified reference task. | |
| static int | reschedule_task (struct task *task, uint64_t start) |
| Reschedule an already scheduled task with an updated start time. | |
| static int | schedule_task_cancel (struct task *task) |
| Cancel a scheduled or queued task. | |
| static int | schedule_task_free (struct task *task) |
| Free scheduler resources associated with a task. | |
| static struct k_thread * | scheduler_init_context (struct task *task) |
| Initialize thread execution context for a task. | |
| int | schedule_task_init (struct task *task, const struct sof_uuid_entry *uid, uint16_t type, int16_t priority, enum task_state(*run)(void *data), void *data, uint16_t core, uint32_t flags) |
| Initialize a scheduling task and bind it to the registered scheduler for its type and core. | |
| void | scheduler_init (int type, const struct scheduler_ops *ops, void *data) |
| Register a scheduler type instance with its operations table and private context data. | |
| void | scheduler_get_task_info (struct scheduler_props *scheduler_props, uint32_t *data_off_size, struct list_item *tasks) |
| Extract scheduler task telemetry and properties for IPC4 base firmware. | |
| int | scheduler_twb_init (void) |
| Initialize the Thread With Budget (TWB) scheduler on the calling core. | |
| int | scheduler_twb_task_init (struct task **task, const struct sof_uuid_entry *uid, const struct task_ops *ops, void *data, int32_t core, const char *name, size_t stack_size, int32_t thread_priority, uint32_t cycles_granted) |
| Initialize a TWB task with a dedicated Zephyr worker thread and cycle budget. | |
| static bool | task_is_active (struct task *task) |
| Check whether a task is active (queued, running, pending, or rescheduling). | |
| static enum task_state | task_run (struct task *task) |
| Execute a task's run callback. | |
| static void | task_complete (struct task *task) |
| Execute a task's complete callback, if registered. | |
| static uint64_t | task_get_deadline (struct task *task) |
| Retrieve a task's deadline timestamp. | |
| int | task_main_start (struct sof *sof) |
| Start the main SOF background task. | |
| int | start_complete (void) |
| Signal completion of system startup. | |
Variables | |
| struct tr_ctx | ll_tr |
Real-time task schedulers (Low-Latency Timer/DMA, Data Processing preemptible threads, Thread With Budget), scheduling domains, and task state machines.
Retrieve private data pointer of an EDF task.
| [in] | task | Pointer to the target task structure. |
Set private data pointer of an EDF task.
| [in,out] | task | Pointer to the target task structure. |
| [in] | data | Pointer to private context data. |
| #define HW_CYCLES_TO_SYS_TICKS | ( | x | ) | (x * CONFIG_SYS_CLOCK_TICKS_PER_SEC / CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC) |
Convert DSP hardware clock cycles to Zephyr system clock ticks.
| [in] | x | Hardware cycles. |
| #define IPC_PERIOD_USEC 100 |
Scheduling period for host IPC worker task in microseconds.
| #define ll_sch_domain_get_pdata | ( | domain | ) | ((domain)->priv_data) |
Retrieve the private data pointer of a Low-Latency scheduling domain.
| [in] | domain | Target domain. |
Set the private data pointer of a Low-Latency scheduling domain.
| [in,out] | domain | Target domain. |
| [in] | data | Private context pointer. |
Retrieve the private data pointer of a Low-Latency task.
| [in] | task | Pointer to the target task structure. |
Set the private data pointer of a Low-Latency task.
| [in,out] | task | Pointer to the target task structure. |
| [in] | data | Pointer to private context data (e.g. ll_task_pdata). |
| #define LL_TIMER_PERIOD_US 1000ULL |
Default Low-Latency timer scheduling period in microseconds (1000us / 1ms).
| #define LL_WATCHDOG_TIMEOUT_US (2 * LL_TIMER_PERIOD_US) |
Default Low-Latency watchdog timeout in microseconds.
Configured as two periods to provide a safe margin between watchdog start and initial task feeding.
| #define schedule_task_init_ll zephyr_ll_task_init |
| #define scheduler_init_ll zephyr_ll_scheduler_init |
| #define SOF_SCHEDULER_FREE_IRQ_ONLY BIT(0) |
Scheduler free available flags.
Free function disables interrupts only, keeping data structures intact.
| #define SOF_TASK_DEADLINE_ALMOST_IDLE (SOF_TASK_DEADLINE_IDLE - 1) |
Almost idle deadline.
| #define SOF_TASK_DEADLINE_IDLE UINT64_MAX |
Predefined EDF task deadlines.
Idle deadline; run only when nothing else is ready.
| #define SOF_TASK_DEADLINE_NOW 0 |
Immediate deadline; run as soon as possible.
| #define SOF_TASK_PRI_HIGH 0 |
Predefined Low-Latency task priority levels.
Priority level 0 - high (hard real-time).
| #define SOF_TASK_PRI_LOW 9 |
Priority level 9 - low (background/idle).
| #define SOF_TASK_PRI_MED 4 |
Priority level 4 - medium.
| #define SOF_TASK_SKIP_COUNT 0xFFFFu |
Task counter initial value.
| #define SYS_TICKS_TO_HW_CYCLES | ( | x | ) | (x * CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / CONFIG_SYS_CLOCK_TICKS_PER_SEC) |
Convert Zephyr system clock ticks to DSP hardware clock cycles.
| [in] | x | System ticks. |
| #define timer_domain_init | ( | timer, | |
| clk | |||
| ) | zephyr_domain_init(clk) |
| #define ZEPHYR_TWB_BUDGET_MAX (CONFIG_SYS_CLOCK_TICKS_PER_SEC / 1000) |
Maximum budget limit in system clock ticks per period.
| #define ZEPHYR_TWB_STACK_SIZE 8192 |
Default static stack size in bytes for each TWB worker thread.
| anonymous enum |
| anonymous enum |
| Enumerator | |
|---|---|
| SOF_SCHEDULE_EDF | Earliest Deadline First (EDF) scheduler.
|
| SOF_SCHEDULE_LL_TIMER | Low Latency timer domain scheduler. Executes tasks immediately upon expiration of the primary hardware timer tick. |
| SOF_SCHEDULE_LL_DMA | Low Latency DMA interrupt domain scheduler. Executes tasks immediately upon scheduling component's DMA transfer completion interrupt. |
| SOF_SCHEDULE_DP | Data Processing (DP) worker thread scheduler. Preemptible Zephyr worker thread per SOF task. Evaluates task readiness after each Low-Latency (LL) tick, setting absolute deadlines in Zephyr EDF. |
| SOF_SCHEDULE_TWB | Tasks With Budget (TWB) scheduler. Preemptible Zephyr thread per SOF task with a pre-allocated cycle budget renewed every system tick. Drops thread priority on budget exhaustion to prevent system starvation. |
| SOF_SCHEDULE_COUNT | Indicates total number of scheduler types. |
| enum task_state |
Lifecycle and execution states of an SOF task.
| struct schedulers ** arch_schedulers_get | ( | void | ) |
Retrieve the array of registered kernel-space schedulers for the current core.
Must only be called from privileged/kernel context (!k_is_user_context()).
| struct schedulers ** arch_user_schedulers_get | ( | void | ) |
Retrieve registered schedulers for user-space threads on the current core.
Invokes cpu_get_id(), so this function must only be called from kernel context. User-space callers should use arch_user_schedulers_get_for_core instead.
| struct schedulers ** arch_user_schedulers_get_for_core | ( | int | core | ) |
Retrieve registered schedulers for user-space threads on a specific core.
Safe to invoke from user-space contexts because the target core ID is explicitly provided.
| [in] | core | Target DSP core ID. |
|
inlinestatic |
Get the primary platform DMA scheduling domain.
| struct ll_schedule_domain * dma_multi_chan_domain_init | ( | struct dma * | dma_array, |
| uint32_t | num_dma, | ||
| int | clk, | ||
| bool | aggregated_irq | ||
| ) |
Initialize multi-channel DMA scheduling domain.
| [in] | dma_array | Array of DMA controllers. |
| [in] | num_dma | Number of DMA controllers. |
| [in] | clk | Clock source identifier. |
| [in] | aggregated_irq | True if IRQs from channels are aggregated into a single line. |
| struct ll_schedule_domain * dma_single_chan_domain_init | ( | struct dma * | dma_array, |
| uint32_t | num_dma, | ||
| int | clk | ||
| ) |
Initialize single-channel DMA scheduling domain.
| [in] | dma_array | Array of DMA controllers. |
| [in] | num_dma | Number of DMA controllers. |
| [in] | clk | Clock source identifier. |
|
inlinestatic |
Clear/disarm the interrupt tick for the domain.
| [in,out] | domain | Target scheduling domain. |
|
inlinestatic |
Disable Low-Latency scheduling domain execution on the specified core.
| [in,out] | domain | Target scheduling domain. |
| [in] | core | Target core ID. |
|
inlinestatic |
Enable Low-Latency scheduling domain execution on the specified core.
| [in,out] | domain | Target scheduling domain. |
| [in] | core | Target core ID. |
|
inlinestatic |
Initialize a Low-Latency scheduling domain descriptor.
Allocates a ll_schedule_domain on the user or kernel heap, initializes synchronization locks, resets task and core counters, and computes tick conversion constants.
| [in] | type | Domain type (SOF_SCHEDULE_LL_TIMER or SOF_SCHEDULE_LL_DMA). |
| [in] | clk | Source clock identifier. |
| [in] | synchronous | True if domain tasks must run synchronously. |
| [in] | ops | Domain operations table pointer. |
|
inlinestatic |
Query whether a task in the domain has pending execution work.
| [in] | domain | Target scheduling domain. |
| [in] | task | Task to inspect. |
| [out] | comp | Pointer to associated component device pointer, if any. |
|
inlinestatic |
Register a real-time task with the scheduling domain.
| [in,out] | domain | Target scheduling domain. |
| [in,out] | task | Task to register. |
| [in] | handler | Work handler callback function. |
| [in,out] | arg | Private context argument passed to handler. |
|
inlinestatic |
Configure the next interrupt or tick timestamp for the domain.
| [in,out] | domain | Target scheduling domain. |
| [in] | start | Next execution start timestamp in clock ticks. |
|
inlinestatic |
Notify the domain that a task has been cancelled.
| [in,out] | domain | Target scheduling domain. |
| [in,out] | task | Cancelled task pointer. |
|
inlinestatic |
Unregister a real-time task from the scheduling domain.
| [in,out] | domain | Target scheduling domain. |
| [in,out] | task | Task to unregister. |
| [in] | num_tasks | Current total registered task count. |
| void ipc_schedule_process | ( | struct ipc * | ipc | ) |
Schedule processing of the next pending IPC command received from host.
| [in,out] | ipc | Global IPC subsystem context pointer. |
|
inlinestatic |
Retrieve IPC command processing deadline.
| [in] | data | Task structure context pointer. |
|
inlinestatic |
Reschedule an already scheduled task with an updated start time.
| [in,out] | task | Task to reschedule. |
| [in] | start | New start delay in microseconds. |
|
inlinestatic |
Schedule a task for execution with start delay and period.
| [in,out] | task | Task to schedule. |
| [in] | start | Start delay in microseconds from now. |
| [in] | period | Repetition period in microseconds (0 for one-shot execution). |
|
inlinestatic |
Schedule a task to execute after a specified reference task.
after.| [in,out] | task | Task to schedule. |
| [in] | start | Start timing parameter (scheduler-specific). |
| [in] | period | Repetition period in microseconds (scheduler-specific). |
| [in] | after | Reference task after which this task must run. |
|
inlinestatic |
Schedule a task to execute before a specified reference task.
before.| [in,out] | task | Task to schedule. |
| [in] | start | Start timing parameter (scheduler-specific). |
| [in] | period | Repetition period in microseconds (scheduler-specific). |
| [in] | before | Reference task before which this task must run. |
|
inlinestatic |
Cancel a scheduled or queued task.
| [in,out] | task | Task to cancel. |
|
inlinestatic |
Free scheduler resources associated with a task.
| [in,out] | task | Task whose resources should be freed. |
| int schedule_task_init | ( | struct task * | task, |
| const struct sof_uuid_entry * | uid, | ||
| uint16_t | type, | ||
| int16_t | priority, | ||
| enum task_state(*)(void *data) | run, | ||
| void * | data, | ||
| uint16_t | core, | ||
| uint32_t | flags | ||
| ) |
Initialize a scheduling task and bind it to the registered scheduler for its type and core.
Validates scheduler type and searches registered schedulers. User schedulers look up the target core via arch_user_schedulers_get_for_core(core), whereas kernel schedulers look up via arch_schedulers_get() on the calling core. Therefore, kernel task initialization must execute directly on the target core. Initializes task properties, priority, execution callback, and sets task state to SOF_TASK_STATE_INIT.
| [out] | task | Task structure to initialize. |
| [in] | uid | Statically assigned task UUID entry. |
| [in] | type | Scheduler type (SOF_SCHEDULE_*). |
| [in] | priority | Task scheduling priority (lower values indicate higher priority). |
| [in] | run | Execution callback function returning task_state. |
| [in] | data | Private context pointer passed to run callback. |
| [in] | core | DSP core ID on which the task should execute. |
| [in] | flags | Task-specific scheduling flags. |
| int schedule_task_init_edf | ( | struct task * | task, |
| const struct sof_uuid_entry * | uid, | ||
| const struct task_ops * | ops, | ||
| void * | data, | ||
| uint16_t | core, | ||
| uint32_t | flags | ||
| ) |
Initialize a task for Earliest Deadline First (EDF) workqueue execution.
| [out] | task | Pointer to task structure to initialize. |
| [in] | uid | UUID identifying the task. |
| [in] | ops | Task operations callbacks (task_ops). |
| [in] | data | Context pointer passed to task callbacks. |
| [in] | core | Target DSP core ID. |
| [in] | flags | Scheduling flags. |
|
inlinestatic |
Notify the scheduler that a task is transitioning to the running state.
| [in,out] | task | Task being set to running. |
| int scheduler_dp_init | ( | void | ) |
Initialize the Data Processing (DP) scheduler on the calling core.
Allocates per-core DP scheduler state and initializes its driving LL tick source task.
| void scheduler_dp_internal_free | ( | struct task * | task | ) |
Free kernel-side internal resources associated with a DP task.
| [in,out] | task | Task being freed. |
| void scheduler_dp_ll_tick | ( | void | ) |
Tick notification from the Low-Latency (LL) timer domain to the DP scheduler.
Invoked on each core after all LL tasks complete. Evaluates readiness for all queued DP tasks, updates their absolute deadlines, and signals worker threads.
| int scheduler_dp_task_init | ( | struct task ** | task, |
| const struct sof_uuid_entry * | uid, | ||
| const struct task_ops * | ops, | ||
| struct processing_module * | mod, | ||
| uint16_t | core, | ||
| size_t | stack_size, | ||
| uint32_t | options | ||
| ) |
Initialize a Data Processing task and attach a dedicated Zephyr worker thread.
Must be invoked on the same core that the task is configured to execute on.
| [out] | task | Pointer to store the allocated task structure. |
| [in] | uid | UUID identifying the task/module. |
| [in] | ops | Task operations callbacks (task_ops). |
| [in] | mod | Processing module descriptor bound to this task. |
| [in] | core | DSP core affinity for the task thread. |
| [in] | stack_size | Stack byte size for the Zephyr worker thread. |
| [in] | options | Task configuration flags. |
|
inlinestatic |
Dispatch an IPC command synchronously to a Data Processing (DP) worker thread.
Posts DP_TASK_EVENT_IPC to the thread's event queue and blocks waiting on completion (via dp_sync with a 100 ms timeout) before returning.
| [in,out] | pmod | Pointer to the processing module descriptor. |
| [in] | cmd | IPC command identifier to execute. |
| [in,out] | param | Parameters payload for the IPC command. |
|
inlinestatic |
Retrieve private data of a registered kernel scheduler on the current core.
| [in] | type | Scheduler type (SOF_SCHEDULE_*). |
| void scheduler_get_task_info | ( | struct scheduler_props * | scheduler_props, |
| uint32_t * | data_off_size, | ||
| struct list_item * | tasks | ||
| ) |
Extract scheduler task telemetry and properties for IPC4 base firmware.
Populates scheduler_props with the calling core ID and total task count, appending task_props structures for each active task in the list.
| [out] | scheduler_props | Properties structure to be filled. |
| [in,out] | data_off_size | Pointer to running byte size of scheduler_props buffer. |
| [in] | tasks | Linked list of tasks to inspect. |
| void scheduler_get_task_info_dp | ( | struct scheduler_props * | scheduler_props, |
| uint32_t * | data_off_size | ||
| ) |
Extract telemetry information about Data Processing scheduler tasks.
Populates scheduler_props with COMP_PROCESSING_DOMAIN_DP and active DP tasks.
| [out] | scheduler_props | Structure to be filled with DP scheduler properties. |
| [in,out] | data_off_size | Pointer to the current size of scheduler_props buffer. |
| void scheduler_get_task_info_ll | ( | struct scheduler_props * | scheduler_props, |
| uint32_t * | data_off_size | ||
| ) |
Extract telemetry information about Low-Latency scheduler tasks.
Populates scheduler_props with COMP_PROCESSING_DOMAIN_LL and active LL tasks.
| [out] | scheduler_props | Structure to be filled with LL scheduler properties. |
| [in,out] | data_off_size | Pointer to the current size of scheduler_props buffer. |
|
inlinestatic |
Retrieve private data of a registered user-space scheduler on the current core.
| [in] | type | Scheduler type (SOF_SCHEDULE_*). |
| void scheduler_init | ( | int | type, |
| const struct scheduler_ops * | ops, | ||
| void * | data | ||
| ) |
Register a scheduler type instance with its operations table and private context data.
Allocates a schedule_data container on the system (or user) heap, links it into the active core scheduler list, and associates the provided operations.
| [in] | type | Scheduler type identifier (SOF_SCHEDULE_*). |
| [in] | ops | Pointer to scheduler operations table (must provide schedule_task, schedule_task_cancel, schedule_task_free). |
| [in] | data | Pointer to scheduler private instance data. |
|
inlinestatic |
Initialize thread execution context for a task.
| [in,out] | task | Task requiring execution context initialization. |
| int scheduler_init_edf | ( | void | ) |
Initialize the Earliest Deadline First (EDF) workqueue scheduler.
|
inlinestatic |
Lookup scheduler private context data by scheduler type from a schedulers container.
| [in] | schedulers | Schedulers list container. |
| [in] | type | Scheduler type identifier (SOF_SCHEDULE_*). |
| int scheduler_twb_init | ( | void | ) |
Initialize the Thread With Budget (TWB) scheduler on the calling core.
Allocates per-core TWB scheduler state and binds its driving LL tick source task.
| int scheduler_twb_task_init | ( | struct task ** | task, |
| const struct sof_uuid_entry * | uid, | ||
| const struct task_ops * | ops, | ||
| void * | data, | ||
| int32_t | core, | ||
| const char * | name, | ||
| size_t | stack_size, | ||
| int32_t | thread_priority, | ||
| uint32_t | cycles_granted | ||
| ) |
Initialize a TWB task with a dedicated Zephyr worker thread and cycle budget.
Must be invoked on the same core that the task is configured to execute on.
| [out] | task | Pointer to store the allocated task structure. |
| [in] | uid | UUID identifying the task. |
| [in] | ops | Task operations callbacks (task_ops). |
| [in] | data | Private context pointer passed to task callbacks. |
| [in] | core | DSP core affinity for the worker thread. |
| [in] | name | Debug name assigned to the Zephyr thread. |
| [in] | stack_size | Stack byte size for the worker thread. |
| [in] | thread_priority | Default preemptible thread priority (must be >= 0). |
| [in] | cycles_granted | Budget in Zephyr system clock ticks per period (0 or >= ZEPHYR_TWB_BUDGET_MAX for unlimited). |
| int start_complete | ( | void | ) |
Signal completion of system startup.
|
inlinestatic |
Execute a task's complete callback, if registered.
| [in,out] | task | Task whose completion callback should be invoked. |
|
inlinestatic |
Retrieve a task's deadline timestamp.
| [in] | task | Task to query. |
|
inlinestatic |
Check whether a task is active (queued, running, pending, or rescheduling).
| [in] | task | Task to check. |
| int task_main_start | ( | struct sof * | sof | ) |
Start the main SOF background task.
| [in,out] | sof | Global SOF context pointer. |
|
inlinestatic |
Execute a task's run callback.
| [in,out] | task | Task to execute. |
|
inlinestatic |
Get the primary platform timer scheduling domain.
| struct ll_schedule_domain * zephyr_domain_init | ( | int | clk | ) |
Initialize the primary timer-driven Low-Latency scheduling domain on Zephyr.
| [in] | clk | Clock source identifier. |
| struct ll_schedule_domain * zephyr_ll_domain | ( | void | ) |
Retrieve the global Low-Latency timer scheduling domain descriptor on Zephyr.
| int zephyr_ll_scheduler_init | ( | struct ll_schedule_domain * | domain | ) |
Initialize the Zephyr Low-Latency scheduler domain.
| [in,out] | domain | Pointer to the Low-Latency schedule domain. |
| int zephyr_ll_task_init | ( | struct task * | task, |
| const struct sof_uuid_entry * | uid, | ||
| uint16_t | type, | ||
| int16_t | priority, | ||
| enum task_state(*)(void *data) | run, | ||
| void * | data, | ||
| uint16_t | core, | ||
| uint32_t | flags | ||
| ) |
Initialize a Zephyr Low-Latency task.
| [out] | task | Pointer to task structure. |
| [in] | uid | UUID identifying the task. |
| [in] | type | Task type identifier (SOF_SCHEDULE_LL_TIMER or SOF_SCHEDULE_LL_DMA). |
| [in] | priority | Task priority (lower values indicate higher priority). |
| [in] | run | Work callback function. |
| [in] | data | Context pointer. |
| [in] | core | Target DSP core ID. |
| [in] | flags | Scheduling flags. |
| int zephyr_ll_task_sem_alloc | ( | struct task * | task | ) |
Allocate a completion semaphore for a Low-Latency task.
| [in,out] | task | Target task. |
| int zephyr_ll_task_sem_free | ( | struct task * | task | ) |
Free a completion semaphore for a Low-Latency task.
| [in,out] | task | Target task. |
|
extern |