From b8b8de326e167adf8cb645f88ec4c22c27253cbc Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 18:36:12 +0000 Subject: [PATCH 1/5] lib: dma: do not include sof/lib/io.h and the memory map sof/lib/dma.h uses neither the register access helpers of sof/lib/io.h nor the platform memory map, but it brings both into the user-space host, DAI, copier, chain DMA, ASRC and pipeline sources that use the DMA API. Drop the includes. Three kernel sources got them through this header, so they include what they use: zephyr/wrapper.c the register helpers and the memory map, which it included as platform/lib/memory.h instead of through sof/lib/memory.h, zephyr/lib/cpu.c and ipc3/host-page-table.c the memory map. So does dma-legacy.h, which sof/lib/dma.h includes for the builds without the Zephyr native drivers: it uses the register helpers. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/kernel/ipc/ipc3/host-page-table.c | 1 + zephyr/include/sof/lib/dma-legacy.h | 2 ++ zephyr/include/sof/lib/dma.h | 2 -- zephyr/lib/cpu.c | 1 + zephyr/wrapper.c | 3 ++- 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/kernel/ipc/ipc3/host-page-table.c b/src/kernel/ipc/ipc3/host-page-table.c index 4e42b21ac825..56b2335a3a76 100644 --- a/src/kernel/ipc/ipc3/host-page-table.c +++ b/src/kernel/ipc/ipc3/host-page-table.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/zephyr/include/sof/lib/dma-legacy.h b/zephyr/include/sof/lib/dma-legacy.h index cb381ce03363..592ffc87b665 100644 --- a/zephyr/include/sof/lib/dma-legacy.h +++ b/zephyr/include/sof/lib/dma-legacy.h @@ -6,6 +6,8 @@ #ifndef __SOF_LIB_DMA_LEGACY_H__ #define __SOF_LIB_DMA_LEGACY_H__ +#include + /* DMA attributes */ #define DMA_ATTR_BUFFER_ALIGNMENT 0 #define DMA_ATTR_COPY_ALIGNMENT 1 diff --git a/zephyr/include/sof/lib/dma.h b/zephyr/include/sof/lib/dma.h index 261abe8cacea..145478db30f3 100644 --- a/zephyr/include/sof/lib/dma.h +++ b/zephyr/include/sof/lib/dma.h @@ -21,8 +21,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/zephyr/lib/cpu.c b/zephyr/lib/cpu.c index ea407a45a554..7978d6cc2454 100644 --- a/zephyr/lib/cpu.c +++ b/zephyr/lib/cpu.c @@ -19,6 +19,7 @@ static uint32_t mic_disable_status; #endif /* CONFIG_INTEL_ADSP_MIC_PRIVACY */ #include #include +#include #include #include #include diff --git a/zephyr/wrapper.c b/zephyr/wrapper.c index afdc5b54a2e9..d866c7305824 100644 --- a/zephyr/wrapper.c +++ b/zephyr/wrapper.c @@ -13,7 +13,8 @@ #include #include #include -#include +#include +#include #include #include #include From 22ab945d4d0b81850cbae4a10012c5b54a00a5b0 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 18:36:12 +0000 Subject: [PATCH 2/5] rtos: timer: do not include sof/platform.h rtos/timer.h uses nothing from sof/platform.h, which brings the platform definitions and clock headers into every user-space source that reads the cycle counter or the stream timestamps. Drop the include. base_fw_intel.c, zephyr/lib/alloc.c and zephyr/lib/cpu.c used HOST_PAGE_SIZE and platform_boot_complete() through this header, so they include sof/platform.h. dai-zephyr.c got the memory map through this header too, and it uses local_to_host() from it. It defines local_to_host() as a no-op if the platform doesn't, so without the include the code still built but lost the imx8ulp address translation. Include sof/lib/memory.h there. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/audio/dai-zephyr.c | 1 + src/kernel/audio/base_fw_intel.c | 1 + zephyr/include/rtos/timer.h | 1 - zephyr/lib/alloc.c | 1 + zephyr/lib/cpu.c | 1 + 5 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/audio/dai-zephyr.c b/src/audio/dai-zephyr.c index 40d0a9f4902a..2cbdfe998a2c 100644 --- a/src/audio/dai-zephyr.c +++ b/src/audio/dai-zephyr.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/src/kernel/audio/base_fw_intel.c b/src/kernel/audio/base_fw_intel.c index 3d25f89dbd18..43ba7d0011dc 100644 --- a/src/kernel/audio/base_fw_intel.c +++ b/src/kernel/audio/base_fw_intel.c @@ -24,6 +24,7 @@ #include #include +#include #include #include diff --git a/zephyr/include/rtos/timer.h b/zephyr/include/rtos/timer.h index fef53389faac..c430859823bb 100644 --- a/zephyr/include/rtos/timer.h +++ b/zephyr/include/rtos/timer.h @@ -16,7 +16,6 @@ #include #include #include -#include struct comp_dev; struct sof_ipc_stream_posn; diff --git a/zephyr/lib/alloc.c b/zephyr/lib/alloc.c index 87d0fa9d945d..f1148a0e6771 100644 --- a/zephyr/lib/alloc.c +++ b/zephyr/lib/alloc.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include /* for zephyr_ll_user_heap() */ diff --git a/zephyr/lib/cpu.c b/zephyr/lib/cpu.c index 7978d6cc2454..ec5217823f8a 100644 --- a/zephyr/lib/cpu.c +++ b/zephyr/lib/cpu.c @@ -21,6 +21,7 @@ static uint32_t mic_disable_status; #include #include #include +#include #include #include #include From 76bc5ff6263a7171d8f8fdabec481492561cc846 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 18:36:12 +0000 Subject: [PATCH 3/5] schedule: ll_schedule_domain: include rtos/clk.h only for the host domain_init() only uses clock_ms_to_ticks() from rtos/clk.h in the builds without Zephyr. The Zephyr builds compute the ticks with k_ms_to_cyc_ceil64(), but still include the clock header, and with it the platform clock headers, into the user-space scheduler and IPC sources. Only include it when not building for Zephyr. The native_sim platform code used the clock definitions through this header, so it includes rtos/clk.h. No functional change. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- src/include/sof/schedule/ll_schedule_domain.h | 3 +++ src/kernel/platform/posix/posix.c | 1 + 2 files changed, 4 insertions(+) diff --git a/src/include/sof/schedule/ll_schedule_domain.h b/src/include/sof/schedule/ll_schedule_domain.h index 1ef47c005589..c86e37e8b1a5 100644 --- a/src/include/sof/schedule/ll_schedule_domain.h +++ b/src/include/sof/schedule/ll_schedule_domain.h @@ -18,7 +18,10 @@ #include #include #include +#ifndef __ZEPHYR__ +/* for clock_ms_to_ticks() in domain_init() */ #include +#endif #include #include #include diff --git a/src/kernel/platform/posix/posix.c b/src/kernel/platform/posix/posix.c index cea923d91ef1..eb5a55274eb7 100644 --- a/src/kernel/platform/posix/posix.c +++ b/src/kernel/platform/posix/posix.c @@ -2,6 +2,7 @@ // Copyright(c) 2022 Google LLC. All rights reserved. // Author: Andy Ross #include +#include #include #include #include From 076a319b7019f1689a2912af5b16a5c3ef334fd9 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 18:36:12 +0000 Subject: [PATCH 4/5] scripts: kernel_user_partition: allow zephyr/drivers/dma.h The sof_dma_*() system calls in sof/lib/sof_dma.h take Zephyr's struct dma_config and struct dma_status, and their callers use the Zephyr DMA constants, so user-space code needs zephyr/drivers/dma.h. The header has no system calls itself, and Zephyr's own header cannot be split. Remove it from the kernel-only headers, with a note that user-space code must not call its dma_*() driver functions directly, which the include check cannot catch. None does today: the user-space DMA code only uses the sof_dma_*() calls. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- scripts/kernel_user_partition.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/kernel_user_partition.txt b/scripts/kernel_user_partition.txt index 35229aecb7e7..d042068ce196 100644 --- a/scripts/kernel_user_partition.txt +++ b/scripts/kernel_user_partition.txt @@ -55,9 +55,12 @@ zephyr/include/sof/lib/vpage.h # Zephyr headers that only kernel code may include: kernel internals and # driver APIs that are not system calls. +# Not listed on purpose: zephyr/drivers/dma.h. Its types and constants are +# the arguments of the sof_dma_*() system calls in sof/lib/sof_dma.h, so +# user-space code needs them. User-space code must not call its dma_*() +# driver functions directly, which this include check cannot catch. [zephyr-kernel-headers] kernel/include/* -include/zephyr/drivers/dma.h include/zephyr/pm/device_runtime.h # User-space sources that still include kernel-only headers, removed one From 3caff134522bcc5026aa710db1b127fd05be2d53 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 16 Nov 2026 18:36:29 +0000 Subject: [PATCH 5/5] scripts: kernel_user_partition: drop clean sources from the baseline Ten sources no longer include kernel-only headers in any configuration: the ASRC, chain DMA, copier DAI and gain, UAOL, DMA and DAI library sources, the user-space IPC code and the DP scheduler thread and application code. Remove them from the leak baseline. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Liam Girdwood --- scripts/kernel_user_partition.txt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/scripts/kernel_user_partition.txt b/scripts/kernel_user_partition.txt index d042068ce196..2bf6401a1be7 100644 --- a/scripts/kernel_user_partition.txt +++ b/scripts/kernel_user_partition.txt @@ -68,18 +68,13 @@ include/zephyr/pm/device_runtime.h # other user-space source is an error, so this list must only shrink. # It covers the CI build configurations and the user-space overlays. [leak-baseline] -src/audio/asrc/asrc.c -src/audio/chain_dma.c src/audio/component.c src/audio/copier/copier.c -src/audio/copier/copier_dai.c -src/audio/copier/copier_gain.c src/audio/copier/copier_host.c src/audio/copier/copier_ipcgtw.c src/audio/dai-zephyr.c src/audio/data_blob.c src/audio/host-zephyr.c -src/audio/intel_uaol.c src/audio/kpb.c src/audio/module_adapter/iadk/kpb_service.cpp src/audio/module_adapter/iadk/system_agent.cpp @@ -93,17 +88,12 @@ src/audio/pipeline/pipeline-xrun.c src/audio/volume/volume.c src/audio/volume/volume_ipc4.c src/debug/tester/tester_simple_dram_test.c -src/ipc/ipc-common.c src/ipc/ipc-helper.c src/ipc/ipc4/dai.c src/ipc/ipc4/handler-user.c src/ipc/ipc4/helper.c -src/lib/dai.c -src/lib/dma.c src/lib/notifier.c src/samples/audio/detect_test.c src/schedule/zephyr_domain.c src/schedule/zephyr_dp_schedule.c -src/schedule/zephyr_dp_schedule_application.c -src/schedule/zephyr_dp_schedule_thread.c src/schedule/zephyr_ll.c