Sound Open Firmware
Loading...
Searching...
No Matches
Scheduling Infrastructure

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

Collaboration diagram for Scheduling Infrastructure:

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
 

Detailed Description

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

Macro Definition Documentation

◆ edf_sch_get_pdata

#define edf_sch_get_pdata (   task)    task->priv_data

Retrieve private data pointer of an EDF task.

Parameters
[in]taskPointer to the target task structure.
Returns
Pointer to private context data.
Deprecated:
See sof/schedule/edf_schedule.h.

◆ edf_sch_set_pdata

#define edf_sch_set_pdata (   task,
  data 
)     (task->priv_data = data)

Set private data pointer of an EDF task.

Parameters
[in,out]taskPointer to the target task structure.
[in]dataPointer to private context data.
Deprecated:
See sof/schedule/edf_schedule.h.

◆ HW_CYCLES_TO_SYS_TICKS

#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.

Parameters
[in]xHardware cycles.

◆ IPC_PERIOD_USEC

#define IPC_PERIOD_USEC   100

Scheduling period for host IPC worker task in microseconds.

◆ ll_sch_domain_get_pdata

#define ll_sch_domain_get_pdata (   domain)    ((domain)->priv_data)

Retrieve the private data pointer of a Low-Latency scheduling domain.

Parameters
[in]domainTarget domain.
Returns
Pointer to domain-specific context data.

◆ ll_sch_domain_set_pdata

#define ll_sch_domain_set_pdata (   domain,
  data 
)    ((domain)->priv_data = (data))

Set the private data pointer of a Low-Latency scheduling domain.

Parameters
[in,out]domainTarget domain.
[in]dataPrivate context pointer.

◆ ll_sch_get_pdata

#define ll_sch_get_pdata (   task)    ((task)->priv_data)

Retrieve the private data pointer of a Low-Latency task.

Parameters
[in]taskPointer to the target task structure.
Returns
Pointer to private context data.

◆ ll_sch_set_pdata

#define ll_sch_set_pdata (   task,
  data 
)     do { (task)->priv_data = (data); } while (0)

Set the private data pointer of a Low-Latency task.

Parameters
[in,out]taskPointer to the target task structure.
[in]dataPointer to private context data (e.g. ll_task_pdata).

◆ LL_TIMER_PERIOD_US

#define LL_TIMER_PERIOD_US   1000ULL

Default Low-Latency timer scheduling period in microseconds (1000us / 1ms).

◆ LL_WATCHDOG_TIMEOUT_US

#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.

◆ schedule_task_init_ll

#define schedule_task_init_ll   zephyr_ll_task_init

◆ scheduler_init_ll

#define scheduler_init_ll   zephyr_ll_scheduler_init

◆ SOF_SCHEDULER_FREE_IRQ_ONLY

#define SOF_SCHEDULER_FREE_IRQ_ONLY   BIT(0)

Scheduler free available flags.

Free function disables interrupts only, keeping data structures intact.

◆ SOF_TASK_DEADLINE_ALMOST_IDLE

#define SOF_TASK_DEADLINE_ALMOST_IDLE   (SOF_TASK_DEADLINE_IDLE - 1)

Almost idle deadline.

◆ SOF_TASK_DEADLINE_IDLE

#define SOF_TASK_DEADLINE_IDLE   UINT64_MAX

Predefined EDF task deadlines.

Idle deadline; run only when nothing else is ready.

◆ SOF_TASK_DEADLINE_NOW

#define SOF_TASK_DEADLINE_NOW   0

Immediate deadline; run as soon as possible.

◆ SOF_TASK_PRI_HIGH

#define SOF_TASK_PRI_HIGH   0

Predefined Low-Latency task priority levels.

Priority level 0 - high (hard real-time).

◆ SOF_TASK_PRI_LOW

#define SOF_TASK_PRI_LOW   9

Priority level 9 - low (background/idle).

◆ SOF_TASK_PRI_MED

