zephyr: switch LL scheduler to native timing API

Use the native Zephyr timing API for LL scheduling.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
This commit is contained in:
Guennadi Liakhovetski 2021-07-02 14:42:00 +02:00 committed by Liam Girdwood
parent 2ece18ff7e
commit 5796bf7eeb
2 changed files with 6 additions and 11 deletions

View File

@ -34,7 +34,7 @@
#define ZEPHYR_LL_STACK_SIZE 8192
#define LL_TIMER_PERIOD_TICKS (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC * LL_TIMER_PERIOD_US / 1000000ULL)
#define LL_TIMER_PERIOD_TICKS (CONFIG_SYS_CLOCK_TICKS_PER_SEC * LL_TIMER_PERIOD_US / 1000000ULL)
K_KERNEL_STACK_ARRAY_DEFINE(ll_sched_stack, CONFIG_CORE_COUNT, ZEPHYR_LL_STACK_SIZE);
@ -70,7 +70,7 @@ static void zephyr_domain_thread_fn(void *p1, void *p2, void *p3)
static void zephyr_domain_timer_fn(struct k_timer *timer)
{
struct zephyr_domain *zephyr_domain = k_timer_user_data_get(timer);
uint64_t now = platform_timer_get(NULL);
uint64_t now = k_uptime_ticks();
int core;
if (!zephyr_domain)
@ -137,8 +137,8 @@ static int zephyr_domain_register(struct ll_schedule_domain *domain,
k_timer_user_data_set(&zephyr_domain->timer, zephyr_domain);
k_timer_start(&zephyr_domain->timer, start, K_USEC(LL_TIMER_PERIOD_US));
domain->next_tick = platform_timer_get_atomic(zephyr_domain->ll_timer) +
k_ticks_to_cyc_ceil64(k_timer_remaining_ticks(&zephyr_domain->timer));
domain->next_tick = k_uptime_ticks() +
k_timer_remaining_ticks(&zephyr_domain->timer);
}
tr_info(&ll_tr, "zephyr_domain_register domain->type %d domain->clk %d domain->ticks_per_ms %d period %d",
@ -181,9 +181,7 @@ static int zephyr_domain_unregister(struct ll_schedule_domain *domain,
static bool zephyr_domain_is_pending(struct ll_schedule_domain *domain,
struct task *task, struct comp_dev **comp)
{
struct zephyr_domain *zephyr_domain = ll_sch_domain_get_pdata(domain);
return task->start <= platform_timer_get_atomic(zephyr_domain->ll_timer);
return task->start <= k_uptime_ticks();
}
static const struct ll_schedule_domain_ops zephyr_domain_ops = {

View File

@ -30,9 +30,6 @@ struct zephyr_ll_pdata {
struct k_sem sem;
};
/* FIXME: would be good to use the timer, configured in the underlying domain */
#define domain_time(sch) platform_timer_get_atomic(timer_get())
/* Locking: caller should hold the domain lock */
static void zephyr_ll_task_done(struct zephyr_ll *sch,
struct task *task)
@ -292,7 +289,7 @@ static int zephyr_ll_task_schedule(void *data, struct task *task, uint64_t start
}
}
task->start = domain_time(sch) + delay;
task->start = k_uptime_ticks() + k_cyc_to_ticks_floor64(delay);
if (sch->ll_domain->next_tick != UINT64_MAX &&
sch->ll_domain->next_tick > task->start)
task->start = sch->ll_domain->next_tick;