8#ifndef __SOF_SCHEDULE_LL_SCHEDULE_DOMAIN_H__
9#define __SOF_SCHEDULE_LL_SCHEDULE_DOMAIN_H__
19#include <sof/trace/trace.h>
20#include <ipc/topology.h>
25#if defined(CONFIG_AMD)
26#define LL_TIMER_PERIOD_US 500ULL
28#define LL_TIMER_PERIOD_US 1000ULL
35#define LL_WATCHDOG_TIMEOUT_US (2 * LL_TIMER_PERIOD_US)
47 void (*handler)(
void *arg),
void *arg);
49 struct task *
task, uint32_t num_tasks);
50#if CONFIG_SOF_USERSPACE_LL
66#if CONFIG_CROSS_CORE_STREAM
87#ifdef CONFIG_SOF_USERSPACE_LL
104#define ll_sch_domain_set_pdata(domain, data) ((domain)->priv_data = (data))
106#define ll_sch_domain_get_pdata(domain) ((domain)->priv_data)
118#ifdef CONFIG_SOF_USERSPACE_LL
119struct task *zephyr_ll_task_alloc(
void);
120struct k_heap *zephyr_ll_user_heap(
void);
121bool zephyr_ll_user_heap_verify(
struct k_heap *heap);
122void zephyr_ll_user_resources_init(
void);
123void user_ll_grant_access(
struct k_thread *thread,
int core);
124void user_ll_lock_sched(
int core);
125void user_ll_unlock_sched(
int core);
128void user_ll_assert_locked(
int core);
130static inline void user_ll_assert_locked(
int core) { ARG_UNUSED(core); }
140#ifdef CONFIG_SOF_USERSPACE_LL
142 sizeof(*domain),
sizeof(
void *));
144 memset(domain, 0,
sizeof(*domain));
164#ifdef CONFIG_SOF_USERSPACE_LL
166 domain->
lock = k_object_alloc(K_OBJ_MUTEX);
171 k_mutex_init(domain->
lock);
208#if CONFIG_SOF_USERSPACE_LL
218 return domain->
ops->domain_thread_init(domain,
task);
228 if (domain->
ops->domain_thread_free)
229 domain->
ops->domain_thread_free(domain, num_tasks);
235 void (*handler)(
void *arg),
void *arg)
251 struct task *
task, uint32_t num_tasks)
289#if CONFIG_CROSS_CORE_STREAM
292 if (domain->
ops->domain_block)
293 domain->
ops->domain_block(domain);
298 if (domain->
ops->domain_unblock)
299 domain->
ops->domain_unblock(domain);
320#define dma_multi_chan_domain_init(dma_array, num_dma, clk, aggregated_irq)\
321 zephyr_dma_domain_init(dma_array, num_dma, clk)
328#define timer_domain_init(timer, clk) zephyr_domain_init(clk)
329#ifdef CONFIG_SOF_USERSPACE_LL
331struct k_thread *zephyr_domain_thread_tid_for_core(
int core);
332struct k_mem_domain *zephyr_ll_mem_domain(
void);
334#ifdef CONFIG_SOF_FULL_ZEPHYR_APPLICATION
335__syscall
int zephyr_ll_task_sem_alloc(
struct task *
task);
336__syscall
int zephyr_ll_task_sem_free(
struct task *
task);
337#include <zephyr/syscalls/ll_schedule_domain.h>
339int z_impl_zephyr_ll_task_sem_alloc(
struct task *
task);
340int z_impl_zephyr_ll_task_sem_free(
struct task *
task);
341#define zephyr_ll_task_sem_alloc z_impl_zephyr_ll_task_sem_alloc
342#define zephyr_ll_task_sem_free z_impl_zephyr_ll_task_sem_free
347 uint32_t num_dma,
int clk,
348 bool aggregated_irq);
#define atomic_init(p, v)
Definition atomic.h:18
void * rzalloc(uint32_t flags, size_t bytes)
Similar to rmalloc(), guarantees that returned block is zeroed.
void * sof_heap_alloc(struct k_heap *heap, uint32_t flags, size_t bytes, size_t alignment)
#define SOF_MEM_FLAG_USER
Allocate user memory address.
Definition alloc.h:45
#define SOF_MEM_FLAG_KERNEL
Allocate kernel memory address.
Definition alloc.h:43
#define SOF_MEM_FLAG_COHERENT
Allocate uncached address.
Definition alloc.h:37
void sof_heap_free(struct k_heap *heap, void *addr)
static void domain_task_cancel(struct ll_schedule_domain *domain, struct task *task)
Definition ll_schedule_domain.h:201
static void domain_unregister(struct ll_schedule_domain *domain, struct task *task, uint32_t num_tasks)
Definition ll_schedule_domain.h:250
static void domain_disable(struct ll_schedule_domain *domain, int core)
Definition ll_schedule_domain.h:280
static struct ll_schedule_domain * dma_domain_get(void)
Definition ll_schedule_domain.h:113
struct ll_schedule_domain * timer_domain_init(struct timer *timer, int clk)
struct ll_schedule_domain * dma_multi_chan_domain_init(struct dma *dma_array, uint32_t num_dma, int clk, bool aggregated_irq)
struct ll_schedule_domain * dma_single_chan_domain_init(struct dma *dma_array, uint32_t num_dma, int clk)
static void domain_clear(struct ll_schedule_domain *domain)
Definition ll_schedule_domain.h:191
static struct ll_schedule_domain * domain_init(int type, int clk, bool synchronous, const struct ll_schedule_domain_ops *ops)
Definition ll_schedule_domain.h:135
static bool domain_is_pending(struct ll_schedule_domain *domain, struct task *task, struct comp_dev **comp)
Definition ll_schedule_domain.h:303
static void domain_enable(struct ll_schedule_domain *domain, int core)
Definition ll_schedule_domain.h:271
static struct ll_schedule_domain * timer_domain_get(void)
Definition ll_schedule_domain.h:108
static int domain_register(struct ll_schedule_domain *domain, struct task *task, void(*handler)(void *arg), void *arg)
Definition ll_schedule_domain.h:233
static void domain_set(struct ll_schedule_domain *domain, uint64_t start)
Definition ll_schedule_domain.h:182
#define assert(x)
Definition panic.h:19
struct sof * sof_get(void)
static void k_spinlock_init(struct k_spinlock *lock)
Definition spinlock.h:13
Audio component base device "class".
Definition component.h:645
Definition ll_schedule_domain.h:44
void(* domain_task_cancel)(struct ll_schedule_domain *domain, struct task *task)
Definition ll_schedule_domain.h:81
bool(* domain_is_pending)(struct ll_schedule_domain *domain, struct task *task, struct comp_dev **comp)
Definition ll_schedule_domain.h:79
void(* domain_clear)(struct ll_schedule_domain *domain)
Definition ll_schedule_domain.h:78
void(* domain_disable)(struct ll_schedule_domain *domain, int core)
Definition ll_schedule_domain.h:65
int(* domain_register)(struct ll_schedule_domain *domain, struct task *task, void(*handler)(void *arg), void *arg)
Definition ll_schedule_domain.h:45
int(* domain_unregister)(struct ll_schedule_domain *domain, struct task *task, uint32_t num_tasks)
Definition ll_schedule_domain.h:48
void(* domain_set)(struct ll_schedule_domain *domain, uint64_t start)
Definition ll_schedule_domain.h:77
void(* domain_enable)(struct ll_schedule_domain *domain, int core)
Definition ll_schedule_domain.h:64
Definition ll_schedule_domain.h:84
atomic_t enabled_cores
number of enabled cores
Definition ll_schedule_domain.h:93
uint32_t ticks_per_ms
number of clock ticks per ms
Definition ll_schedule_domain.h:94
bool full_sync
tasks should be full synchronous, no time dependent
Definition ll_schedule_domain.h:98
bool synchronous
are tasks should be synchronous
Definition ll_schedule_domain.h:97
atomic_t total_num_tasks
total number of registered tasks
Definition ll_schedule_domain.h:92
struct k_spinlock lock
standard lock
Definition ll_schedule_domain.h:90
void * priv_data
pointer to private data
Definition ll_schedule_domain.h:99
int type
domain type
Definition ll_schedule_domain.h:95
bool enabled[CONFIG_CORE_COUNT]
enabled cores
Definition ll_schedule_domain.h:100
uint64_t next_tick
ticks just set for next run
Definition ll_schedule_domain.h:85
int clk
source clock
Definition ll_schedule_domain.h:96
const struct ll_schedule_domain_ops * ops
domain ops
Definition ll_schedule_domain.h:101
uint64_t new_target_tick
for the next set, used during the reschedule stage
Definition ll_schedule_domain.h:86
struct ll_schedule_domain * platform_timer_domain
Definition sof.h:67
struct ll_schedule_domain * platform_dma_domain
Definition sof.h:70
Task used by schedulers.
Definition task.h:56
uint32_t type
Definition tlv.h:0