Skip to content

Commit 85f1dbe

Browse files
lyakhkv2019i
authored andcommitted
ipc: move delayed IPC sending to the primary core
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 <guennadi.liakhovetski@linux.intel.com>
1 parent 6a3de61 commit 85f1dbe

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/ipc/ipc-common.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ void ipc_send_queued_msg(void)
170170
k_spin_unlock(&ipc->lock, key);
171171
}
172172

173+
#ifdef __ZEPHYR__
174+
static struct k_work_q ipc_send_wq;
175+
static K_THREAD_STACK_DEFINE(ipc_send_wq_stack, CONFIG_STACK_SIZE_IPC_TX);
176+
#endif
177+
173178
static void schedule_ipc_worker(void)
174179
{
175180
/*
@@ -179,7 +184,7 @@ static void schedule_ipc_worker(void)
179184
#ifdef __ZEPHYR__
180185
struct ipc *ipc = ipc_get();
181186

182-
k_work_schedule(&ipc->z_delayed_work, K_USEC(IPC_PERIOD_USEC));
187+
k_work_schedule_for_queue(&ipc_send_wq, &ipc->z_delayed_work, K_USEC(IPC_PERIOD_USEC));
183188
#endif
184189
}
185190

@@ -296,6 +301,20 @@ int ipc_init(struct sof *sof)
296301
#endif
297302

298303
#ifdef __ZEPHYR__
304+
struct k_thread *thread = &ipc_send_wq.thread;
305+
306+
k_work_queue_start(&ipc_send_wq,
307+
ipc_send_wq_stack,
308+
K_THREAD_STACK_SIZEOF(ipc_send_wq_stack),
309+
1, NULL);
310+
311+
k_thread_suspend(thread);
312+
313+
k_thread_cpu_pin(thread, PLATFORM_PRIMARY_CORE_ID);
314+
k_thread_name_set(thread, "ipc_send_wq");
315+
316+
k_thread_resume(thread);
317+
299318
k_work_init_delayable(&sof->ipc->z_delayed_work, ipc_work_handler);
300319
#endif
301320

zephyr/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,10 @@ config STACK_SIZE_EDF
9797
help
9898
EDF scheduler work-queue thread stack size. Keep a power of 2.
9999

100+
config STACK_SIZE_IPC_TX
101+
int "IPC sender stack size"
102+
default 2048
103+
help
104+
IPC sender work-queue thread stack size. Keep a power of 2.
105+
100106
endif

0 commit comments

Comments
 (0)