Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion src/audio/chain_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ static int chain_task_start(struct comp_dev *dev)
}

pm_policy_state_lock_get(PM_STATE_RUNTIME_IDLE, PM_ALL_SUBSTATES);
cd->chain_task.state = SOF_TASK_STATE_INIT;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also remove 'schedule_task_cancel(&cd->chain_task)' in 'chain_task_pause' ? I think after this change it will not be necessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@makarukp this should be a separate PR, reverting that change - after this is merged

k_spin_unlock(&drivers->lock, key);

return 0;
Expand Down
29 changes: 17 additions & 12 deletions src/schedule/zephyr_ll.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,20 @@ static void zephyr_ll_run(void *data)
{
struct zephyr_ll *sch = data;
struct task *task;
struct list_item *list;
struct list_item *list, *tmp, task_head = LIST_INIT(task_head);
uint32_t flags;

zephyr_ll_lock(sch, &flags);

/*
* We have to traverse the list manually, because we drop the lock while
* executing tasks, at that time tasks can be removed from or added to
* the list.
* We drop the lock while executing tasks, at that time tasks can be
* removed from or added to the list, including the task that was
* executed. Use a temporary list to make sure that the main list is
* always consistent and contains the tasks, that we haven't run in this
* cycle yet.
*/
list = sch->tasks.next;

while (list != &sch->tasks) {
for (list = sch->tasks.next; !list_is_empty(&sch->tasks); list = sch->tasks.next) {
enum task_state state;
struct zephyr_ll_pdata *pdata;

Expand All @@ -190,6 +191,10 @@ static void zephyr_ll_run(void *data)
pdata->run = true;
task->state = SOF_TASK_STATE_RUNNING;

/* Move the task to a temporary list */
list_item_del(list);
list_item_append(list, &task_head);

zephyr_ll_unlock(sch, &flags);

/*
Expand All @@ -207,12 +212,6 @@ static void zephyr_ll_run(void *data)

zephyr_ll_lock(sch, &flags);

/*
* The .next pointer could've been changed while the lock wasn't
* held
*/
list = list->next;

if (pdata->freeing) {
/*
* zephyr_ll_task_free() is trying to free this task.
Expand All @@ -238,6 +237,12 @@ static void zephyr_ll_run(void *data)
}
}

/* Move tasks back */
list_for_item_safe(list, tmp, &task_head) {
list_item_del(list);
list_item_append(list, &sch->tasks);
}

zephyr_ll_unlock(sch, &flags);

notifier_event(sch, NOTIFIER_ID_LL_POST_RUN,
Expand Down