Repository navigation
Phase 1: stop user-facing headers pulling in kernel-only headers - #11330
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The application-mode DP scheduler needs direct helper and scheduler includes to preserve compilation after the header cleanup.
1 open issue
What changed in this PR
This PR prepares SOF’s kernel/userspace separation by reducing kernel-header dependencies in user-facing APIs without intended functional changes.
Changes:
- Extract data-placement attributes, performance-counter data, and DMA stream helpers into separate headers.
- Replace transitive dependencies with direct includes where needed.
- Remove unused includes and update kernel-header classification.
| File | Description |
|---|---|
| zephyr/lib/cpu.c | Adds direct DAI dependency. |
| zephyr/include/rtos/userspace_helper.h | Uses extracted placement attributes. |
| zephyr/include/rtos/userspace_data.h | Defines Zephyr placement attributes. |
| zephyr/include/rtos/task.h | Includes counter data without timer helpers. |
| zephyr/edf_schedule.c | Adds direct scheduler dependency. |
| tools/testbench/utils.c | Adds direct scheduler dependency. |
| tools/testbench/file.c | Adds direct DAI dependency. |
| src/schedule/zephyr_dp_schedule.c | Adds direct scheduler dependency. |
| src/schedule/zephyr_dp_schedule_thread.c | Adds helper and scheduler dependencies. |
| src/schedule/schedule.c | Adds direct CPU dependency. |
| src/platform/mtk/platform.c | Adds direct DMA dependency. |
| src/platform/library/schedule/schedule.c | Adds direct scheduler dependency. |
| src/platform/library/schedule/edf_schedule.c | Adds direct scheduler dependency. |
| src/platform/intel/ace/platform.c | Adds IDC and DMA dependencies. |
| src/platform/imx95/platform.c | Adds direct mailbox dependency. |
| src/platform/imx8m_cm7/platform.c | Adds direct mailbox dependency. |
| src/platform/imx8/platform.c | Adds mailbox and platform dependencies. |
| src/library_manager/lib_manager.c | Adds direct timer dependency. |
| src/ipc/ipc4/dai.c | Adds mailbox and timer dependencies. |
| src/ipc/ipc3/dai.c | Adds direct mailbox dependency. |
| src/ipc/ipc-helper.c | Removes unused driver include. |
| src/include/sof/trace/trace.h | Removes platform trace dependency. |
| src/include/sof/lib/perf_cnt.h | Uses extracted counter structure. |
| src/include/sof/lib/perf_cnt_data.h | Defines standalone counter data. |
| src/include/sof/ipc/topology.h | Removes unnecessary kernel includes. |
| src/include/sof/audio/pipeline.h | Removes mailbox dependency. |
| src/include/sof/audio/component.h | Reduces transitive kernel dependencies. |
| src/include/sof/audio/component_ext.h | Keeps dependencies needed by extended helpers. |
| src/include/sof/audio/audio_stream.h | Removes DMA dependency and hardware helper. |
| src/include/sof/audio/audio_stream_hw.h | Houses DMA stream synchronization helper. |
| src/drivers/amd/rembrandt/acp_hs_dai.c | Adds direct register dependency. |
| src/audio/volume/volume.h | Adds direct mailbox dependency. |
| src/audio/pipeline/pipeline-xrun.c | Adds mailbox and timer dependencies. |
| src/audio/pipeline/pipeline-params.c | Removes unused heap include. |
| src/audio/pipeline/pipeline-graph.c | Adds direct mailbox dependency. |
| src/audio/module_adapter/module/generic.c | Adds direct scheduler dependency. |
| src/audio/module_adapter/module/dolby/dax.h | Adds direct atomic dependency. |
| src/audio/module_adapter/module_adapter.c | Adds scheduler include; removes interrupt include. |
| src/audio/module_adapter/library/userspace_proxy.c | Adds direct mailbox dependency. |
| src/audio/host-zephyr.c | Includes relocated DMA stream helper. |
| src/audio/data_blob.c | Adds direct mailbox dependency. |
| src/audio/dai-zephyr.c | Includes relocated DMA stream helper. |
| src/audio/copier/copier.c | Adds direct mailbox dependency. |
| src/audio/copier/copier_ipcgtw.c | Replaces unused initialization include with mailbox include. |
| src/audio/copier/copier_host.c | Adds direct mailbox dependency. |
| src/audio/component.c | Explicitly includes counter helpers. |
| src/audio/buffers/comp_buffer.c | Removes unused interrupt include. |
| src/audio/base_fw.c | Makes kernel dependencies explicit. |
| src/audio/base_fw_intel.c | Adds direct timer dependency. |
| src/audio/asrc/asrc.c | Adds direct DAI dependency. |
| src/audio/asrc/asrc_farrow.c | Removes unused platform include. |
| scripts/kernel_user_partition.txt | Stops classifying initialization header as kernel-only. |
| posix/include/rtos/userspace_helper.h | Uses extracted placement attributes. |
| posix/include/rtos/userspace_data.h | Defines no-op POSIX placement attributes. |
Review effort: Balanced
221a2b8 to
e9e2e46
Compare
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
2 open issues
Review effort: Lite
<platform/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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
e9e2e46 to
5a7b58a
Compare
PR 11330: test resultsRun date: 2026-10-22 15:53 UTC Tested commit: 5a7b58a05d9963717330110ffc32b8c96f791130 |
|
The earlier |