#define SOF_TASK_PRI_MED   4

Priority level 4 - medium.

◆ SOF_TASK_SKIP_COUNT

#define SOF_TASK_SKIP_COUNT   0xFFFFu

Task counter initial value.

◆ SYS_TICKS_TO_HW_CYCLES

#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.

Parameters
[in]xSystem ticks.

◆ timer_domain_init

#define timer_domain_init (   timer,
  clk 
)    zephyr_domain_init(clk)

◆ ZEPHYR_TWB_BUDGET_MAX

#define ZEPHYR_TWB_BUDGET_MAX   (CONFIG_SYS_CLOCK_TICKS_PER_SEC / 1000)

Maximum budget limit in system clock ticks per period.

◆ ZEPHYR_TWB_STACK_SIZE

#define ZEPHYR_TWB_STACK_SIZE   8192

Default static stack size in bytes for each TWB worker thread.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Events signaled to Data Processing (DP) worker threads.

Enumerator
DP_TASK_EVENT_PROCESS 
DP_TASK_EVENT_CANCEL 
DP_TASK_EVENT_IPC 
DP_TASK_EVENT_IPC_DONE 

◆ anonymous enum

anonymous enum
Enumerator
SOF_SCHEDULE_EDF 

Earliest Deadline First (EDF) scheduler.

Deprecated:
Deprecated for modern audio pipeline processing. In Zephyr-based builds, EDF is implemented as a delayed workqueue (edf_workq) retained for host IPC processing and legacy KPB draining tasks until migration. Audio pipeline components should use SOF_SCHEDULE_DP for preemptible deadline-driven tasks or SOF_SCHEDULE_LL_TIMER / SOF_SCHEDULE_LL_DMA for hard real-time tasks.
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.

◆ task_state

enum task_state

Lifecycle and execution states of an SOF task.

Enumerator
SOF_TASK_STATE_INIT 

Task allocated and initialized, not yet scheduled.

SOF_TASK_STATE_QUEUED 

Task queued in scheduler run list awaiting tick or trigger.

SOF_TASK_STATE_PENDING 

Task waiting for preconditions, audio data, or buffer space.

SOF_TASK_STATE_RUNNING 

Task actively executing in thread or timer/DMA handler.

SOF_TASK_STATE_PREEMPTED 

Task preempted by higher priority thread or ISR.

SOF_TASK_STATE_COMPLETED 

Task execution finished; removed from active scheduling.

SOF_TASK_STATE_FREE 

Task resources released.

SOF_TASK_STATE_CANCEL 

Task cancelled, pending removal from scheduler.

SOF_TASK_STATE_RESCHEDULE 

Return code from run callback requesting rescheduling in next period.

Function Documentation

◆ arch_schedulers_get()

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()).

Returns
Pointer to the per-core schedulers list head pointer.

◆ arch_user_schedulers_get()

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.

Returns
Pointer to the per-core user schedulers list head pointer, or NULL if user LL is disabled.

◆ arch_user_schedulers_get_for_core()

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.

Parameters
[in]coreTarget DSP core ID.
Returns
Pointer to the user schedulers list head pointer for the specified core, or NULL if disabled.

◆ dma_domain_get()

static struct ll_schedule_domain * dma_domain_get ( void  )
inlinestatic

Get the primary platform DMA scheduling domain.

Returns
Pointer to global DMA scheduling domain.

◆ dma_multi_chan_domain_init()

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.

Parameters
[in]dma_arrayArray of DMA controllers.
[in]num_dmaNumber of DMA controllers.
[in]clkClock source identifier.
[in]aggregated_irqTrue if IRQs from channels are aggregated into a single line.
Returns
Pointer to initialized scheduling domain.

◆ dma_single_chan_domain_init()

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.

Parameters
[in]dma_arrayArray of DMA controllers.
[in]num_dmaNumber of DMA controllers.
[in]clkClock source identifier.
Returns
Pointer to initialized scheduling domain.

