From 74fae84b99dd3f6c003b56d95d322e9fedf4bc6e Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 21 Oct 2026 17:54:27 +0100 Subject: [PATCH 01/10] trace: do not include the platform trace header from sof/trace/trace.h only provides platform_trace_point(), which is used by the trace_point() macro of the sof-logger backend. That backend (trace-soflogger.h) already includes the platform header itself, and without CONFIG_TRACE trace_point() is a no-op defined in trace.h. Including it from trace.h made every user of the logging API depend on the platform headers, and through them on the platform memory map and mailbox. Drop the include. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/include/sof/trace/trace.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/include/sof/trace/trace.h b/src/include/sof/trace/trace.h index bd6a56d87da0..0639ac4adbd9 100644 --- a/src/include/sof/trace/trace.h +++ b/src/include/sof/trace/trace.h @@ -26,9 +26,6 @@ #endif #include -#if !CONFIG_LIBRARY -#include -#endif #include #if CONFIG_ZEPHYR_LOG || CONFIG_LIBRARY || CONFIG_ARCH_POSIX_LIBFUZZER From 03f6411cafef4d037f6588a3ebe2e55986ce2d82 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 21 Oct 2026 17:56:49 +0100 Subject: [PATCH 02/10] lib: perf_cnt: move struct perf_cnt_data to its own header struct task embeds struct perf_cnt_data, so zephyr's rtos/task.h included sof/lib/perf_cnt.h, and with it rtos/timer.h and the platform timer headers. Every user of the scheduler or component API therefore depended on the timer driver headers. Move the plain data structure to sof/lib/perf_cnt_data.h, include that from rtos/task.h, and include sof/lib/perf_cnt.h directly where the counter helpers are used. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/audio/base_fw.c | 1 + src/audio/base_fw_intel.c | 1 + src/audio/component.c | 1 + src/audio/pipeline/pipeline-xrun.c | 1 + src/include/sof/lib/perf_cnt.h | 22 +-------------- src/include/sof/lib/perf_cnt_data.h | 42 +++++++++++++++++++++++++++++ src/ipc/ipc4/dai.c | 1 + src/library_manager/lib_manager.c | 1 + src/schedule/schedule.c | 1 + zephyr/include/rtos/task.h | 2 +- 10 files changed, 51 insertions(+), 22 deletions(-) create mode 100644 src/include/sof/lib/perf_cnt_data.h diff --git a/src/audio/base_fw.c b/src/audio/base_fw.c index 1f6436d3f79e..271d7dc21a08 100644 --- a/src/audio/base_fw.c +++ b/src/audio/base_fw.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/src/audio/base_fw_intel.c b/src/audio/base_fw_intel.c index bcb9fca8e1f2..0d302e7c3fab 100644 --- a/src/audio/base_fw_intel.c +++ b/src/audio/base_fw_intel.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include diff --git a/src/audio/component.c b/src/audio/component.c index 81873c96f78d..9a1623099fef 100644 --- a/src/audio/component.c +++ b/src/audio/component.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/src/audio/pipeline/pipeline-xrun.c b/src/audio/pipeline/pipeline-xrun.c index c535ddbb84a1..9b08318a77fa 100644 --- a/src/audio/pipeline/pipeline-xrun.c +++ b/src/audio/pipeline/pipeline-xrun.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/src/include/sof/lib/perf_cnt.h b/src/include/sof/lib/perf_cnt.h index bcb2a0769630..753fcef36b51 100644 --- a/src/include/sof/lib/perf_cnt.h +++ b/src/include/sof/lib/perf_cnt.h @@ -15,27 +15,7 @@ #define __SOF_LIB_PERF_CNT_H__ #include - -struct perf_cnt_data { - /* current platform clock */ - uint32_t plat_ts; - /* current cpu clock */ - uint32_t cpu_ts; - /* one period module cycles */ - uint32_t plat_delta_last; - /* period module peak cycles within period_cnt */ - uint32_t plat_delta_peak; - /* one period module cycles from cpu clock */ - uint32_t cpu_delta_last; - /* period module peak cycles within period_cnt from cpu clock */ - uint32_t cpu_delta_peak; - /* total cycles within period_cnt */ - uint32_t cpu_delta_sum; - /* accumulate period passed and calculate avg cycles */ - uint32_t period_cnt; - /* indicate which period have peak mcps in current module */ - uint32_t peak_mcps_period_cnt; -}; +#include #if CONFIG_PERFORMANCE_COUNTERS diff --git a/src/include/sof/lib/perf_cnt_data.h b/src/include/sof/lib/perf_cnt_data.h new file mode 100644 index 000000000000..82c4aec86658 --- /dev/null +++ b/src/include/sof/lib/perf_cnt_data.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2019 Intel Corporation. All rights reserved. + * + * Author: Marcin Maka + */ + +/** + * \file include/sof/lib/perf_cnt_data.h + * \brief Performance counter data, without the timer based helpers + * + * Kept separate from sof/lib/perf_cnt.h so that structures embedding the + * counters (tasks, components) do not depend on the timer headers. + */ + +#ifndef __SOF_LIB_PERF_CNT_DATA_H__ +#define __SOF_LIB_PERF_CNT_DATA_H__ + +#include + +struct perf_cnt_data { + /* current platform clock */ + uint32_t plat_ts; + /* current cpu clock */ + uint32_t cpu_ts; + /* one period module cycles */ + uint32_t plat_delta_last; + /* period module peak cycles within period_cnt */ + uint32_t plat_delta_peak; + /* one period module cycles from cpu clock */ + uint32_t cpu_delta_last; + /* period module peak cycles within period_cnt from cpu clock */ + uint32_t cpu_delta_peak; + /* total cycles within period_cnt */ + uint32_t cpu_delta_sum; + /* accumulate period passed and calculate avg cycles */ + uint32_t period_cnt; + /* indicate which period have peak mcps in current module */ + uint32_t peak_mcps_period_cnt; +}; + +#endif /* __SOF_LIB_PERF_CNT_DATA_H__ */ diff --git a/src/ipc/ipc4/dai.c b/src/ipc/ipc4/dai.c index 997916aa7854..491875dca933 100644 --- a/src/ipc/ipc4/dai.c +++ b/src/ipc/ipc4/dai.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include diff --git a/src/library_manager/lib_manager.c b/src/library_manager/lib_manager.c index 1e0a3c111587..8841fe4d58c8 100644 --- a/src/library_manager/lib_manager.c +++ b/src/library_manager/lib_manager.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/src/schedule/schedule.c b/src/schedule/schedule.c index 31f79334b0e4..89691a32d981 100644 --- a/src/schedule/schedule.c +++ b/src/schedule/schedule.c @@ -7,6 +7,7 @@ /* Generic scheduler */ #include +#include #include #include #include diff --git a/zephyr/include/rtos/task.h b/zephyr/include/rtos/task.h index 199f3e552156..563b4b999145 100644 --- a/zephyr/include/rtos/task.h +++ b/zephyr/include/rtos/task.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include /** \addtogroup scheduling_api * @{ From 2cb844b1e9535bd8cdca4a1369a00602a85debe3 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 21 Oct 2026 18:05:17 +0100 Subject: [PATCH 03/10] rtos: split the user data placement macros out of userspace_helper.h rtos/userspace_helper.h mixes two things: the APP_TASK_* and APP_SYSUSER_* attributes that place data in the memory partitions user-space threads can access, and the kernel helpers that create heaps, stacks and memory domain grants. User-space code needs the former and must not depend on the latter. Move the placement attributes to a new rtos/userspace_data.h, for both the zephyr and posix RTOS layers, and include it from rtos/userspace_helper.h so existing users are unaffected. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- posix/include/rtos/userspace_data.h | 22 ++++++++++++++ posix/include/rtos/userspace_helper.h | 5 +--- zephyr/include/rtos/userspace_data.h | 41 ++++++++++++++++++++++++++ zephyr/include/rtos/userspace_helper.h | 19 ++---------- 4 files changed, 67 insertions(+), 20 deletions(-) create mode 100644 posix/include/rtos/userspace_data.h create mode 100644 zephyr/include/rtos/userspace_data.h diff --git a/posix/include/rtos/userspace_data.h b/posix/include/rtos/userspace_data.h new file mode 100644 index 000000000000..f8733f3cf675 --- /dev/null +++ b/posix/include/rtos/userspace_data.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2026 Intel Corporation. + */ + +/** + * \file posix/include/rtos/userspace_data.h + * \brief Placement of data that user-space threads must be able to access. + * + * Only the memory partition placement attributes, so that user-space code + * can use them without the kernel memory domain helpers in + * rtos/userspace_helper.h. + */ +#ifndef __POSIX_RTOS_USERSPACE_DATA_H__ +#define __POSIX_RTOS_USERSPACE_DATA_H__ + +#define APP_TASK_BSS +#define APP_TASK_DATA +#define APP_SYSUSER_BSS +#define APP_SYSUSER_DATA + +#endif /* __POSIX_RTOS_USERSPACE_DATA_H__ */ diff --git a/posix/include/rtos/userspace_helper.h b/posix/include/rtos/userspace_helper.h index bb5d7670e9a1..d1b3c2377393 100644 --- a/posix/include/rtos/userspace_helper.h +++ b/posix/include/rtos/userspace_helper.h @@ -17,10 +17,7 @@ #include -#define APP_TASK_BSS -#define APP_TASK_DATA -#define APP_SYSUSER_BSS -#define APP_SYSUSER_DATA +#include struct sys_heap; diff --git a/zephyr/include/rtos/userspace_data.h b/zephyr/include/rtos/userspace_data.h new file mode 100644 index 000000000000..45019e027cee --- /dev/null +++ b/zephyr/include/rtos/userspace_data.h @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2026 Intel Corporation. + */ + +/** + * \file zephyr/include/rtos/userspace_data.h + * \brief Placement of data that user-space threads must be able to access. + * + * Only the memory partition placement attributes, so that user-space code + * can use them without the kernel memory domain helpers in + * rtos/userspace_helper.h. + */ +#ifndef __ZEPHYR_RTOS_USERSPACE_DATA_H__ +#define __ZEPHYR_RTOS_USERSPACE_DATA_H__ + +#ifndef CONFIG_USERSPACE + +#define APP_TASK_BSS +#define APP_TASK_DATA +#define APP_SYSUSER_BSS +#define APP_SYSUSER_DATA + +#else + +#include + +#define APP_TASK_BSS K_APP_BMEM(common_partition) +#define APP_TASK_DATA K_APP_DMEM(common_partition) + +#ifdef CONFIG_SOF_USERSPACE_LL +#define APP_SYSUSER_BSS K_APP_BMEM(sysuser_partition) +#define APP_SYSUSER_DATA K_APP_DMEM(sysuser_partition) +#else +#define APP_SYSUSER_BSS +#define APP_SYSUSER_DATA +#endif + +#endif /* CONFIG_USERSPACE */ + +#endif /* __ZEPHYR_RTOS_USERSPACE_DATA_H__ */ diff --git a/zephyr/include/rtos/userspace_helper.h b/zephyr/include/rtos/userspace_helper.h index b3b122accf9a..44d03b827bd3 100644 --- a/zephyr/include/rtos/userspace_helper.h +++ b/zephyr/include/rtos/userspace_helper.h @@ -14,27 +14,14 @@ #include -#ifndef CONFIG_USERSPACE -#define APP_TASK_BSS -#define APP_TASK_DATA -#define APP_SYSUSER_BSS -#define APP_SYSUSER_DATA -#else +#include + +#ifdef CONFIG_USERSPACE #include #include #define USER_MOD_HEAP_SIZE ALIGN_UP(CONFIG_SOF_ZEPHYR_USERSPACE_MODULE_HEAP_SIZE, \ CONFIG_MM_DRV_PAGE_SIZE) -#define APP_TASK_BSS K_APP_BMEM(common_partition) -#define APP_TASK_DATA K_APP_DMEM(common_partition) - -#ifdef CONFIG_SOF_USERSPACE_LL -#define APP_SYSUSER_BSS K_APP_BMEM(sysuser_partition) -#define APP_SYSUSER_DATA K_APP_DMEM(sysuser_partition) -#else -#define APP_SYSUSER_BSS -#define APP_SYSUSER_DATA -#endif struct processing_module; struct userspace_context; From c8de082ca7dacb0c913948913ccec4109c36e98e Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 21 Oct 2026 18:38:08 +0100 Subject: [PATCH 04/10] audio: component: drop kernel-only includes from component.h component.h included rtos/idc.h and rtos/userspace_helper.h, which made every component depend on the IDC and memory domain headers. Components only need the user data placement attributes, so include rtos/userspace_data.h instead. The only user of the IDC definitions in the component API is component_ext.h, whose cross-core helpers build and send IDC messages; include rtos/idc.h there instead, marked as a kernel dependency to be moved out of the component API later. Include rtos/idc.h and rtos/userspace_helper.h directly in the kernel files that relied on component.h for them. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/include/sof/audio/component.h | 3 +-- src/include/sof/audio/component_ext.h | 2 ++ src/platform/intel/ace/platform.c | 1 + src/schedule/zephyr_dp_schedule_application.c | 1 + src/schedule/zephyr_dp_schedule_thread.c | 1 + 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/include/sof/audio/component.h b/src/include/sof/audio/component.h index f414811cc3c9..85e70e9ad45a 100644 --- a/src/include/sof/audio/component.h +++ b/src/include/sof/audio/component.h @@ -20,9 +20,8 @@ #include #include #include -#include #include -#include +#include #include #include #include diff --git a/src/include/sof/audio/component_ext.h b/src/include/sof/audio/component_ext.h index 74562203864e..08a594637ae7 100644 --- a/src/include/sof/audio/component_ext.h +++ b/src/include/sof/audio/component_ext.h @@ -18,6 +18,8 @@ #include #include +/* TODO: the cross-core helpers below send IDC messages, which is kernel only */ +#include /** \addtogroup component_infra_api * @{ diff --git a/src/platform/intel/ace/platform.c b/src/platform/intel/ace/platform.c index f19003117e08..d67d5835d8db 100644 --- a/src/platform/intel/ace/platform.c +++ b/src/platform/intel/ace/platform.c @@ -8,6 +8,7 @@ // Janusz Jankowski #include +#include #include #include #include diff --git a/src/schedule/zephyr_dp_schedule_application.c b/src/schedule/zephyr_dp_schedule_application.c index 1ce105392c2f..f160f1d6abcd 100644 --- a/src/schedule/zephyr_dp_schedule_application.c +++ b/src/schedule/zephyr_dp_schedule_application.c @@ -6,6 +6,7 @@ */ #include +#include #include #include diff --git a/src/schedule/zephyr_dp_schedule_thread.c b/src/schedule/zephyr_dp_schedule_thread.c index 43c4b43e35e2..40da93950d07 100644 --- a/src/schedule/zephyr_dp_schedule_thread.c +++ b/src/schedule/zephyr_dp_schedule_thread.c @@ -7,6 +7,7 @@ */ #include +#include #include #include From 9df6dd3291f0c9f98b9d4374492b8dc931af9fa1 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 21 Oct 2026 18:45:28 +0100 Subject: [PATCH 05/10] audio: pipeline: do not include the mailbox header from pipeline.h pipeline.h does not use anything from sof/lib/mailbox.h, but including it made every user of the pipeline or component API depend on the platform mailbox and memory map definitions. Drop the include and include sof/lib/mailbox.h directly in the files that access the mailbox, host box or software registers. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/audio/base_fw.c | 1 + src/audio/copier/copier.c | 1 + src/audio/copier/copier_host.c | 1 + src/audio/copier/copier_ipcgtw.c | 1 + src/audio/data_blob.c | 1 + src/audio/module_adapter/library/userspace_proxy.c | 1 + src/audio/pipeline/pipeline-graph.c | 1 + src/audio/pipeline/pipeline-xrun.c | 1 + src/audio/volume/volume.h | 1 + src/include/sof/audio/pipeline.h | 1 - src/ipc/ipc3/dai.c | 1 + src/ipc/ipc4/dai.c | 1 + src/platform/imx8m_cm7/platform.c | 1 + src/platform/imx95/platform.c | 1 + 14 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/audio/base_fw.c b/src/audio/base_fw.c index 271d7dc21a08..fe67e417e43f 100644 --- a/src/audio/base_fw.c +++ b/src/audio/base_fw.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/src/audio/copier/copier.c b/src/audio/copier/copier.c index 4ec85cb64fba..d4415e1fdc97 100644 --- a/src/audio/copier/copier.c +++ b/src/audio/copier/copier.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "copier.h" #include "host_copier.h" #include "dai_copier.h" diff --git a/src/audio/copier/copier_host.c b/src/audio/copier/copier_host.c index 3e704b2b1163..1d8960dee199 100644 --- a/src/audio/copier/copier_host.c +++ b/src/audio/copier/copier_host.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "copier.h" #include "host_copier.h" diff --git a/src/audio/copier/copier_ipcgtw.c b/src/audio/copier/copier_ipcgtw.c index 29c7780f6423..2e6660dfbafc 100644 --- a/src/audio/copier/copier_ipcgtw.c +++ b/src/audio/copier/copier_ipcgtw.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "copier.h" #include "ipcgtw_copier.h" diff --git a/src/audio/data_blob.c b/src/audio/data_blob.c index a0f0cb0aa9bb..e56ca190be6c 100644 --- a/src/audio/data_blob.c +++ b/src/audio/data_blob.c @@ -12,6 +12,7 @@ #include #include #include +#include LOG_MODULE_REGISTER(data_blob, CONFIG_SOF_LOG_LEVEL); diff --git a/src/audio/module_adapter/library/userspace_proxy.c b/src/audio/module_adapter/library/userspace_proxy.c index 9cda1e9e709e..a861c9670cc5 100644 --- a/src/audio/module_adapter/library/userspace_proxy.c +++ b/src/audio/module_adapter/library/userspace_proxy.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/src/audio/pipeline/pipeline-graph.c b/src/audio/pipeline/pipeline-graph.c index b4e5d5cb4ff5..84dbc528f524 100644 --- a/src/audio/pipeline/pipeline-graph.c +++ b/src/audio/pipeline/pipeline-graph.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/src/audio/pipeline/pipeline-xrun.c b/src/audio/pipeline/pipeline-xrun.c index 9b08318a77fa..af6d9a4062c1 100644 --- a/src/audio/pipeline/pipeline-xrun.c +++ b/src/audio/pipeline/pipeline-xrun.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/src/audio/volume/volume.h b/src/audio/volume/volume.h index 7d25e1fc4c97..b73870d74f1e 100644 --- a/src/audio/volume/volume.h +++ b/src/audio/volume/volume.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/src/include/sof/audio/pipeline.h b/src/include/sof/audio/pipeline.h index a621aee488ab..9409eaec0236 100644 --- a/src/include/sof/audio/pipeline.h +++ b/src/include/sof/audio/pipeline.h @@ -15,7 +15,6 @@ #define __SOF_AUDIO_PIPELINE_H__ #include -#include #include #include #include diff --git a/src/ipc/ipc3/dai.c b/src/ipc/ipc3/dai.c index a118d5e341d3..fcb6a7062939 100644 --- a/src/ipc/ipc3/dai.c +++ b/src/ipc/ipc3/dai.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/src/ipc/ipc4/dai.c b/src/ipc/ipc4/dai.c index 491875dca933..27c8ee8b6f56 100644 --- a/src/ipc/ipc4/dai.c +++ b/src/ipc/ipc4/dai.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/src/platform/imx8m_cm7/platform.c b/src/platform/imx8m_cm7/platform.c index 2da512f3063d..da1da0c90a8b 100644 --- a/src/platform/imx8m_cm7/platform.c +++ b/src/platform/imx8m_cm7/platform.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include diff --git a/src/platform/imx95/platform.c b/src/platform/imx95/platform.c index f46500907c91..b7d4bed96b24 100644 --- a/src/platform/imx95/platform.c +++ b/src/platform/imx95/platform.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include From 19a40c2f13f97a19f89d16737b33a27365a60990 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 21 Oct 2026 18:50:56 +0100 Subject: [PATCH 06/10] ipc: topology: drop unused platform and memory includes sof/ipc/topology.h uses nothing from sof/platform.h or sof/lib/memory.h, but including them made most of the audio code depend on the platform headers. Drop them and include sof/platform.h and sof/lib/mailbox.h directly in the i.MX8 platform code, which relied on them. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/drivers/amd/rembrandt/acp_hs_dai.c | 1 + src/include/sof/ipc/topology.h | 2 -- src/platform/imx8/platform.c | 2 ++ src/platform/imx93_a55/platform.c | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/drivers/amd/rembrandt/acp_hs_dai.c b/src/drivers/amd/rembrandt/acp_hs_dai.c index 0901d4d8b696..2dc1d8ef72c4 100644 --- a/src/drivers/amd/rembrandt/acp_hs_dai.c +++ b/src/drivers/amd/rembrandt/acp_hs_dai.c @@ -18,6 +18,7 @@ #include #include #include +#include SOF_DEFINE_REG_UUID(hsdai); /* unused with Zephyr, generates no output */ diff --git a/src/include/sof/ipc/topology.h b/src/include/sof/ipc/topology.h index e04ac5364d4b..d072abc16a24 100644 --- a/src/include/sof/ipc/topology.h +++ b/src/include/sof/ipc/topology.h @@ -13,9 +13,7 @@ #include #include #include -#include #include -#include #include #include #include diff --git a/src/platform/imx8/platform.c b/src/platform/imx8/platform.c index 50d6bb4f4ac6..b07039832c2b 100644 --- a/src/platform/imx8/platform.c +++ b/src/platform/imx8/platform.c @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/src/platform/imx93_a55/platform.c b/src/platform/imx93_a55/platform.c index ed5a7f6956fc..7bc7df3578c6 100644 --- a/src/platform/imx93_a55/platform.c +++ b/src/platform/imx93_a55/platform.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include From 72bfb5fe8338bd9858c2d7f7568b512228b71e73 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 21 Oct 2026 19:23:35 +0100 Subject: [PATCH 07/10] audio: audio_stream: move audio_stream_sync_to_hw() to its own header audio_stream_sync_to_hw() reads a Zephyr struct dma_status, so audio_stream.h included sof/lib/dma.h and with it the Zephyr DMA driver API and the SOF DMA definitions. Only the host and DAI components use this helper. Move it to sof/audio/audio_stream_hw.h, still only defined for Zephyr builds as before, include that from host-zephyr.c and dai-zephyr.c, and drop sof/lib/dma.h from audio_stream.h. The only change in the generated code is the file name and line reported by the helper's assertions. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/audio/dai-zephyr.c | 1 + src/audio/host-zephyr.c | 1 + src/include/sof/audio/audio_stream.h | 30 -------------- src/include/sof/audio/audio_stream_hw.h | 54 +++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 30 deletions(-) create mode 100644 src/include/sof/audio/audio_stream_hw.h diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index 785740e36ab2..d9b753f28227 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -6,6 +6,7 @@ // Keyon Jie #include +#include #include #include #include diff --git a/src/audio/host-zephyr.c b/src/audio/host-zephyr.c index 48936617c9fa..45e2b874aa46 100644 --- a/src/audio/host-zephyr.c +++ b/src/audio/host-zephyr.c @@ -6,6 +6,7 @@ // Keyon Jie #include +#include #include #include #include diff --git a/src/include/sof/audio/audio_stream.h b/src/include/sof/audio/audio_stream.h index 45adb1e4a38a..4f2d3a03c97c 100644 --- a/src/include/sof/audio/audio_stream.h +++ b/src/include/sof/audio/audio_stream.h @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -695,35 +694,6 @@ static inline void audio_stream_consume(struct audio_stream *buffer, uint32_t by buffer->free = buffer->size - buffer->avail; } -#ifdef __ZEPHYR__ -/** - * Replicates the hardware state of the DMA buffer as a struct audio_stream. - * @param stream Stream to update. - * @param dma_status DMA buffer hardware state (struct dma_status from Zephyr). - */ -static inline void audio_stream_sync_to_hw(struct audio_stream *stream, - const struct dma_status *dma_status) -{ - uintptr_t buf_start = (uintptr_t)audio_stream_get_addr(stream); - - /* Note: It is assumed here that dma_status values are reported as bytes. However, - * this is actually platform-specific. Although unlikely, they could be, for example, - * words on some particular platform, and changes should be made here to address - * such case. - */ - - assert(dma_status->write_position < audio_stream_get_size(stream)); - assert(dma_status->read_position < audio_stream_get_size(stream)); - assert(dma_status->pending_length <= audio_stream_get_size(stream)); - assert(dma_status->free <= audio_stream_get_size(stream)); - - audio_stream_set_wptr(stream, (void *)(buf_start + dma_status->write_position)); - audio_stream_set_rptr(stream, (void *)(buf_start + dma_status->read_position)); - audio_stream_set_avail(stream, dma_status->pending_length); - audio_stream_set_free(stream, dma_status->free); -} -#endif /* __ZEPHYR__ */ - /** * Resets the buffer. * @param buffer Buffer to reset. diff --git a/src/include/sof/audio/audio_stream_hw.h b/src/include/sof/audio/audio_stream_hw.h new file mode 100644 index 000000000000..82ae90280be7 --- /dev/null +++ b/src/include/sof/audio/audio_stream_hw.h @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2020 - 2023 Intel Corporation. All rights reserved. + */ + +/** + * \file include/sof/audio/audio_stream_hw.h + * \brief Synchronisation of an audio stream with the state of its DMA buffer + * + * Kept separate from sof/audio/audio_stream.h because it needs the Zephyr + * DMA driver definitions, which most users of the audio stream API do not. + * Only available in Zephyr builds. + */ + +#ifndef __SOF_AUDIO_AUDIO_STREAM_HW_H__ +#define __SOF_AUDIO_AUDIO_STREAM_HW_H__ + +#include +#include + +#ifdef __ZEPHYR__ + +#include + +/** + * Replicates the hardware state of the DMA buffer as a struct audio_stream. + * @param stream Stream to update. + * @param dma_status DMA buffer hardware state (struct dma_status from Zephyr). + */ +static inline void audio_stream_sync_to_hw(struct audio_stream *stream, + const struct dma_status *dma_status) +{ + uintptr_t buf_start = (uintptr_t)audio_stream_get_addr(stream); + + /* Note: It is assumed here that dma_status values are reported as bytes. However, + * this is actually platform-specific. Although unlikely, they could be, for example, + * words on some particular platform, and changes should be made here to address + * such case. + */ + + assert(dma_status->write_position < audio_stream_get_size(stream)); + assert(dma_status->read_position < audio_stream_get_size(stream)); + assert(dma_status->pending_length <= audio_stream_get_size(stream)); + assert(dma_status->free <= audio_stream_get_size(stream)); + + audio_stream_set_wptr(stream, (void *)(buf_start + dma_status->write_position)); + audio_stream_set_rptr(stream, (void *)(buf_start + dma_status->read_position)); + audio_stream_set_avail(stream, dma_status->pending_length); + audio_stream_set_free(stream, dma_status->free); +} + +#endif /* __ZEPHYR__ */ + +#endif /* __SOF_AUDIO_AUDIO_STREAM_HW_H__ */ From 9ab9313fbec4b25f5fca5ce8af3b53f0c0001940 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 21 Oct 2026 19:37:27 +0100 Subject: [PATCH 08/10] audio: component: do not include the DAI and scheduler headers component.h only needs struct dai_data and struct task as opaque types, but it included sof/lib/dai.h and sof/schedule/schedule.h, and with them the Zephyr DAI and DMA driver APIs and the scheduler internals. Every component and module therefore depended on them. Forward declare the two structures instead. component_ext.h does call dai_config() and schedule_task(), so it includes the two headers itself, and the files that relied on component.h for the DAI, DMA or scheduler definitions now include them directly. Also include rtos/atomic.h in the Dolby DAX module header, which uses atomic_t. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/audio/asrc/asrc.c | 1 + src/audio/base_fw.c | 2 ++ src/audio/module_adapter/module/dolby/dax.h | 1 + src/audio/module_adapter/module/generic.c | 1 + src/audio/module_adapter/module_adapter.c | 1 + src/include/sof/audio/component.h | 4 ++-- src/include/sof/audio/component_ext.h | 2 ++ src/platform/intel/ace/platform.c | 1 + src/platform/library/schedule/edf_schedule.c | 1 + src/platform/library/schedule/schedule.c | 1 + src/platform/mtk/platform.c | 1 + src/probe/probe.c | 2 +- src/schedule/zephyr_dp_schedule.c | 1 + src/schedule/zephyr_dp_schedule_application.c | 1 + src/schedule/zephyr_dp_schedule_thread.c | 1 + tools/testbench/file.c | 1 + tools/testbench/utils.c | 1 + zephyr/edf_schedule.c | 1 + zephyr/lib/cpu.c | 1 + 19 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/audio/asrc/asrc.c b/src/audio/asrc/asrc.c index 0f3394a0ace5..b5ebc21b8f4d 100644 --- a/src/audio/asrc/asrc.c +++ b/src/audio/asrc/asrc.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/src/audio/base_fw.c b/src/audio/base_fw.c index fe67e417e43f..17c75c57feba 100644 --- a/src/audio/base_fw.c +++ b/src/audio/base_fw.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include /* FIXME: * Builds for some platforms like tgl fail because their defines related to memory windows are * already defined somewhere else. Remove this ifdef after it's cleaned up diff --git a/src/audio/module_adapter/module/dolby/dax.h b/src/audio/module_adapter/module/dolby/dax.h index eb50db9cd94e..56c71ce7b9e1 100644 --- a/src/audio/module_adapter/module/dolby/dax.h +++ b/src/audio/module_adapter/module/dolby/dax.h @@ -7,6 +7,7 @@ * Author: Jun Lai */ +#include #include #include #include diff --git a/src/audio/module_adapter/module/generic.c b/src/audio/module_adapter/module/generic.c index 885291a74200..137767480e1d 100644 --- a/src/audio/module_adapter/module/generic.c +++ b/src/audio/module_adapter/module/generic.c @@ -20,6 +20,7 @@ #include #include #include +#include #if CONFIG_IPC_MAJOR_4 #include #include diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index 5bbfe1632af5..d7a87a8be32e 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -24,6 +24,7 @@ #include #include #include +#include #if CONFIG_IPC_MAJOR_4 #include #include diff --git a/src/include/sof/audio/component.h b/src/include/sof/audio/component.h index 85e70e9ad45a..3b0c59a2635c 100644 --- a/src/include/sof/audio/component.h +++ b/src/include/sof/audio/component.h @@ -22,9 +22,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -36,6 +34,8 @@ struct sof_ipc_stream_posn; struct dai_hw_params; struct timestamp_data; struct dai_ts_data; +struct dai_data; +struct task; /** \addtogroup component_infra_api * @{ diff --git a/src/include/sof/audio/component_ext.h b/src/include/sof/audio/component_ext.h index 08a594637ae7..691173f1c27a 100644 --- a/src/include/sof/audio/component_ext.h +++ b/src/include/sof/audio/component_ext.h @@ -20,6 +20,8 @@ #include /* TODO: the cross-core helpers below send IDC messages, which is kernel only */ #include +#include +#include /** \addtogroup component_infra_api * @{ diff --git a/src/platform/intel/ace/platform.c b/src/platform/intel/ace/platform.c index d67d5835d8db..806a58a27bd8 100644 --- a/src/platform/intel/ace/platform.c +++ b/src/platform/intel/ace/platform.c @@ -28,6 +28,7 @@ #include #include #include +#include #if CONFIG_INTEL_ADSP_MIC_PRIVACY #include "sof/audio/mic_privacy_manager.h" #endif diff --git a/src/platform/library/schedule/edf_schedule.c b/src/platform/library/schedule/edf_schedule.c index 67c3a669c2f8..1fbfb4a63ada 100644 --- a/src/platform/library/schedule/edf_schedule.c +++ b/src/platform/library/schedule/edf_schedule.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/src/platform/library/schedule/schedule.c b/src/platform/library/schedule/schedule.c index ea4cc33608ac..4ceafd495eb6 100644 --- a/src/platform/library/schedule/schedule.c +++ b/src/platform/library/schedule/schedule.c @@ -8,6 +8,7 @@ // Ranjani Sridharan #include +#include #include #include #include diff --git a/src/platform/mtk/platform.c b/src/platform/mtk/platform.c index 22497cf19641..1cb835717f05 100644 --- a/src/platform/mtk/platform.c +++ b/src/platform/mtk/platform.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/src/probe/probe.c b/src/probe/probe.c index d3746ca05078..22dafba75ac7 100644 --- a/src/probe/probe.c +++ b/src/probe/probe.c @@ -21,9 +21,9 @@ #include #include #include +#include #if CONFIG_IPC_MAJOR_4 #include -#include #include #include #include diff --git a/src/schedule/zephyr_dp_schedule.c b/src/schedule/zephyr_dp_schedule.c index 89a830eb14a6..314f8df5bba0 100644 --- a/src/schedule/zephyr_dp_schedule.c +++ b/src/schedule/zephyr_dp_schedule.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include "zephyr_dp_schedule.h" diff --git a/src/schedule/zephyr_dp_schedule_application.c b/src/schedule/zephyr_dp_schedule_application.c index f160f1d6abcd..80fe50be31de 100644 --- a/src/schedule/zephyr_dp_schedule_application.c +++ b/src/schedule/zephyr_dp_schedule_application.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include diff --git a/src/schedule/zephyr_dp_schedule_thread.c b/src/schedule/zephyr_dp_schedule_thread.c index 40da93950d07..fa8583832a03 100644 --- a/src/schedule/zephyr_dp_schedule_thread.c +++ b/src/schedule/zephyr_dp_schedule_thread.c @@ -17,6 +17,7 @@ #include #include #include +#include #include diff --git a/tools/testbench/file.c b/tools/testbench/file.c index 6e48cc184c38..07159d8c296b 100644 --- a/tools/testbench/file.c +++ b/tools/testbench/file.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/testbench/utils.c b/tools/testbench/utils.c index 91c08c62aab1..5d37caf4099c 100644 --- a/tools/testbench/utils.c +++ b/tools/testbench/utils.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/zephyr/edf_schedule.c b/zephyr/edf_schedule.c index f00ad28b217a..3578b3dd6c7d 100644 --- a/zephyr/edf_schedule.c +++ b/zephyr/edf_schedule.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include diff --git a/zephyr/lib/cpu.c b/zephyr/lib/cpu.c index c2f654509a34..ea407a45a554 100644 --- a/zephyr/lib/cpu.c +++ b/zephyr/lib/cpu.c @@ -20,6 +20,7 @@ static uint32_t mic_disable_status; #include #include #include +#include #include #include #include From 3c7620cb404fcb9d7c17f1fe952b301cfe517924 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 21 Oct 2026 19:50:18 +0100 Subject: [PATCH 09/10] audio: remove unused kernel-only includes from audio and IPC code Drop includes of kernel-only headers that the files do not use: rtos/interrupt.h in comp_buffer.c and module_adapter.c, rtos/init.h in copier_ipcgtw.c, sof/lib/mm_heap.h in pipeline-params.c, sof/platform.h in asrc_farrow.c and sof/ipc/driver.h in ipc-helper.c. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/audio/asrc/asrc_farrow.c | 1 - src/audio/buffers/comp_buffer.c | 1 - src/audio/copier/copier_ipcgtw.c | 1 - src/audio/module_adapter/module_adapter.c | 1 - src/audio/pipeline/pipeline-params.c | 1 - src/ipc/ipc-helper.c | 1 - 6 files changed, 6 deletions(-) diff --git a/src/audio/asrc/asrc_farrow.c b/src/audio/asrc/asrc_farrow.c index dcd58fad22bf..00883bb279ba 100644 --- a/src/audio/asrc/asrc_farrow.c +++ b/src/audio/asrc/asrc_farrow.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/src/audio/buffers/comp_buffer.c b/src/audio/buffers/comp_buffer.c index f86328e244b3..09f5610559e8 100644 --- a/src/audio/buffers/comp_buffer.c +++ b/src/audio/buffers/comp_buffer.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include diff --git a/src/audio/copier/copier_ipcgtw.c b/src/audio/copier/copier_ipcgtw.c index 2e6660dfbafc..7b53e9aba0d6 100644 --- a/src/audio/copier/copier_ipcgtw.c +++ b/src/audio/copier/copier_ipcgtw.c @@ -11,7 +11,6 @@ #include #include #include -#include #include "copier.h" #include "ipcgtw_copier.h" diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index d7a87a8be32e..3ccae18cbe09 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -30,7 +30,6 @@ #include #include #endif -#include #include #include #include diff --git a/src/audio/pipeline/pipeline-params.c b/src/audio/pipeline/pipeline-params.c index ed32fc9e3b02..afa7b7ec739e 100644 --- a/src/audio/pipeline/pipeline-params.c +++ b/src/audio/pipeline/pipeline-params.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ipc/ipc-helper.c b/src/ipc/ipc-helper.c index c8b7f0213f1b..a8a36a94e774 100644 --- a/src/ipc/ipc-helper.c +++ b/src/ipc/ipc-helper.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include From 5a7b58a05d9963717330110ffc32b8c96f791130 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 21 Oct 2026 19:50:33 +0100 Subject: [PATCH 10/10] scripts: kernel_user_partition: allow module registration rtos/init.h only provides SOF_MODULE_INIT(), the hook every audio module uses to register its driver. It is part of the module API rather than a kernel-only interface, so stop reporting it as a kernel-only include. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- scripts/kernel_user_partition.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/kernel_user_partition.txt b/scripts/kernel_user_partition.txt index 657492223121..cf913dd07713 100644 --- a/scripts/kernel_user_partition.txt +++ b/scripts/kernel_user_partition.txt @@ -37,6 +37,8 @@ src/audio/mic_privacy_manager/* src/audio/module_adapter/library/userspace_proxy.c # SOF headers that only kernel code may include. +# Not listed on purpose: rtos/init.h, which only provides the +# SOF_MODULE_INIT() registration hook used by every module. [kernel-headers] src/include/sof/drivers/* src/include/sof/platform.h @@ -51,7 +53,6 @@ src/include/sof/lib/watchdog.h src/platform/* zephyr/include/rtos/clk.h zephyr/include/rtos/idc.h -zephyr/include/rtos/init.h zephyr/include/rtos/interrupt.h zephyr/include/rtos/interrupt-legacy.h zephyr/include/rtos/timer.h