Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipc: move delayed IPC sending to the primary core #9764

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
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
13 changes: 13 additions & 0 deletions zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,17 @@ config VIRTUAL_HEAP
help
Enabling this option will use the virtual memory heap allocator to allocate buffers.
It is based on a set of buffers whose size is predetermined.

config STACK_SIZE_EDF
int "EDF scheduler stack size"
default 8192
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
2 changes: 1 addition & 1 deletion zephyr/edf_schedule.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <zephyr/sys_clock.h>

static struct k_work_q edf_workq;
static K_THREAD_STACK_DEFINE(edf_workq_stack, 8192);
static K_THREAD_STACK_DEFINE(edf_workq_stack, CONFIG_STACK_SIZE_EDF);

/*
* since only IPC is using the EDF scheduler - we schedule the work in the
Expand Down
Loading