◆ domain_clear()

static void domain_clear ( struct ll_schedule_domain *  domain)
inlinestatic

Clear/disarm the interrupt tick for the domain.

Parameters
[in,out]domainTarget scheduling domain.

◆ domain_disable()

static void domain_disable ( struct ll_schedule_domain *  domain,
int  core 
)
inlinestatic

Disable Low-Latency scheduling domain execution on the specified core.

Parameters
[in,out]domainTarget scheduling domain.
[in]coreTarget core ID.

◆ domain_enable()

static void domain_enable ( struct ll_schedule_domain *  domain,
int  core 
)
inlinestatic

Enable Low-Latency scheduling domain execution on the specified core.

Parameters
[in,out]domainTarget scheduling domain.
[in]coreTarget core ID.

◆ domain_init()

static struct ll_schedule_domain * domain_init ( int  type,
int  clk,
bool  synchronous,
const struct ll_schedule_domain_ops *  ops 
)
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.

Parameters
[in]typeDomain type (SOF_SCHEDULE_LL_TIMER or SOF_SCHEDULE_LL_DMA).
[in]clkSource clock identifier.
[in]synchronousTrue if domain tasks must run synchronously.
[in]opsDomain operations table pointer.
Returns
Pointer to initialized domain, or NULL on allocation failure.

◆ domain_is_pending()

static bool domain_is_pending ( struct ll_schedule_domain *  domain,
struct task *  task,
struct comp_dev **  comp 
)
inlinestatic

Query whether a task in the domain has pending execution work.

Parameters
[in]domainTarget scheduling domain.
[in]taskTask to inspect.
[out]compPointer to associated component device pointer, if any.
Returns
true if work is pending, false otherwise.

◆ domain_register()

static int domain_register ( struct ll_schedule_domain *  domain,
struct task *  task,
void(*)(void *arg)  handler,
void *  arg 
)
inlinestatic

Register a real-time task with the scheduling domain.

Parameters
[in,out]domainTarget scheduling domain.
[in,out]taskTask to register.
[in]handlerWork handler callback function.
[in,out]argPrivate context argument passed to handler.
Returns
0 on success, negative error code on failure.

◆ domain_set()

static void domain_set ( struct ll_schedule_domain *  domain,
uint64_t  start 
)
inlinestatic

Configure the next interrupt or tick timestamp for the domain.

Parameters
[in,out]domainTarget scheduling domain.
[in]startNext execution start timestamp in clock ticks.

◆ domain_task_cancel()

static void domain_task_cancel ( struct ll_schedule_domain *  domain,
struct task *  task 
)
inlinestatic

Notify the domain that a task has been cancelled.

Parameters
[in,out]domainTarget scheduling domain.
[in,out]taskCancelled task pointer.

◆ domain_unregister()

static void domain_unregister ( struct ll_schedule_domain *  domain,
struct task *  task,
uint32_t  num_tasks 
)
inlinestatic

Unregister a real-time task from the scheduling domain.

Parameters
[in,out]domainTarget scheduling domain.
[in,out]taskTask to unregister.
[in]num_tasksCurrent total registered task count.

◆ ipc_schedule_process()

void ipc_schedule_process ( struct ipc *  ipc)

Schedule processing of the next pending IPC command received from host.

Parameters
[in,out]ipcGlobal IPC subsystem context pointer.

◆ ipc_task_deadline()

static uint64_t ipc_task_deadline ( void *  data)
inlinestatic

Retrieve IPC command processing deadline.

Parameters
[in]dataTask structure context pointer.
Returns
Task deadline timestamp (SOF_TASK_DEADLINE_NOW).

◆ reschedule_task()

static int reschedule_task ( struct task *  task,
uint64_t  start 
)
inlinestatic

Reschedule an already scheduled task with an updated start time.

Parameters
[in,out]taskTask to reschedule.
[in]startNew start delay in microseconds.
Returns
0 on success, or negative error code from scheduler ops.

