dp: delayed start should apply to the first DP cycle only

When DP start, copy from DP to LL should be delayed till first
DP deadline time.

In current implementation the cycle counter is set at every
DP scheduler trigger. If DP is - for any reason - scheduled
again before its deadline passes, the counter will be set again
and copying delay time will be too long. In extreme situation
(i.e. if OBS is set to long value when IBS is short - in this case
DP will proceed a short data chunks with a long deadline), it may
lead to permanent stuck in processing.

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
This commit is contained in:
Marcin Szkudlinski 2024-02-07 13:50:05 +01:00 committed by Kai Vehmanen
parent 8b99003733
commit 7c0c8a400c
1 changed files with 5 additions and 8 deletions

View File

@ -36,11 +36,10 @@ struct scheduler_dp_data {
struct task_dp_pdata {
k_tid_t thread_id; /* zephyr thread ID */
uint32_t deadline_clock_ticks; /* dp module deadline in Zephyr ticks */
uint32_t deadline_ll_cycles; /* dp module deadline in LL cycles */
k_thread_stack_t __sparse_cache *p_stack; /* pointer to thread stack */
struct k_sem sem; /* semaphore for task scheduling */
struct processing_module *mod; /* the module to be scheduled */
uint32_t ll_cycles_to_deadline; /* current number of LL cycles till deadline */
uint32_t ll_cycles_to_start; /* current number of LL cycles till delayed start */
};
/* Single CPU-wide lock
@ -233,9 +232,9 @@ void scheduler_dp_ll_tick(void *receiver_data, enum notify_id event_type, void *
struct processing_module *mod = pdata->mod;
/* decrease number of LL ticks/cycles left till the module reaches its deadline */
if (pdata->ll_cycles_to_deadline) {
pdata->ll_cycles_to_deadline--;
if (!pdata->ll_cycles_to_deadline)
if (pdata->ll_cycles_to_start) {
pdata->ll_cycles_to_start--;
if (!pdata->ll_cycles_to_start)
/* deadline reached, clear startup delay flag.
* see dp_startup_delay comment for details
*/
@ -253,7 +252,6 @@ void scheduler_dp_ll_tick(void *receiver_data, enum notify_id event_type, void *
/* set a deadline for given num of ticks, starting now */
k_thread_deadline_set(pdata->thread_id,
pdata->deadline_clock_ticks);
pdata->ll_cycles_to_deadline = pdata->deadline_ll_cycles;
/* trigger the task */
curr_task->state = SOF_TASK_STATE_RUNNING;
@ -391,8 +389,7 @@ static int scheduler_dp_task_shedule(void *data, struct task *task, uint64_t sta
deadline_clock_ticks /= 1000000;
pdata->deadline_clock_ticks = deadline_clock_ticks;
pdata->deadline_ll_cycles = period / LL_TIMER_PERIOD_US;
pdata->ll_cycles_to_deadline = 0;
pdata->ll_cycles_to_start = period / LL_TIMER_PERIOD_US;
pdata->mod->dp_startup_delay = true;
scheduler_dp_unlock(lock_key);