Repository navigation
kernel/user partition, Phase 4 part 3: untangle the DMA, timer and LL domain headers - #11470
Merged
Merged
Conversation
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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the header-dependency cleanup supporting kernel/user-space separation.
No open issues 🎉
What changed in this PR
This PR advances the kernel/user-space partition in #11306 by removing unnecessary kernel-header dependencies from shared DMA, timer, and low-latency scheduling headers, with no intended functional change.
Changes:
- Removes transitive kernel includes and adds explicit dependencies where needed.
- Allows the Zephyr DMA header for syscall argument types while documenting that direct driver calls remain prohibited.
- Reduces the include-checker leak baseline from 39 sources to 29.
| File | Description |
|---|---|
zephyr/wrapper.c |
Explicitly includes register helpers and the SOF memory-map wrapper. |
zephyr/lib/cpu.c |
Adds explicit memory-map and platform dependencies. |
zephyr/lib/alloc.c |
Adds an explicit platform dependency. |
zephyr/include/sof/lib/dma.h |
Removes register-access and memory-map includes. |
zephyr/include/sof/lib/dma-legacy.h |
Includes register helpers for legacy DMA. |
zephyr/include/rtos/timer.h |
Removes the platform-header dependency. |
src/kernel/platform/posix/posix.c |
Explicitly includes clock definitions. |
src/kernel/ipc/ipc3/host-page-table.c |
Explicitly includes the memory map. |
src/kernel/audio/base_fw_intel.c |
Adds an explicit platform dependency. |
src/include/sof/schedule/ll_schedule_domain.h |
Limits the clock include to non-Zephyr builds. |
src/audio/dai-zephyr.c |
Explicitly includes memory definitions to preserve address translation. |
scripts/kernel_user_partition.txt |
Reclassifies the Zephyr DMA header and removes ten baseline entries. |
Review effort: Balanced
lgirdwood
marked this pull request as ready for review
November 16, 2026 22:21
lgirdwood
requested review from
abonislawski,
bardliao,
dabekjakub,
dbaluta,
iuliana-prodan,
kv2019i,
lbetlej,
lyakh,
mmaka1,
pblaszko,
plbossart and
tmleman
as code owners
November 16, 2026 22:21
PR 11470: test resultsRun date: 2026-11-17 11:24 UTC Tested commit: 3caff134522bcc5026aa710db1b127fd05be2d53 |
kv2019i
approved these changes
Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 4 of #11306 (kernel / user-space partition), third part: three headers that user-space code needs stop including kernel-only headers they do not use. The DMA headers are reclassified, and the leak baseline shrinks from 39 to 29 sources.
What changes
sof/lib/dma.hno longer includessof/lib/io.h(register access) or the platform memory map. It brought both into every user-space source that uses the DMA API.rtos/timer.hno longer includessof/platform.h. It brought the platform definitions and clock headers into every user-space source that reads the cycle counter.ll_schedule_domain.hincludesrtos/clk.honly in the host builds. That is the only place wheredomain_init()uses it.zephyr/drivers/dma.his no longer a kernel-only header for the checker.sof_dma_*()system calls take Zephyr'sstruct dma_configandstruct dma_status, so user-space code needs the header for their arguments and constants.dma_*()driver functions directly. The include check cannot catch that, so the manifest says so. Today no user-space source does: the user-space DMA code only uses thesof_dma_*()calls.In the CI configurations,
sof/platform.h,sof/lib/io.hand the i.MXsof/drivers/mu.hno longer reach any user-space source, andrtos/clk.honly reaches the two pipeline sources that include it directly. Not counting the reclassified Zephyr header, the (user-space source, kernel-only header) pairs go from 671 to 300.Patches
lib: dma: dropsof/lib/io.hand the memory map fromsof/lib/dma.h. Three kernel sources got them through it and now include them:zephyr/wrapper.ctakes the register helpers and the memory map. It included the platform memory header directly, which only works aftersof/lib/memory.h.zephyr/lib/cpu.candipc3/host-page-table.ctake the memory map.dma-legacy.h, whichsof/lib/dma.hincludes for builds without the Zephyr native drivers, takes the register helpers. Among the platforms that build, only acp_6_0 uses it.rtos: timer: dropsof/platform.h.base_fw_intel.c,zephyr/lib/alloc.candzephyr/lib/cpu.cusedHOST_PAGE_SIZEandplatform_boot_complete()through it and now include it.dai-zephyr.calso got the memory map this way, forlocal_to_host(). It defineslocal_to_host()as a no-op when the platform doesn't, so without the include it still built but lost the imx8ulp address translation. The object comparison caught this, anddai-zephyr.cnow includessof/lib/memory.h. No other object changed.schedule: ll_schedule_domain: includertos/clk.honly when not building for Zephyr. On Zephyr,domain_init()usesk_ms_to_cyc_ceil64(). The native_sim platform code used the clock definitions through this header and now includesrtos/clk.h.scripts: kernel_user_partition: allowzephyr/drivers/dma.h, as described above.What is left
The 29 remaining sources use kernel APIs, not just kernel headers:
rtos/timer.h(11 sources).irq_local_disable()/irq_local_enable()(7 sources).perf_cnt.h,agent.h,cpu-clk-manager.h,watchdog.handpm_runtime.h.Functional change
None.
Testing
--strict, it passes for each of the 12 CI build configurations, built locally as CI does (repro-build.conf,-Werror), and for every other configuration below. Across all of them, exactly the 29 baseline sources leak.CONFIG_SOF_USERSPACE_PROXY=n;os_linux_overlay.conf;llext_relocatable.conf;app/debug_stream_overlay.conf, and PTL with that overlay and user-space LL.SYS_INIT()order), and the per-function disassembly. No object changes at any commit. The only image difference issof_init()on imx8m_cm7, imx93 and imx95, which embeds the git hash.dma-legacy.hdependency; none of the other configurations includes that header, so the other results are unaffected by the fix.All of the above was run on 607d0a9 (current main).
🤖 Generated with Claude Code