◆ schedule_task()

static int schedule_task ( struct task *  task,
uint64_t  start,
uint64_t  period 
)
inlinestatic

Schedule a task for execution with start delay and period.

Parameters
[in,out]taskTask to schedule.
[in]startStart delay in microseconds from now.
[in]periodRepetition period in microseconds (0 for one-shot execution).
Returns
0 on success, -EINVAL if task is NULL, or negative error code from scheduler ops.

◆ schedule_task_after()

static int schedule_task_after ( struct task *  task,
uint64_t  start,
uint64_t  period,
struct task *  after 
)
inlinestatic

Schedule a task to execute after a specified reference task.

Note
Relative task ordering is optional and scheduler-specific. If the underlying scheduler does not implement schedule_task_after, this wrapper falls back to ordinary schedule_task() and ignores after.
Parameters
[in,out]taskTask to schedule.
[in]startStart timing parameter (scheduler-specific).
[in]periodRepetition period in microseconds (scheduler-specific).
[in]afterReference task after which this task must run.
Returns
0 on success, -EINVAL if arguments are invalid, or negative error code from scheduler ops.

◆ schedule_task_before()

static int schedule_task_before ( struct task *  task,
uint64_t  start,
uint64_t  period,
struct task *  before 
)
inlinestatic

Schedule a task to execute before a specified reference task.

Note
Relative task ordering is optional and scheduler-specific. If the underlying scheduler does not implement schedule_task_before, this wrapper falls back to ordinary schedule_task() and ignores before.
Parameters
[in,out]taskTask to schedule.
[in]startStart timing parameter (scheduler-specific).
[in]periodRepetition period in microseconds (scheduler-specific).
[in]beforeReference task before which this task must run.
Returns
0 on success, -EINVAL if arguments are invalid, or negative error code from scheduler ops.

◆ schedule_task_cancel()

static int schedule_task_cancel ( struct task *  task)
inlinestatic

Cancel a scheduled or queued task.

Parameters
[in,out]taskTask to cancel.
Returns
0 on success, -EINVAL if task or bound scheduler is NULL, or negative error code from scheduler ops.

◆ schedule_task_free()

static int schedule_task_free ( struct task *  task)
inlinestatic

Free scheduler resources associated with a task.

Parameters
[in,out]taskTask whose resources should be freed.
Returns
0 on success, -EINVAL if task or bound scheduler is NULL, or negative error code from scheduler ops.

◆ schedule_task_init()

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.

Parameters
[out]taskTask structure to initialize.
[in]uidStatically assigned task UUID entry.
[in]typeScheduler type (SOF_SCHEDULE_*).
[in]priorityTask scheduling priority (lower values indicate higher priority).
[in]runExecution callback function returning task_state.
[in]dataPrivate context pointer passed to run callback.
[in]coreDSP core ID on which the task should execute.
[in]flagsTask-specific scheduling flags.
Returns
0 on success, -EINVAL if type >= SOF_SCHEDULE_COUNT, -ENODEV if scheduler cannot be found.

◆ schedule_task_init_edf()

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.

Deprecated:
Deprecated for audio pipelines; use scheduler_dp_task_init() instead.
Parameters
[out]taskPointer to task structure to initialize.
[in]uidUUID identifying the task.
[in]opsTask operations callbacks (task_ops).
[in]dataContext pointer passed to task callbacks.
[in]coreTarget DSP core ID.
[in]flagsScheduling flags.
Returns
0 on success, negative error code on failure.

◆ schedule_task_running()

static int schedule_task_running ( struct task *  task)
inlinestatic

Notify the scheduler that a task is transitioning to the running state.

Parameters
[in,out]taskTask being set to running.
Returns
0 on success, or negative error code from scheduler ops.

◆ scheduler_dp_init()

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.

Returns
0 on success, negative error code (-ENOMEM) on failure.

◆ scheduler_dp_internal_free()

void scheduler_dp_internal_free ( struct task *  task)

