From ad67a4e2f3d68fca42053c56bf51070d0a2d1652 Mon Sep 17 00:00:00 2001 From: Adrian Bonislawski Date: Tue, 18 Jun 2024 11:58:36 +0200 Subject: [PATCH] ipc: add kconfig to switch IPC task scheduler to TWB This will add kconfig option to switch scheduler type for IPC task Signed-off-by: Adrian Bonislawski --- src/include/sof/ipc/common.h | 4 ++++ src/ipc/ipc-common.c | 4 ++++ src/ipc/ipc-zephyr.c | 15 +++++++++++++-- zephyr/Kconfig | 7 +++++++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/include/sof/ipc/common.h b/src/include/sof/ipc/common.h index 43ad023da1ef..562739ffb5c9 100644 --- a/src/include/sof/ipc/common.h +++ b/src/include/sof/ipc/common.h @@ -68,7 +68,11 @@ struct ipc { struct list_item comp_list; /* list of component devices */ /* processing task */ +#if CONFIG_TWB_IPC_TASK + struct task *ipc_task; +#else struct task ipc_task; +#endif #ifdef CONFIG_SOF_TELEMETRY_IO_PERFORMANCE_MEASUREMENTS /* io performance measurement */ diff --git a/src/ipc/ipc-common.c b/src/ipc/ipc-common.c index 244a218d5be8..8f72ac1ba91b 100644 --- a/src/ipc/ipc-common.c +++ b/src/ipc/ipc-common.c @@ -273,7 +273,11 @@ static void ipc_work_handler(struct k_work *work) void ipc_schedule_process(struct ipc *ipc) { +#if CONFIG_TWB_IPC_TASK + schedule_task(ipc->ipc_task, 0, IPC_PERIOD_USEC); +#else schedule_task(&ipc->ipc_task, 0, IPC_PERIOD_USEC); +#endif } int ipc_init(struct sof *sof) diff --git a/src/ipc/ipc-zephyr.c b/src/ipc/ipc-zephyr.c index a410e03123d6..fc2eac10166c 100644 --- a/src/ipc/ipc-zephyr.c +++ b/src/ipc/ipc-zephyr.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -160,9 +161,14 @@ static int ipc_device_resume_handler(const struct device *dev, void *arg) intel_adsp_ipc_set_message_handler(INTEL_ADSP_IPC_HOST_DEV, message_handler, ipc); /* schedule task */ +#if CONFIG_TWB_IPC_TASK + scheduler_twb_task_init(&ipc->ipc_task, SOF_UUID(zipc_task_uuid), + &ipc_task_ops, ipc, 0, "IPC", ZEPHYR_TWB_STACK_SIZE, + CONFIG_TWB_THREAD_MEDIUM_PRIORITY, ZEPHYR_TWB_BUDGET_MAX / 2); +#else schedule_task_init_edf(&ipc->ipc_task, SOF_UUID(zipc_task_uuid), &ipc_task_ops, ipc, 0, 0); - +#endif return 0; } #endif /* CONFIG_PM_DEVICE */ @@ -278,9 +284,14 @@ int platform_ipc_init(struct ipc *ipc) ipc_set_drvdata(ipc, NULL); /* schedule task */ +#if CONFIG_TWB_IPC_TASK + scheduler_twb_task_init(&ipc->ipc_task, SOF_UUID(zipc_task_uuid), + &ipc_task_ops, ipc, 0, "IPC", ZEPHYR_TWB_STACK_SIZE, + CONFIG_TWB_THREAD_MEDIUM_PRIORITY, ZEPHYR_TWB_BUDGET_MAX / 2); +#else schedule_task_init_edf(&ipc->ipc_task, SOF_UUID(zipc_task_uuid), &ipc_task_ops, ipc, 0, 0); - +#endif /* configure interrupt - work is done internally by Zephyr API */ /* attach handlers */ diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 23fb3b5393d1..b4f732778ccd 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -67,6 +67,13 @@ config ZEPHYR_TWB_SCHEDULER Zephyr preemptive threads for each SOF task that has pre-allocated MCPS budget renewed with every system tick. +config TWB_IPC_TASK + bool "use TWB scheduler for IPC task" + default n + depends on ZEPHYR_TWB_SCHEDULER + help + Switch IPC task to TWB scheduler. + config CROSS_CORE_STREAM bool "Enable cross-core connected pipelines" default y if IPC_MAJOR_4