Skip to content
Merged
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
19 changes: 15 additions & 4 deletions src/schedule/zephyr_ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

alternatively we could put this test above line 316 inverted and avoid running the loop completely, but maybe this way it's a bit more obvious. Although this does come with a bit of performance penalty compared to the other version :-)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@lyakh hmm, but we can't know for sure "task" is already on the "sch->tasks" list. So I'd keep it here.

I uploaded a new version now. I realized we also need to avoid re-adding the task to the "sch->tasks" lists.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if it is not on the list, we anyway continue after the loop, right? Same as if it is on the list and cancelled. So, the list only makes sense for not cancelled tasks on it.

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);
Expand All @@ -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++;
Expand Down