Free kernel-side internal resources associated with a DP task.

Parameters
[in,out]taskTask being freed.

◆ scheduler_dp_ll_tick()

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.

◆ scheduler_dp_task_init()

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.

Parameters
[out]taskPointer to store the allocated task structure.
[in]uidUUID identifying the task/module.
[in]opsTask operations callbacks (task_ops).
[in]modProcessing module descriptor bound to this task.
[in]coreDSP core affinity for the task thread.
[in]stack_sizeStack byte size for the Zephyr worker thread.
[in]optionsTask configuration flags.
Returns
0 on success, negative error code on failure.

◆ scheduler_dp_thread_ipc()

static int scheduler_dp_thread_ipc ( struct processing_module *  pmod,
unsigned int  cmd,
union scheduler_dp_thread_ipc_param *  param 
)
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.

Parameters
[in,out]pmodPointer to the processing module descriptor.
[in]cmdIPC command identifier to execute.
[in,out]paramParameters payload for the IPC command.
Returns
0 on success, negative error code on failure.

◆ scheduler_get_data()

static void * scheduler_get_data ( uint16_t  type)
inlinestatic

Retrieve private data of a registered kernel scheduler on the current core.

Parameters
[in]typeScheduler type (SOF_SCHEDULE_*).
Returns
Pointer to scheduler private data, or NULL if not found.

◆ scheduler_get_task_info()

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.

Parameters
[out]scheduler_propsProperties structure to be filled.
[in,out]data_off_sizePointer to running byte size of scheduler_props buffer.
[in]tasksLinked list of tasks to inspect.

◆ scheduler_get_task_info_dp()

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.

Parameters
[out]scheduler_propsStructure to be filled with DP scheduler properties.
[in,out]data_off_sizePointer to the current size of scheduler_props buffer.

◆ scheduler_get_task_info_ll()

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.

Parameters
[out]scheduler_propsStructure to be filled with LL scheduler properties.
[in,out]data_off_sizePointer to the current size of scheduler_props buffer.

◆ scheduler_get_user_data()

static void * scheduler_get_user_data ( uint16_t  type)
inlinestatic

Retrieve private data of a registered user-space scheduler on the current core.

Parameters
[in]typeScheduler type (SOF_SCHEDULE_*).
Returns
Pointer to scheduler private data, or NULL if not found.

◆ scheduler_init()

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.

Parameters
[in]typeScheduler type identifier (SOF_SCHEDULE_*).
[in]opsPointer to scheduler operations table (must provide schedule_task, schedule_task_cancel, schedule_task_free).
[in]dataPointer to scheduler private instance data.

◆ scheduler_init_context()

static struct k_thread * scheduler_init_context ( struct task *  task)
inlinestatic

Initialize thread execution context for a task.

Parameters
[in,out]taskTask requiring execution context initialization.
Returns
Pointer to allocated Zephyr thread, or NULL if unsupported or failed.

◆ scheduler_init_edf()

int scheduler_init_edf ( void  )

Initialize the Earliest Deadline First (EDF) workqueue scheduler.

Deprecated:
Deprecated for audio pipelines; retained for host IPC and legacy KPB draining.
Returns
0 on success, negative error code on failure.

◆ scheduler_list_get_data()

static void * scheduler_list_get_data ( struct schedulers *  schedulers,
uint16_t  type 
)
inlinestatic

Lookup scheduler private context data by scheduler type from a schedulers container.

Parameters
[in]schedulersSchedulers list container.
[in]typeScheduler type identifier (SOF_SCHEDULE_*).
Returns
Pointer to scheduler-specific private data, or NULL if not found.

◆ scheduler_twb_init()

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.

Returns
0 on success, negative error code (-ENOMEM) on failure.

◆ scheduler_twb_task_init()

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.

