Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/debug/telemetry/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
config SOF_TELEMETRY
bool "enable telemetry"
default n
depends on !SOF_USERSPACE_LL
help
Enables telemetry. Enables performance measurements and debug utilities
that use memory window 2 (debug window) as interface. Measurements include
Expand Down
5 changes: 5 additions & 0 deletions src/include/sof/schedule/ll_schedule.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
struct k_mem_domain *zephyr_ll_mem_domain(void);
struct k_heap *zephyr_ll_heap_init(void);

#endif

/**
Expand Down
42 changes: 39 additions & 3 deletions src/include/sof/schedule/ll_schedule_domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 */
Expand All @@ -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);
#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 *));
#else
domain = rzalloc(SOF_MEM_FLAG_KERNEL | SOF_MEM_FLAG_COHERENT, sizeof(*domain));
#endif
if (!domain)
return NULL;
domain->type = type;
Expand All @@ -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);
#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);
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);

Expand Down Expand Up @@ -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
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declaration of zephyr_domain_thread_tid is placed outside the CONFIG_SOF_USERSPACE_LL guard (lines 103-109) where it logically belongs based on its implementation. This function is only implemented when CONFIG_SOF_USERSPACE_LL is enabled, so its declaration should be within the same conditional block to prevent link errors.

Suggested change
#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

Copilot uses AI. Check for mistakes.

struct ll_schedule_domain *dma_multi_chan_domain_init(struct dma *dma_array,
Expand Down
4 changes: 4 additions & 0 deletions src/init/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ __cold static int primary_core_init(int argc, char *argv[], struct sof *sof)
io_perf_monitor_init();
#endif

#if CONFIG_SOF_USERSPACE_LL
zephyr_ll_resources_init();
#endif

/* init the platform */
if (platform_init(sof) < 0)
sof_panic(SOF_IPC_PANIC_PLATFORM);
Expand Down
1 change: 1 addition & 0 deletions src/schedule/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ config SCHEDULE_DMA_MULTI_CHANNEL
config SCHEDULE_LL_STATS_LOG
bool "Log low-latency scheduler statistics"
default y
depends on !SOF_USERSPACE_LL
help
Log statistics from low-latency scheduler. This is a low overhead
mechanism to gather average and worst-case execution times of
Expand Down
Loading
Loading