From 4f11c63b6f5cd4583666fe99a8c6b22dbcd627f6 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Wed, 18 Nov 2026 15:57:36 +0200 Subject: [PATCH] schedule: dp: do not set the DP thread deadline from the LL user thread With CONFIG_SOF_USERSPACE_LL, scheduler_dp_recalculate() runs in the LL user thread, which has no permission on the DP thread objects. Starting a capture with a DP module, e.g. the DP SRC in sof-ptl-nocodec, oopses the LL thread: os.z_vrfy_k_thread_absolute_deadline_set: syscall z_vrfy_k_thread_absolute_deadline_set failed check: access denied The commit that added scheduler_dp_kick() left the direct k_thread_absolute_deadline_set() call in place, using the thread pointer from task memory. scheduler_dp_kick() already sets the deadline from the kernel-only task record, so drop the direct call. The same commit also converted the deadline from ms to cycles a second time when computing the relative deadline passed to scheduler_dp_kick(), and dropped the update of deadline_clock_ticks that the DP deadline miss telemetry relies on. Pass the already converted value and restore the deadline_clock_ticks update. Fixes: 20c417dcf0e9 ("schedule: dp: add scheduler_dp_kick() for applying DP scheduling results") Signed-off-by: Kai Vehmanen --- src/schedule/zephyr_dp_schedule_application.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/schedule/zephyr_dp_schedule_application.c b/src/schedule/zephyr_dp_schedule_application.c index 830f90db8a38..ea5321ff91ed 100644 --- a/src/schedule/zephyr_dp_schedule_application.c +++ b/src/schedule/zephyr_dp_schedule_application.c @@ -329,16 +329,17 @@ void scheduler_dp_recalculate(struct scheduler_dp_data *dp_sch) /* calculate number of ticks */ deadline = deadline * (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / 1000); - /* calculate number of ticks, scheduler_dp_kick() adds "NOW" */ - deadline_cycles = deadline * - (CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC / 1000); - flags |= SCHEDULER_DP_KICK_DEADLINE; + if (trigger_task) { + /* add to "NOW", overflows are OK */ + uint32_t abs_deadline = dp_sch->last_ll_tick_timestamp + + deadline; - /* set in Zephyr. Note that it may be in past, it does not matter, - * Zephyr still will schedule the thread with earlier deadline - * first - */ - k_thread_absolute_deadline_set(pdata->thread_id, deadline); + pdata->deadline_clock_ticks = abs_deadline ? abs_deadline : 1U; + } + + /* scheduler_dp_kick() adds "NOW" and sets the deadline in Zephyr */ + deadline_cycles = deadline; + flags |= SCHEDULER_DP_KICK_DEADLINE; } }