Parameters
[out]taskPointer to store the allocated task structure.
[in]uidUUID identifying the task.
[in]opsTask operations callbacks (task_ops).
[in]dataPrivate context pointer passed to task callbacks.
[in]coreDSP core affinity for the worker thread.
[in]nameDebug name assigned to the Zephyr thread.
[in]stack_sizeStack byte size for the worker thread.
[in]thread_priorityDefault preemptible thread priority (must be >= 0).
[in]cycles_grantedBudget in Zephyr system clock ticks per period (0 or >= ZEPHYR_TWB_BUDGET_MAX for unlimited).
Returns
0 on success, negative error code (-EINVAL, -ENOMEM, -EFAULT) on failure.

◆ start_complete()

int start_complete ( void  )

Signal completion of system startup.

Returns
0 on success, negative error code on failure.

◆ task_complete()

static void task_complete ( struct task *  task)
inlinestatic

Execute a task's complete callback, if registered.

Parameters
[in,out]taskTask whose completion callback should be invoked.

◆ task_get_deadline()

static uint64_t task_get_deadline ( struct task *  task)
inlinestatic

Retrieve a task's deadline timestamp.

Parameters
[in]taskTask to query.
Returns
Current deadline timestamp.

◆ task_is_active()

static bool task_is_active ( struct task *  task)
inlinestatic

Check whether a task is active (queued, running, pending, or rescheduling).

Parameters
[in]taskTask to check.
Returns
true if task is in an active execution state, false otherwise.

◆ task_main_start()

int task_main_start ( struct sof *  sof)

Start the main SOF background task.

Parameters
[in,out]sofGlobal SOF context pointer.
Returns
0 on success, negative error code on failure.

◆ task_run()

static enum task_state task_run ( struct task *  task)
inlinestatic

Execute a task's run callback.

Parameters
[in,out]taskTask to execute.
Returns
Resulting task state returned by the run callback.

◆ timer_domain_get()

static struct ll_schedule_domain * timer_domain_get ( void  )
inlinestatic

Get the primary platform timer scheduling domain.

Returns
Pointer to global timer scheduling domain.

◆ zephyr_domain_init()

struct ll_schedule_domain * zephyr_domain_init ( int  clk)

Initialize the primary timer-driven Low-Latency scheduling domain on Zephyr.

Parameters
[in]clkClock source identifier.
Returns
Pointer to initialized scheduling domain, or NULL on failure.

◆ zephyr_ll_domain()

struct ll_schedule_domain * zephyr_ll_domain ( void  )

Retrieve the global Low-Latency timer scheduling domain descriptor on Zephyr.

Returns
Pointer to active domain descriptor.

◆ zephyr_ll_scheduler_init()

int zephyr_ll_scheduler_init ( struct ll_schedule_domain *  domain)

Initialize the Zephyr Low-Latency scheduler domain.

Parameters
[in,out]domainPointer to the Low-Latency schedule domain.
Returns
0 on success, negative error code on failure.

◆ zephyr_ll_task_init()

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.

Parameters
[out]taskPointer to task structure.
[in]uidUUID identifying the task.
[in]typeTask type identifier (SOF_SCHEDULE_LL_TIMER or SOF_SCHEDULE_LL_DMA).
[in]priorityTask priority (lower values indicate higher priority).
[in]runWork callback function.
[in]dataContext pointer.
[in]coreTarget DSP core ID.
[in]flagsScheduling flags.
Returns
0 on success, negative error code on failure.

◆ zephyr_ll_task_sem_alloc()

int zephyr_ll_task_sem_alloc ( struct task *  task)

Allocate a completion semaphore for a Low-Latency task.

Parameters
[in,out]taskTarget task.
Returns
0 on success, negative error code on failure.

◆ zephyr_ll_task_sem_free()

int zephyr_ll_task_sem_free ( struct task *  task)

Free a completion semaphore for a Low-Latency task.

Parameters
[in,out]taskTarget task.
Returns
0 on success, negative error code on failure.

Variable Documentation

◆ ll_tr

struct tr_ctx ll_tr
extern