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 6, 2025
1 parent 2dbedef commit c7b7c91
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 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, 2048);
#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_reschedule_for_queue(&ipc_send_wq, &ipc->z_delayed_work, K_USEC(IPC_PERIOD_USEC));
#endif
}

Expand Down Expand Up @@ -305,6 +310,21 @@ 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_mask_clear(thread);
k_thread_cpu_mask_enable(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

0 comments on commit c7b7c91

Please sign in to comment.