Skip to content
Closed
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
3 changes: 3 additions & 0 deletions src/include/sof/ipc/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ struct ipc {
/* processing task */
struct task ipc_task;

/* task for flushing outbound messages */
struct task ipc_tx_task;

void *private;
};

Expand Down
29 changes: 29 additions & 0 deletions src/ipc/ipc-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <sof/ipc/common.h>
#include <sof/ipc/msg.h>
#include <sof/ipc/driver.h>
#include <sof/schedule/ll_schedule.h>
#include <sof/ipc/schedule.h>
#include <sof/lib/alloc.h>
#include <sof/lib/cache.h>
Expand Down Expand Up @@ -168,6 +169,9 @@ void ipc_send_queued_msg(void)

key = k_spin_lock(&ipc->lock);

if (ipc->pm_prepare_D3)
goto out;

/* any messages to send ? */
if (list_is_empty(&ipc->msg_list))
goto out;
Expand Down Expand Up @@ -212,6 +216,8 @@ void ipc_msg_send(struct ipc_msg *msg, void *data, bool high_priority)
list_item_append(&msg->list, &ipc->msg_list);
}

schedule_task(&ipc->ipc_tx_task, IPC_PERIOD_USEC, IPC_PERIOD_USEC);

out:
k_spin_unlock(&ipc->lock, key);
}
Expand All @@ -221,6 +227,25 @@ void ipc_schedule_process(struct ipc *ipc)
schedule_task(&ipc->ipc_task, 0, IPC_PERIOD_USEC);
}

static enum task_state ipc_tx_task_run(void *data)
{
struct ipc *ipc = data;
enum task_state ret = SOF_TASK_STATE_RESCHEDULE;
k_spinlock_key_t key;

ipc_send_queued_msg();

key = k_spin_lock(&ipc->lock);

if (ipc->pm_prepare_D3 ||
list_is_empty(&ipc->msg_list))
ret = SOF_TASK_STATE_COMPLETED;

k_spin_unlock(&ipc->lock, key);

return ret;
}

int ipc_init(struct sof *sof)
{
tr_info(&ipc_tr, "ipc_init()");
Expand All @@ -234,6 +259,10 @@ int ipc_init(struct sof *sof)
list_init(&sof->ipc->msg_list);
list_init(&sof->ipc->comp_list);

schedule_task_init_ll(&sof->ipc->ipc_tx_task, SOF_UUID(ipc_uuid),

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.

I must be confusing this with something else, wasn't this supposed to be an EDF task?

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.

Yup, I dropped that approached and used LL task instead. We should not rely on the "task start" field in EDF scheduling (it's a feature of the Zephyr SOF EDF scheduler implementation, not part of the interface).

SOF_SCHEDULE_LL_TIMER, SOF_TASK_PRI_MED,
ipc_tx_task_run, sof->ipc, 0, 0);

return platform_ipc_init(sof->ipc);
}

Expand Down
6 changes: 0 additions & 6 deletions src/schedule/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,10 @@ static uint64_t task_main_deadline(void *data)

enum task_state task_main_primary_core(void *data)
{
struct ipc *ipc = ipc_get();

/* main audio processing loop */
while (1) {
/* sleep until next IPC or DMA */
wait_for_interrupt(0);

if (!ipc->pm_prepare_D3)
ipc_send_queued_msg();

}

return SOF_TASK_STATE_COMPLETED;
Expand Down