Skip to content

Commit

Permalink
ipc: move delayed IPC sending to the primary core
Browse files Browse the repository at this point in the history
Low level IPC processing should be confined to the primary core. Move
delayed IPC sending to a dedicated work queue with core 0 affinity.

Fixes: #8165
Signed-off-by: Guennadi Liakhovetski <[email protected]>
  • Loading branch information
lyakh committed Jan 13, 2025
1 parent decc67e commit 9428f95
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/ipc/ipc-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ void ipc_send_queued_msg(void)
k_spin_unlock(&ipc->lock, key);
}

#ifdef __ZEPHYR__
static struct k_work_q ipc_send_wq;
static K_THREAD_STACK_DEFINE(ipc_send_wq_stack, CONFIG_STACK_SIZE_IPC_TX);
#endif

static void schedule_ipc_worker(void)
{
/*
Expand All @@ -179,7 +184,7 @@ static void schedule_ipc_worker(void)
#ifdef __ZEPHYR__
struct ipc *ipc = ipc_get();

k_work_schedule(&ipc->z_delayed_work, K_USEC(IPC_PERIOD_USEC));
k_work_schedule_for_queue(&ipc_send_wq, &ipc->z_delayed_work, K_USEC(IPC_PERIOD_USEC));
#endif
}

Expand Down Expand Up @@ -305,6 +310,20 @@ int ipc_init(struct sof *sof)
#endif

#ifdef __ZEPHYR__
struct k_thread *thread = &ipc_send_wq.thread;

k_work_queue_start(&ipc_send_wq,
ipc_send_wq_stack,
K_THREAD_STACK_SIZEOF(ipc_send_wq_stack),
1, NULL);

k_thread_suspend(thread);

k_thread_cpu_pin(thread, PLATFORM_PRIMARY_CORE_ID);
k_thread_name_set(thread, "ipc_send_wq");

k_thread_resume(thread);

k_work_init_delayable(&sof->ipc->z_delayed_work, ipc_work_handler);
#endif

Expand Down
6 changes: 6 additions & 0 deletions zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,10 @@ config STACK_SIZE_EDF
help
EDF scheduler work-queue thread stack size. Keep a power of 2.

config STACK_SIZE_IPC_TX
int "IPC sender stack size"
default 2048
help
IPC sender work-queue thread stack size. Keep a power of 2.

endif

0 comments on commit 9428f95

Please sign in to comment.