Phase 1 of #11306 (kernel / user-space partition), first part: header hygiene. User-facing headers stop pulling in kernel-only headers they don't need. No functional change.
Each patch either removes an include that isn't used, or moves a definition to a smaller header, so that its users no longer get the rest of a kernel-only header. When a file did use something it only got transitively, it now includes the header directly. That makes the remaining kernel dependencies of user-space code explicit.
Patches
sof/trace/trace.h: no longer includes the platform trace header; only the sof-logger backend needs it, and that backend already includes it.struct perf_cnt_data: moved tosof/lib/perf_cnt_data.h, sortos/task.hno longer pulls inrtos/timer.h.rtos/userspace_data.h(new): theAPP_TASK_*/APP_SYSUSER_*data placement attributes, split out ofrtos/userspace_helper.h(zephyr and posix).component.h:rtos/idc.handrtos/userspace_helper.h;sof/lib/dai.handsof/schedule/schedule.h, using forward declarations instead.component_ext.hkeeps the IDC, DAI and scheduler includes, because its cross-core and DAI helpers use them. They are marked as kernel dependencies to move out later.pipeline.h: drops the unusedsof/lib/mailbox.h; the mailbox users include it directly.sof/ipc/topology.h: drops the unusedsof/platform.handsof/lib/memory.h.audio_stream_sync_to_hw(): moved tosof/audio/audio_stream_hw.h, soaudio_stream.hno longer includessof/lib/dma.hand the Zephyr DMA API.Unused includes: a few kernel-only includes removed from audio and IPC sources.
scripts/kernel_user_partition.txt:rtos/init.h(SOF_MODULE_INIT()) is no longer reported as kernel-only.Effect, measured with
scripts/check_kernel_includes.pyon PTL (number of user-space sources including each header):zephyr/drivers/dma.h,sof/lib/io.hsof/lib/mailbox.hrtos/timer.hrtos/userspace_helper.hrtos/idc.hNot in this PR (Phase 1 continued)
platform.h/clock headers behind it:rtos/alloc.hincludessof/lib/memory.honly forPLATFORM_DCACHE_ALIGN, but that pulls in the platform memory map and, through it,sof/platform.hand the clock headers. That accounts for most of what the checker still reports. Fixing it needs a small user-safe alignment header per platform, because the values differ (32, 64, 128 orDCACHE_LINE_SIZE).component_ext.h(cross-core IDC helpers),sof/lib/dma.h,dai-zephyr.hand the scheduler headers.PLATFORM_MAX_CHANNELS;Testing
audio_stream_sync_to_hw()move: on qemu_xtensa, the only one of these with assertions enabled, the file name and line in its assertions change inhost-zephyr.canddai-zephyr.c.stub_build_all_ipc*.conf), the imx93 64-bit build, and PTL with theuserspace_overlay.confandll_userspace_overlay.confoverlays all build on each commit.acp_dmic_dmadevicetree node that the pinned Zephyr does not have.All of the above was run on 7ea6847 (current main).
🤖 Generated with Claude Code