From 4fe16bb4e3b46c830ec1bbdad1b8b1efe27a69c1 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 15 Nov 2026 22:26:14 +0000 Subject: [PATCH 01/11] rtos: idc: move the message format to rtos/idc_msg.h rtos/idc.h is the IDC driver header: the payload buffers, the driver state, interrupt setup and init. It also has the IDC message format, which user-space code needs to send cross-core component and pipeline messages: the send modes, the message types and fields, struct idc_msg and idc_send_msg(). Because of that, the component API pulls the whole driver header into 14 user-space sources. Move the message format to a new rtos/idc_msg.h, which rtos/idc.h includes, so existing users see no change. The core power-up message stays in rtos/idc.h: its extension is the firmware text address from the platform memory map. The prototypes of idc_cmd_user() and ipc_user_xcore_send(), the user-space LL cross-core path, move too. The host builds have no user/kernel split, so their rtos/idc_msg.h just includes rtos/idc.h. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- posix/include/rtos/idc_msg.h | 19 +++++ zephyr/include/rtos/idc.h | 127 +--------------------------- zephyr/include/rtos/idc_msg.h | 155 ++++++++++++++++++++++++++++++++++ 3 files changed, 175 insertions(+), 126 deletions(-) create mode 100644 posix/include/rtos/idc_msg.h create mode 100644 zephyr/include/rtos/idc_msg.h diff --git a/posix/include/rtos/idc_msg.h b/posix/include/rtos/idc_msg.h new file mode 100644 index 000000000000..81b2f38d8819 --- /dev/null +++ b/posix/include/rtos/idc_msg.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2026 Intel Corporation. + */ + +/** + * \file include/rtos/idc_msg.h + * \brief IDC message format + * + * The host builds are not partitioned into kernel and user space, so + * this is all of rtos/idc.h. + */ + +#ifndef __POSIX_RTOS_IDC_MSG_H__ +#define __POSIX_RTOS_IDC_MSG_H__ + +#include + +#endif /* __POSIX_RTOS_IDC_MSG_H__ */ diff --git a/zephyr/include/rtos/idc.h b/zephyr/include/rtos/idc.h index f47025ff5bf6..a90340860355 100644 --- a/zephyr/include/rtos/idc.h +++ b/zephyr/include/rtos/idc.h @@ -19,130 +19,21 @@ #include #include #include +#include #include -/** \brief IDC send blocking flag. */ -#define IDC_BLOCKING 0 - -/** \brief IDC send non-blocking flag. */ -#define IDC_NON_BLOCKING 1 - -/** \brief IDC send core power up flag. */ -#define IDC_POWER_UP 2 - -/** \brief IDC send core power down flag. */ -#define IDC_POWER_DOWN 3 - /** \brief IDC task deadline. */ #define IDC_DEADLINE 100 /** \brief ROM wake version parsed by ROM during core wake up. */ #define IDC_ROM_WAKE_VERSION 0x2 -/** \brief IDC message type. */ -#define IDC_TYPE_SHIFT 24 -#define IDC_TYPE_MASK 0x7f -#define IDC_TYPE(x) (((x) & IDC_TYPE_MASK) << IDC_TYPE_SHIFT) - -/** \brief IDC message header. */ -#define IDC_HEADER_MASK 0xffffff -#define IDC_HEADER(x) ((x) & IDC_HEADER_MASK) - -/** \brief IDC message extension. */ -#define IDC_EXTENSION_MASK 0x3fffffff -#define IDC_EXTENSION(x) ((x) & IDC_EXTENSION_MASK) - /** \brief IDC power up message. */ #define IDC_MSG_POWER_UP (IDC_TYPE(0x1) | \ IDC_HEADER(IDC_ROM_WAKE_VERSION)) #define IDC_MSG_POWER_UP_EXT IDC_EXTENSION(SOF_TEXT_START >> 2) -/** \brief IDC power down message. */ -#define IDC_MSG_POWER_DOWN IDC_TYPE(0x2) -#define IDC_MSG_POWER_DOWN_EXT IDC_EXTENSION(0x0) - -/** \brief IDC notify message. */ -#define IDC_MSG_NOTIFY IDC_TYPE(0x3) -#define IDC_MSG_NOTIFY_EXT IDC_EXTENSION(0x0) - -/** \brief IDC IPC processing message. */ -#define IDC_MSG_IPC IDC_TYPE(0x4) -#define IDC_MSG_IPC_EXT IDC_EXTENSION(0x0) - -/** \brief IDC component params message. */ -#define IDC_MSG_PARAMS IDC_TYPE(0x5) -#define IDC_MSG_PARAMS_EXT(x) IDC_EXTENSION(x) - -/** \brief IDC component prepare message. */ -#define IDC_MSG_PREPARE IDC_TYPE(0x6) -#define IDC_MSG_PREPARE_EXT(x) IDC_EXTENSION(x) - -/** \brief IDC component trigger message. */ -#define IDC_MSG_TRIGGER IDC_TYPE(0x7) -#define IDC_MSG_TRIGGER_EXT(x) IDC_EXTENSION(x) - -/** \brief IDC component reset message. */ -#define IDC_MSG_RESET IDC_TYPE(0x8) -#define IDC_MSG_RESET_EXT(x) IDC_EXTENSION(x) - -/** \brief IDC prepare D0ix message. */ -#define IDC_MSG_PREPARE_D0ix IDC_TYPE(0x9) -#define IDC_MSG_PREPARE_D0ix_EXT IDC_EXTENSION(0x0) - -/** \brief IDC secondary core crashed notify message. */ -#define IDC_MSG_SECONDARY_CORE_CRASHED IDC_TYPE(0xA) -#define IDC_MSG_SECONDARY_CORE_CRASHED_EXT(x) IDC_EXTENSION(x) - -/** \brief IDC process async msg */ -#define IDC_MSG_AMS IDC_TYPE(0xB) -#define IDC_MSG_AMS_EXT IDC_EXTENSION(0x0) - -#define IDC_HEADER_TO_AMS_SLOT_MASK(x) (x & 0xFFFF) - -#define IDC_MSG_BIND IDC_TYPE(0xD) -#define IDC_MSG_UNBIND IDC_TYPE(0xE) -#define IDC_MSG_GET_ATTRIBUTE IDC_TYPE(0xF) - -/** \brief IDC component delete message. */ -#define IDC_MSG_FREE IDC_TYPE(0x10) -#define IDC_MSG_FREE_EXT(x) IDC_EXTENSION(x) - -/** \brief IDC pipeline set state message. */ -#define IDC_MSG_PPL_STATE IDC_TYPE(0xC) -#define IDC_PPL_STATE_PPL_ID_SHIFT 0 -#define IDC_PPL_STATE_PPL_ID_MASK MASK(23, 0) -#define IDC_PPL_STATE_PHASE_SHIFT 24 -#define IDC_PPL_STATE_PHASE_MASK MASK(27, 24) -#define IDC_PPL_STATE_PHASE_SET(x) (((x) << IDC_PPL_STATE_PHASE_SHIFT) & \ - IDC_PPL_STATE_PHASE_MASK) -#define IDC_PPL_STATE_PHASE_GET(x) (((x) & IDC_PPL_STATE_PHASE_MASK) >> \ - IDC_PPL_STATE_PHASE_SHIFT) -#define IDC_PPL_STATE_PHASE_PREPARE BIT(0) -#define IDC_PPL_STATE_PHASE_TRIGGER BIT(1) -#define IDC_PPL_STATE_PHASE_ONESHOT (IDC_PPL_STATE_PHASE_PREPARE | \ - IDC_PPL_STATE_PHASE_TRIGGER) - -#define IDC_MSG_PPL_STATE_EXT(_ppl_id, _action) \ - IDC_EXTENSION(((_ppl_id) & IDC_PPL_STATE_PPL_ID_MASK) | \ - IDC_PPL_STATE_PHASE_SET(_action)) - -/** \brief IDC_MSG_SECONDARY_CORE_CRASHED header fields. */ -#define IDC_SCC_CORE_SHIFT 0 -#define IDC_SCC_CORE_MASK 0xff -#define IDC_SCC_CORE(x) (((x) & IDC_SCC_CORE_MASK) << IDC_SCC_CORE_SHIFT) - -#define IDC_SCC_REASON_SHIFT 8 -#define IDC_SCC_REASON_MASK 0xff -#define IDC_SCC_REASON(x) (((x) & IDC_SCC_REASON_MASK) << IDC_SCC_REASON_SHIFT) - -/** \brief Secondary core crash reasons. */ -#define IDC_SCC_REASON_WATCHDOG 0x00 -#define IDC_SCC_REASON_EXCEPTION 0x01 - -/** \brief Decodes IDC message type. */ -#define iTS(x) (((x) >> IDC_TYPE_SHIFT) & IDC_TYPE_MASK) - /** \brief Max IDC message payload size in bytes. */ #define IDC_MAX_PAYLOAD_SIZE (DCACHE_LINE_SIZE * 2) @@ -158,15 +49,6 @@ struct idc_payload { uint8_t data[IDC_MAX_PAYLOAD_SIZE]; } __aligned(DCACHE_LINE_SIZE); -/** \brief IDC message. */ -struct idc_msg { - uint32_t header; /**< header value */ - uint32_t extension; /**< extension value */ - uint32_t core; /**< core id */ - uint32_t size; /**< payload size in bytes */ - const void *payload; /**< pointer to payload data */ -}; - /** \brief IDC data. */ struct idc { uint32_t busy_bit_mask; /**< busy interrupt mask */ @@ -202,19 +84,12 @@ enum task_state idc_do_cmd(void *data); void idc_cmd(struct idc_msg *msg); -#ifdef CONFIG_SOF_USERSPACE_LL -int idc_cmd_user(const struct idc_msg *msg, void *payload); -int ipc_user_xcore_send(const struct idc_msg *msg); -#endif - int idc_msg_status_get(uint32_t core); int idc_init(void); void idc_init_thread(void); -int idc_send_msg(struct idc_msg *msg, uint32_t mode); - struct idc **idc_get(void); #endif /* __ZEPHYR_RTOS_IDC_H__ */ diff --git a/zephyr/include/rtos/idc_msg.h b/zephyr/include/rtos/idc_msg.h new file mode 100644 index 000000000000..4541ee7acc61 --- /dev/null +++ b/zephyr/include/rtos/idc_msg.h @@ -0,0 +1,155 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2018 Intel Corporation. All rights reserved. + * + * Author: Tomasz Lauda + */ + +/** + * \file include/rtos/idc_msg.h + * \brief IDC message format, for code that sends IDC messages + * + * User-space code can include this header. The IDC driver and its + * kernel-only state are in rtos/idc.h. + */ + +#ifndef __ZEPHYR_RTOS_IDC_MSG_H__ +#define __ZEPHYR_RTOS_IDC_MSG_H__ + +#include +#include + +/** \brief IDC send blocking flag. */ +#define IDC_BLOCKING 0 + +/** \brief IDC send non-blocking flag. */ +#define IDC_NON_BLOCKING 1 + +/** \brief IDC send core power up flag. */ +#define IDC_POWER_UP 2 + +/** \brief IDC send core power down flag. */ +#define IDC_POWER_DOWN 3 + +/** \brief IDC message type. */ +#define IDC_TYPE_SHIFT 24 +#define IDC_TYPE_MASK 0x7f +#define IDC_TYPE(x) (((x) & IDC_TYPE_MASK) << IDC_TYPE_SHIFT) + +/** \brief IDC message header. */ +#define IDC_HEADER_MASK 0xffffff +#define IDC_HEADER(x) ((x) & IDC_HEADER_MASK) + +/** \brief IDC message extension. */ +#define IDC_EXTENSION_MASK 0x3fffffff +#define IDC_EXTENSION(x) ((x) & IDC_EXTENSION_MASK) + +/** \brief IDC power down message. */ +#define IDC_MSG_POWER_DOWN IDC_TYPE(0x2) +#define IDC_MSG_POWER_DOWN_EXT IDC_EXTENSION(0x0) + +/** \brief IDC notify message. */ +#define IDC_MSG_NOTIFY IDC_TYPE(0x3) +#define IDC_MSG_NOTIFY_EXT IDC_EXTENSION(0x0) + +/** \brief IDC IPC processing message. */ +#define IDC_MSG_IPC IDC_TYPE(0x4) +#define IDC_MSG_IPC_EXT IDC_EXTENSION(0x0) + +/** \brief IDC component params message. */ +#define IDC_MSG_PARAMS IDC_TYPE(0x5) +#define IDC_MSG_PARAMS_EXT(x) IDC_EXTENSION(x) + +/** \brief IDC component prepare message. */ +#define IDC_MSG_PREPARE IDC_TYPE(0x6) +#define IDC_MSG_PREPARE_EXT(x) IDC_EXTENSION(x) + +/** \brief IDC component trigger message. */ +#define IDC_MSG_TRIGGER IDC_TYPE(0x7) +#define IDC_MSG_TRIGGER_EXT(x) IDC_EXTENSION(x) + +/** \brief IDC component reset message. */ +#define IDC_MSG_RESET IDC_TYPE(0x8) +#define IDC_MSG_RESET_EXT(x) IDC_EXTENSION(x) + +/** \brief IDC prepare D0ix message. */ +#define IDC_MSG_PREPARE_D0ix IDC_TYPE(0x9) +#define IDC_MSG_PREPARE_D0ix_EXT IDC_EXTENSION(0x0) + +/** \brief IDC secondary core crashed notify message. */ +#define IDC_MSG_SECONDARY_CORE_CRASHED IDC_TYPE(0xA) +#define IDC_MSG_SECONDARY_CORE_CRASHED_EXT(x) IDC_EXTENSION(x) + +/** \brief IDC process async msg */ +#define IDC_MSG_AMS IDC_TYPE(0xB) +#define IDC_MSG_AMS_EXT IDC_EXTENSION(0x0) + +#define IDC_HEADER_TO_AMS_SLOT_MASK(x) (x & 0xFFFF) + +#define IDC_MSG_BIND IDC_TYPE(0xD) +#define IDC_MSG_UNBIND IDC_TYPE(0xE) +#define IDC_MSG_GET_ATTRIBUTE IDC_TYPE(0xF) + +/** \brief IDC component delete message. */ +#define IDC_MSG_FREE IDC_TYPE(0x10) +#define IDC_MSG_FREE_EXT(x) IDC_EXTENSION(x) + +/** \brief IDC pipeline set state message. */ +#define IDC_MSG_PPL_STATE IDC_TYPE(0xC) +#define IDC_PPL_STATE_PPL_ID_SHIFT 0 +#define IDC_PPL_STATE_PPL_ID_MASK MASK(23, 0) +#define IDC_PPL_STATE_PHASE_SHIFT 24 +#define IDC_PPL_STATE_PHASE_MASK MASK(27, 24) +#define IDC_PPL_STATE_PHASE_SET(x) (((x) << IDC_PPL_STATE_PHASE_SHIFT) & \ + IDC_PPL_STATE_PHASE_MASK) +#define IDC_PPL_STATE_PHASE_GET(x) (((x) & IDC_PPL_STATE_PHASE_MASK) >> \ + IDC_PPL_STATE_PHASE_SHIFT) +#define IDC_PPL_STATE_PHASE_PREPARE BIT(0) +#define IDC_PPL_STATE_PHASE_TRIGGER BIT(1) +#define IDC_PPL_STATE_PHASE_ONESHOT (IDC_PPL_STATE_PHASE_PREPARE | \ + IDC_PPL_STATE_PHASE_TRIGGER) + +#define IDC_MSG_PPL_STATE_EXT(_ppl_id, _action) \ + IDC_EXTENSION(((_ppl_id) & IDC_PPL_STATE_PPL_ID_MASK) | \ + IDC_PPL_STATE_PHASE_SET(_action)) + +/** \brief IDC_MSG_SECONDARY_CORE_CRASHED header fields. */ +#define IDC_SCC_CORE_SHIFT 0 +#define IDC_SCC_CORE_MASK 0xff +#define IDC_SCC_CORE(x) (((x) & IDC_SCC_CORE_MASK) << IDC_SCC_CORE_SHIFT) + +#define IDC_SCC_REASON_SHIFT 8 +#define IDC_SCC_REASON_MASK 0xff +#define IDC_SCC_REASON(x) (((x) & IDC_SCC_REASON_MASK) << IDC_SCC_REASON_SHIFT) + +/** \brief Secondary core crash reasons. */ +#define IDC_SCC_REASON_WATCHDOG 0x00 +#define IDC_SCC_REASON_EXCEPTION 0x01 + +/** \brief Decodes IDC message type. */ +#define iTS(x) (((x) >> IDC_TYPE_SHIFT) & IDC_TYPE_MASK) + +/** \brief IDC message. */ +struct idc_msg { + uint32_t header; /**< header value */ + uint32_t extension; /**< extension value */ + uint32_t core; /**< core id */ + uint32_t size; /**< payload size in bytes */ + const void *payload; /**< pointer to payload data */ +}; + +/** + * \brief Sends an IDC message to another core. + * + * In user-space LL builds, messages sent from user threads are forwarded + * to the user IPC thread of the target core. + */ +int idc_send_msg(struct idc_msg *msg, uint32_t mode); + +#ifdef CONFIG_SOF_USERSPACE_LL +/* cross-core component messages between the user-space IPC and LL threads */ +int idc_cmd_user(const struct idc_msg *msg, void *payload); +int ipc_user_xcore_send(const struct idc_msg *msg); +#endif + +#endif /* __ZEPHYR_RTOS_IDC_MSG_H__ */ From 408ad8b2879bb6d3e1cf0584847dccb1c0343db3 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 15 Nov 2026 22:26:27 +0000 Subject: [PATCH 02/11] schedule: declare zephyr_ll_user_heap() in ll_schedule.h zephyr_ll_user_heap() returns the address of the user-space LL heap, and user-space code passes it to the heap system calls. It is declared in ll_schedule_domain.h with the LL domain internals, which include the platform clock headers and the memory map. Move the declaration to the user-space LL section of ll_schedule.h, next to the user LL lock helpers. ll_schedule_domain.h includes ll_schedule.h, so its users still see it. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/include/sof/schedule/ll_schedule.h | 8 ++++++++ src/include/sof/schedule/ll_schedule_domain.h | 6 ------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/include/sof/schedule/ll_schedule.h b/src/include/sof/schedule/ll_schedule.h index e3c9bc40c3c1..2e667daed5ac 100644 --- a/src/include/sof/schedule/ll_schedule.h +++ b/src/include/sof/schedule/ll_schedule.h @@ -85,6 +85,14 @@ void user_ll_assert_locked(int core); #else static inline void user_ll_assert_locked(int core) { ARG_UNUSED(core); } #endif + +struct k_heap; + +/** + * @brief Get the user-space heap for Low-Latency scheduling structures. + * @return Pointer to the k_heap instance. + */ +struct k_heap *zephyr_ll_user_heap(void); #endif /* CONFIG_SOF_USERSPACE_LL */ /* ll tracing */ diff --git a/src/include/sof/schedule/ll_schedule_domain.h b/src/include/sof/schedule/ll_schedule_domain.h index 0b25b839ecef..29648775afb6 100644 --- a/src/include/sof/schedule/ll_schedule_domain.h +++ b/src/include/sof/schedule/ll_schedule_domain.h @@ -209,12 +209,6 @@ static inline struct ll_schedule_domain *dma_domain_get(void) */ struct task *zephyr_ll_task_alloc(void); -/** - * @brief Get the user-space heap for Low-Latency scheduling structures. - * @return Pointer to the k_heap instance. - */ -struct k_heap *zephyr_ll_user_heap(void); - /** * @brief Verify that a pointer belongs to the user-space LL heap. * @param[in] heap Heap handle to check. From b55502ee1847383a9a38576178dfe77c37b8879a Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 15 Nov 2026 22:26:27 +0000 Subject: [PATCH 03/11] audio: component_ext: include only the IDC message format component_ext.h includes the IDC driver header, rtos/idc.h, for the cross-core component helpers, and ll_schedule_domain.h for zephyr_ll_user_heap(). Both pull kernel-only headers into every user-space source that uses the component API: rtos/idc.h, and through ll_schedule_domain.h the platform clock headers and the memory map. Include rtos/idc_msg.h, which has all that the helpers use, and ll_schedule.h, which now declares zephyr_ll_user_heap(). No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/include/sof/audio/component_ext.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/sof/audio/component_ext.h b/src/include/sof/audio/component_ext.h index c0496650df2a..9a0ad328fec1 100644 --- a/src/include/sof/audio/component_ext.h +++ b/src/include/sof/audio/component_ext.h @@ -19,8 +19,8 @@ #include #include /* in user-space LL builds idc_send_msg() forwards to the remote user IPC thread */ -#include -#include +#include +#include #include /** \addtogroup component_infra_api From 002394edd2e5074dc372884818f44955ac4a0ef7 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 15 Nov 2026 22:26:39 +0000 Subject: [PATCH 04/11] ipc, notifier: include rtos/idc_msg.h instead of rtos/idc.h The user-space halves of ipc-common.c and notifier.c send IDC messages, and ipc-common.c runs forwarded component messages with idc_cmd_user() in the user-space LL build. They use nothing else from the IDC driver header. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/ipc/ipc-common.c | 2 +- src/lib/notifier.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ipc/ipc-common.c b/src/ipc/ipc-common.c index aaa3d6d98123..198fac6d912a 100644 --- a/src/ipc/ipc-common.c +++ b/src/ipc/ipc-common.c @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/lib/notifier.c b/src/lib/notifier.c index 16b1df0dba3d..d3c8d15ebfbf 100644 --- a/src/lib/notifier.c +++ b/src/lib/notifier.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include From f2e1293d54becd8be9735338549ffeb1caaab3ca Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 10:28:44 +0000 Subject: [PATCH 05/11] posix: declare heap_trace_all() in rtos/alloc.h The Zephyr builds declare heap_trace_all() in rtos/alloc.h, but the host builds declare it in sof/lib/mm_heap.h, so user-space code that calls it needs the heap header there. Declare it in the host rtos/alloc.h too, so both builds get it from the same header. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- posix/include/rtos/alloc.h | 3 +++ posix/include/sof/lib/mm_heap.h | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/posix/include/rtos/alloc.h b/posix/include/rtos/alloc.h index 61541172c0c3..34d81ea741c4 100644 --- a/posix/include/rtos/alloc.h +++ b/posix/include/rtos/alloc.h @@ -120,6 +120,9 @@ void sof_heap_free(struct k_heap *heap, void *addr); struct k_heap *sof_sys_heap_get(void); struct k_heap *sof_sys_user_heap_get(void); +/* trace and log memory allocation statistics across all heaps */ +void heap_trace_all(int force); + /* Posix version of struct mod_alloc_ctx without vregion support */ struct vregion; diff --git a/posix/include/sof/lib/mm_heap.h b/posix/include/sof/lib/mm_heap.h index 84bcc893d101..828b479eb9f6 100644 --- a/posix/include/sof/lib/mm_heap.h +++ b/posix/include/sof/lib/mm_heap.h @@ -91,7 +91,6 @@ void init_heap(struct sof *sof); void free_heap(void); /* status */ -void heap_trace_all(int force); void heap_trace(struct mm_heap *heap, int size); #if CONFIG_DEBUG_MEMORY_USAGE_SCAN From bbb719f82653c53280ae1e613de0385f3dab8c02 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 15 Nov 2026 22:26:54 +0000 Subject: [PATCH 06/11] treewide: remove unused kernel-only includes from user-space sources Remove 32 includes of kernel-only headers that user-space sources in src/audio, src/ipc, src/lib and src/schedule do not use: the platform memory map, sof/platform.h, the mailbox, interrupt, clock, IDC, PM runtime, heap, IPC driver, LLEXT manager and user-space helper headers. Each source was compiled without the include in every configuration that builds it, and none of them uses anything that the header declares. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/audio/chain_dma.c | 1 - src/audio/copier/copier_ipcgtw.c | 1 - src/audio/kpb.c | 2 -- src/audio/module_adapter/module_adapter_ipc3.c | 1 - src/audio/pipeline/pipeline-graph.c | 1 - src/ipc/ipc-common.c | 8 -------- src/ipc/ipc-helper.c | 3 --- src/ipc/ipc4/dai.c | 2 -- src/ipc/ipc4/handler-user.c | 4 ---- src/ipc/ipc4/helper.c | 1 - src/lib/dai.c | 1 - src/lib/dma.c | 1 - src/lib/notifier.c | 1 - src/schedule/zephyr_dp_schedule.c | 3 --- src/schedule/zephyr_dp_schedule_application.c | 3 --- src/schedule/zephyr_dp_schedule_thread.c | 1 - src/schedule/zephyr_ll.c | 1 - 17 files changed, 35 deletions(-) diff --git a/src/audio/chain_dma.c b/src/audio/chain_dma.c index 6dc962b38387..b4ceb879f594 100644 --- a/src/audio/chain_dma.c +++ b/src/audio/chain_dma.c @@ -18,7 +18,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 ad3cff9732b8..699518563fa3 100644 --- a/src/audio/copier/copier_ipcgtw.c +++ b/src/audio/copier/copier_ipcgtw.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include "copier.h" diff --git a/src/audio/kpb.c b/src/audio/kpb.c index b2542d1f1f54..7a51db39eae8 100644 --- a/src/audio/kpb.c +++ b/src/audio/kpb.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -32,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/src/audio/module_adapter/module_adapter_ipc3.c b/src/audio/module_adapter/module_adapter_ipc3.c index ab3a5db627c2..ffe5293a4f64 100644 --- a/src/audio/module_adapter/module_adapter_ipc3.c +++ b/src/audio/module_adapter/module_adapter_ipc3.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include diff --git a/src/audio/pipeline/pipeline-graph.c b/src/audio/pipeline/pipeline-graph.c index 2c78d8920df7..ae3eb317b000 100644 --- a/src/audio/pipeline/pipeline-graph.c +++ b/src/audio/pipeline/pipeline-graph.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ipc/ipc-common.c b/src/ipc/ipc-common.c index 198fac6d912a..a7e4d57dbdf5 100644 --- a/src/ipc/ipc-common.c +++ b/src/ipc/ipc-common.c @@ -15,15 +15,11 @@ #include #include #include -#include #include #include #include #include -#include -#include #include -#include #include #include #include @@ -45,10 +41,6 @@ #include #endif -#ifdef CONFIG_SOF_USERSPACE_LL -#include -#endif - #include /* The IPC code that runs in kernel mode is in src/kernel/ipc/ipc-common-kernel.c */ diff --git a/src/ipc/ipc-helper.c b/src/ipc/ipc-helper.c index 50e87ef8a670..c8e82587edf7 100644 --- a/src/ipc/ipc-helper.c +++ b/src/ipc/ipc-helper.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -21,8 +20,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/src/ipc/ipc4/dai.c b/src/ipc/ipc4/dai.c index b0737e3ac09b..63fe9bc9b895 100644 --- a/src/ipc/ipc4/dai.c +++ b/src/ipc/ipc4/dai.c @@ -9,12 +9,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include diff --git a/src/ipc/ipc4/handler-user.c b/src/ipc/ipc4/handler-user.c index 58df68018242..232e81800201 100644 --- a/src/ipc/ipc4/handler-user.c +++ b/src/ipc/ipc4/handler-user.c @@ -18,11 +18,7 @@ #include #include #include -#include #include -#include -#include -#include #include #include #include diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index 8f69c0d635e7..7932050a7707 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/src/lib/dai.c b/src/lib/dai.c index 4bab1fbdc24e..5b196c75eb8f 100644 --- a/src/lib/dai.c +++ b/src/lib/dai.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/src/lib/dma.c b/src/lib/dma.c index 4c454d8d928c..8464f1c9e3d8 100644 --- a/src/lib/dma.c +++ b/src/lib/dma.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/src/lib/notifier.c b/src/lib/notifier.c index d3c8d15ebfbf..cbc9ff5cd7f8 100644 --- a/src/lib/notifier.c +++ b/src/lib/notifier.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/src/schedule/zephyr_dp_schedule.c b/src/schedule/zephyr_dp_schedule.c index ac50500abd7f..da34fdadae48 100644 --- a/src/schedule/zephyr_dp_schedule.c +++ b/src/schedule/zephyr_dp_schedule.c @@ -7,7 +7,6 @@ #include #include -#include #include #include #include @@ -15,12 +14,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include diff --git a/src/schedule/zephyr_dp_schedule_application.c b/src/schedule/zephyr_dp_schedule_application.c index 0d7b8a522cee..c882be05ce1c 100644 --- a/src/schedule/zephyr_dp_schedule_application.c +++ b/src/schedule/zephyr_dp_schedule_application.c @@ -6,16 +6,13 @@ */ #include -#include #include #include #include #include #include -#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 db2311c3d90a..998d1485dacc 100644 --- a/src/schedule/zephyr_dp_schedule_thread.c +++ b/src/schedule/zephyr_dp_schedule_thread.c @@ -7,7 +7,6 @@ */ #include -#include #include #include diff --git a/src/schedule/zephyr_ll.c b/src/schedule/zephyr_ll.c index 7daa415b8fd1..2a6ce7ee1f8e 100644 --- a/src/schedule/zephyr_ll.c +++ b/src/schedule/zephyr_ll.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include From 6fd00bb66957bdbaf5e43654c74ea629864c6a99 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 15 Nov 2026 22:26:54 +0000 Subject: [PATCH 07/11] schedule: ll_schedule_domain: do not include the memory map ll_schedule_domain.h does not use sof/lib/memory.h, the platform memory map. Drop the include, so that the user-space scheduler and IPC sources that include the LL domain header no longer get it. zephyr/lib/alloc.c uses the memory map and got it through this header, so include it there. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/include/sof/schedule/ll_schedule_domain.h | 1 - zephyr/lib/alloc.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/sof/schedule/ll_schedule_domain.h b/src/include/sof/schedule/ll_schedule_domain.h index 29648775afb6..1ef47c005589 100644 --- a/src/include/sof/schedule/ll_schedule_domain.h +++ b/src/include/sof/schedule/ll_schedule_domain.h @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/zephyr/lib/alloc.c b/zephyr/lib/alloc.c index 332635770c50..87d0fa9d945d 100644 --- a/zephyr/lib/alloc.c +++ b/zephyr/lib/alloc.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include From 609b32ebeca42502a5545d11f30d2e343c203b9e Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 15 Nov 2026 22:26:54 +0000 Subject: [PATCH 08/11] lib: dai-zephyr: do not include the memory map and sof/lib/io.h dai-zephyr.h uses neither the platform memory map nor the register access helpers of sof/lib/io.h. Drop both includes, which reached the DAI, copier and pipeline sources that use the DAI API. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/include/sof/lib/dai-zephyr.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/include/sof/lib/dai-zephyr.h b/src/include/sof/lib/dai-zephyr.h index defab09317f9..69a7d965483e 100644 --- a/src/include/sof/lib/dai-zephyr.h +++ b/src/include/sof/lib/dai-zephyr.h @@ -18,8 +18,6 @@ #include #include -#include -#include #include #include #include From 75f257aafbe9064cc87587a5a63d2d37ef0f0216 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 15 Nov 2026 22:26:54 +0000 Subject: [PATCH 09/11] audio: intel_uaol: include sof/lib/cold.h instead of the memory map intel_uaol.h only needs the __cold attribute from sof/lib/memory.h. Include sof/lib/cold.h, which defines it, instead of the platform memory map. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/include/sof/audio/intel_uaol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/sof/audio/intel_uaol.h b/src/include/sof/audio/intel_uaol.h index 8b7cee072670..6f6947d4c22c 100644 --- a/src/include/sof/audio/intel_uaol.h +++ b/src/include/sof/audio/intel_uaol.h @@ -7,7 +7,7 @@ #define __SOF_AUDIO_INTEL_UAOL_H__ #include -#include +#include #include struct sof_tlv; From 1662e13663fb338dfaac9361583d7ad313266e17 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 15 Nov 2026 22:26:54 +0000 Subject: [PATCH 10/11] ipc4: dmic: do not include sof/drivers/dmic.h The IPC4 DMIC configuration blob definitions in ipc4/dmic.h do not use the DMIC driver header, which only kernel code may include. Drop the include. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/include/ipc4/dmic.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/include/ipc4/dmic.h b/src/include/ipc4/dmic.h index 494c367f6bb0..bcaa9b2c18b1 100644 --- a/src/include/ipc4/dmic.h +++ b/src/include/ipc4/dmic.h @@ -8,7 +8,6 @@ #include #include -#include #include "gateway.h" /** From 9adb8d2cf9405bff275b6f751796ca6a24d507ff Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 15 Nov 2026 22:27:04 +0000 Subject: [PATCH 11/11] scripts: kernel_user_partition: drop clean sources from the baseline module_adapter_ipc3.c and pipeline-params.c no longer include kernel-only headers in any configuration, so remove them from the leak baseline. With them listed, a new leak in either source would not be caught. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- scripts/kernel_user_partition.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/kernel_user_partition.txt b/scripts/kernel_user_partition.txt index fc3894b9e9c9..35229aecb7e7 100644 --- a/scripts/kernel_user_partition.txt +++ b/scripts/kernel_user_partition.txt @@ -82,10 +82,8 @@ src/audio/module_adapter/iadk/kpb_service.cpp src/audio/module_adapter/iadk/system_agent.cpp src/audio/module_adapter/iadk/timestamping_service_provider.cpp src/audio/module_adapter/library/native_system_service.c -src/audio/module_adapter/module_adapter_ipc3.c src/audio/module_adapter/module_adapter_ipc4.c src/audio/pipeline/pipeline-graph.c -src/audio/pipeline/pipeline-params.c src/audio/pipeline/pipeline-schedule.c src/audio/pipeline/pipeline-stream.c src/audio/pipeline/pipeline-xrun.c