diff --git a/src/schedule/zephyr_ll.c b/src/schedule/zephyr_ll.c index 59258d397cd1..f68bb8ad590a 100644 --- a/src/schedule/zephyr_ll.c +++ b/src/schedule/zephyr_ll.c @@ -316,11 +316,15 @@ static int zephyr_ll_task_schedule(void *data, struct task *task, uint64_t start list_for_item(list, &sch->tasks) { task_iter = container_of(list, struct task, list); - /* - * keep original start. TODO: this shouldn't be happening. - * Remove after verification - */ if (task_iter == task) { + /* if cancelled, reschedule the task */ + if (task->state == SOF_TASK_STATE_CANCEL) + break; + + /* + * keep original start. TODO: this shouldn't be happening. + * Remove after verification + */ spin_unlock_irq(&sch->lock, flags); tr_warn(&ll_tr, "task %p (%pU) already scheduled", task, task->uid); @@ -333,6 +337,13 @@ static int zephyr_ll_task_schedule(void *data, struct task *task, uint64_t start sch->ll_domain->next_tick > task->start) task->start = sch->ll_domain->next_tick; + if (task->state == SOF_TASK_STATE_CANCEL) { + /* do not queue the same task again */ + task->state = SOF_TASK_STATE_QUEUED; + spin_unlock_irq(&sch->lock, flags); + return 0; + } + zephyr_ll_task_insert_unlocked(sch, task); sch->n_tasks++;