14#ifndef __SOF_SCHEDULE_LL_SCHEDULE_DOMAIN_H__
15#define __SOF_SCHEDULE_LL_SCHEDULE_DOMAIN_H__
25#include <sof/trace/trace.h>
26#include <ipc/topology.h>
35#if defined(CONFIG_AMD)
37#define LL_TIMER_PERIOD_US 500ULL
40#define LL_TIMER_PERIOD_US 1000ULL
49#define LL_WATCHDOG_TIMEOUT_US (2 * LL_TIMER_PERIOD_US)
73 void (*handler)(
void *arg),
void *arg);
83 struct task *
task, uint32_t num_tasks);
85#if CONFIG_SOF_USERSPACE_LL
120#if CONFIG_CROSS_CORE_STREAM
171#ifdef CONFIG_SOF_USERSPACE_LL
172 struct k_mutex *
lock;
193#define ll_sch_domain_set_pdata(domain, data) ((domain)->priv_data = (data))
200#define ll_sch_domain_get_pdata(domain) ((domain)->priv_data)
220#ifdef CONFIG_SOF_USERSPACE_LL
225struct task *zephyr_ll_task_alloc(
void);
231struct k_heap *zephyr_ll_user_heap(
void);
238bool zephyr_ll_user_heap_verify(
struct k_heap *heap);
243void zephyr_ll_user_resources_init(
void);
250void user_ll_grant_access(
struct k_thread *thread,
int core);
256void user_ll_lock_sched(
int core);
262void user_ll_unlock_sched(
int core);
269void user_ll_assert_locked(
int core);
271static inline void user_ll_assert_locked(
int core) { ARG_UNUSED(core); }
293#ifdef CONFIG_SOF_USERSPACE_LL
295 sizeof(*domain),
sizeof(
void *));
297 memset(domain, 0,
sizeof(*domain));
317#ifdef CONFIG_SOF_USERSPACE_LL
319 domain->
lock = k_object_alloc(K_OBJ_MUTEX);
324 k_mutex_init(domain->
lock);
372#if CONFIG_SOF_USERSPACE_LL
387 return domain->
ops->domain_thread_init(domain,
task);
401 if (domain->
ops->domain_thread_free)
402 domain->
ops->domain_thread_free(domain, num_tasks);
416 void (*handler)(
void *arg),
void *arg)
438 struct task *
task, uint32_t num_tasks)
486#if CONFIG_CROSS_CORE_STREAM
493 if (domain->
ops->domain_block)
494 domain->
ops->domain_block(domain);
503 if (domain->
ops->domain_unblock)
504 domain->
ops->domain_unblock(domain);
538#define dma_multi_chan_domain_init(dma_array, num_dma, clk, aggregated_irq)\
539 zephyr_dma_domain_init(dma_array, num_dma, clk)
565#define timer_domain_init(timer, clk) zephyr_domain_init(clk)
567#ifdef CONFIG_SOF_USERSPACE_LL
580struct k_thread *zephyr_domain_thread_tid_for_core(
int core);
586struct k_mem_domain *zephyr_ll_mem_domain(
void);
592struct k_thread *zephyr_ll_domain_thread(
void);
595#ifdef CONFIG_SOF_FULL_ZEPHYR_APPLICATION
609#include <zephyr/syscalls/ll_schedule_domain.h>
611int z_impl_zephyr_ll_task_sem_alloc(
struct task *
task);
612int z_impl_zephyr_ll_task_sem_free(
struct task *
task);
613#define zephyr_ll_task_sem_alloc z_impl_zephyr_ll_task_sem_alloc
614#define zephyr_ll_task_sem_free z_impl_zephyr_ll_task_sem_free
627 uint32_t num_dma,
int clk,
628 bool aggregated_irq);
Memory allocation API, zones, heaps, and alignment utilities.
#define atomic_init(p, v)
Definition atomic.h:18
RTOS DSP clock frequency management and notification interfaces.
void * rzalloc(uint32_t flags, size_t bytes)
Allocate zero-initialized memory block with default natural alignment.
void * sof_heap_alloc(struct k_heap *heap, uint32_t flags, size_t bytes, size_t alignment)
Allocate memory from a specified Zephyr heap or default system heap.
#define SOF_MEM_FLAG_USER
Base allocation flag denoting memory allocated for user-space threads and module execution.
Definition alloc.h:69
#define SOF_MEM_FLAG_KERNEL
Base allocation flag denoting memory allocated for kernel-space data structures.
Definition alloc.h:67
#define SOF_MEM_FLAG_COHERENT
Allocate uncached / coherent memory address.
Definition alloc.h:53
void sof_heap_free(struct k_heap *heap, void *addr)
Free memory allocated via sof_heap_alloc().
struct ll_schedule_domain * zephyr_ll_domain(void)
Retrieve the global Low-Latency timer scheduling domain descriptor on Zephyr.
static void domain_task_cancel(struct ll_schedule_domain *domain, struct task *task)
Notify the domain that a task has been cancelled.
Definition ll_schedule_domain.h:365
int zephyr_ll_task_sem_alloc(struct task *task)
Allocate a completion semaphore for a Low-Latency task.
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.
Definition ll_schedule_domain.h:437
struct ll_schedule_domain * zephyr_domain_init(int clk)
Initialize the primary timer-driven Low-Latency scheduling domain on Zephyr.
static void domain_disable(struct ll_schedule_domain *domain, int core)
Disable Low-Latency scheduling domain execution on the specified core.
Definition ll_schedule_domain.h:477
static struct ll_schedule_domain * dma_domain_get(void)
Get the primary platform DMA scheduling domain.
Definition ll_schedule_domain.h:215
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.
static void domain_clear(struct ll_schedule_domain *domain)
Clear/disarm the interrupt tick for the domain.
Definition ll_schedule_domain.h:351
#define timer_domain_init(timer, clk)
Definition ll_schedule_domain.h:565
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.
Definition ll_schedule_domain.h:288
int zephyr_ll_task_sem_free(struct task *task)
Free a completion semaphore for a Low-Latency task.
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.
Definition ll_schedule_domain.h:515
static void domain_enable(struct ll_schedule_domain *domain, int core)
Enable Low-Latency scheduling domain execution on the specified core.
Definition ll_schedule_domain.h:463
static struct ll_schedule_domain * timer_domain_get(void)
Get the primary platform timer scheduling domain.
Definition ll_schedule_domain.h:206
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.
Definition ll_schedule_domain.h:414
static void domain_set(struct ll_schedule_domain *domain, uint64_t start)
Configure the next interrupt or tick timestamp for the domain.
Definition ll_schedule_domain.h:339
Memory attributes, cold/hot execution paths, and platform memory inclusions.
#define assert(x)
Definition panic.h:19
Sound Open Firmware global runtime context.
struct sof * sof_get(void)
Get the global Sound Open Firmware runtime instance pointer.
RTOS spinlock primitives and initialization.
static void k_spinlock_init(struct k_spinlock *lock)
Initialize a spinlock structure to the unlocked state.
Definition spinlock.h:25
User-space ABI log levels and binary trace packet header definitions.
Audio component base device "class" used by all other component types.
Definition component.h:587
Low-Latency schedule domain operations table.
Definition ll_schedule_domain.h:62
void(* domain_task_cancel)(struct ll_schedule_domain *domain, struct task *task)
Notification hook invoked when a task within the domain is cancelled.
Definition ll_schedule_domain.h:162
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.
Definition ll_schedule_domain.h:154
void(* domain_clear)(struct ll_schedule_domain *domain)
Clear scheduled domain interrupt / tick timer.
Definition ll_schedule_domain.h:145
void(* domain_disable)(struct ll_schedule_domain *domain, int core)
Disable domain interrupts/triggers on the specified core.
Definition ll_schedule_domain.h:118
int(* domain_register)(struct ll_schedule_domain *domain, struct task *task, void(*handler)(void *arg), void *arg)
Register a real-time task with the domain.
Definition ll_schedule_domain.h:71
int(* domain_unregister)(struct ll_schedule_domain *domain, struct task *task, uint32_t num_tasks)
Unregister a task from the domain.
Definition ll_schedule_domain.h:82
void(* domain_set)(struct ll_schedule_domain *domain, uint64_t start)
Set the next tick timestamp for the domain.
Definition ll_schedule_domain.h:139
void(* domain_enable)(struct ll_schedule_domain *domain, int core)
Enable domain interrupts/triggers on the specified core.
Definition ll_schedule_domain.h:111
Low-Latency scheduling domain instance descriptor.
Definition ll_schedule_domain.h:168
atomic_t enabled_cores
Number of currently enabled cores.
Definition ll_schedule_domain.h:177
uint32_t ticks_per_ms
Number of clock ticks per millisecond.
Definition ll_schedule_domain.h:178
bool full_sync
True if tasks are fully synchronous with no time dependency.
Definition ll_schedule_domain.h:182
bool synchronous
True if tasks in this domain execute synchronously.
Definition ll_schedule_domain.h:181
atomic_t total_num_tasks
Total number of registered tasks across all cores.
Definition ll_schedule_domain.h:176
struct k_spinlock lock
Standard spinlock.
Definition ll_schedule_domain.h:174
void * priv_data
Pointer to private domain driver data.
Definition ll_schedule_domain.h:183
int type
Domain type (SOF_SCHEDULE_LL_TIMER or SOF_SCHEDULE_LL_DMA).
Definition ll_schedule_domain.h:179
bool enabled[CONFIG_CORE_COUNT]
Per-core enablement flags.
Definition ll_schedule_domain.h:184
uint64_t next_tick
Ticks just set for next run.
Definition ll_schedule_domain.h:169
int clk
Source clock identifier.
Definition ll_schedule_domain.h:180
const struct ll_schedule_domain_ops * ops
Domain operations table.
Definition ll_schedule_domain.h:185
uint64_t new_target_tick
For the next set, used during the reschedule stage.
Definition ll_schedule_domain.h:170
struct ll_schedule_domain * platform_timer_domain
Definition sof.h:73
struct ll_schedule_domain * platform_dma_domain
Definition sof.h:76
Core task structure managed by SOF schedulers.
Definition task.h:81