Skip to content

Phase 1 (part 4): more include cleanup in user-space code - #11386

Draft
lgirdwood wants to merge 5 commits into
thesofproject:mainfrom
lgirdwood:kernel-user/phase1d
Draft

lgirdwood wants to merge 5 commits into
thesofproject:mainfrom
lgirdwood:kernel-user/phase1d

Conversation

@lgirdwood

@lgirdwood lgirdwood commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Phase 1 of #11306 (kernel / user-space partition), fourth part: more include cleanup in user-space code, with no functional change. Follows #11364.

Patches

  • CONFIG_ACE_VERSION_2_0_OR_LATER (new): a hidden Kconfig option set for ACE 2.0 and later. The copier DAI and IPC4 DAI code use it instead of ACE_VERSION > ACE_VERSION_1_5, which needed the platform version header. zephyr/Kconfig already tests the ACE version the same way.
  • sof/platform.h: dropped from the copier DAI and IPC4 DAI code, which only used it for ACE_VERSION.
  • Platform memory map: the DRC, multiband DRC and SRC sources include sof/lib/cold.h instead of sof/lib/memory.h; __cold is all they used. asrc_farrow.c and src.c drop it.
  • Unused kernel includes: rtos/interrupt.h, rtos/timer.h, rtos/wait.h and rtos/userspace_helper.h are dropped from the audio sources that use nothing from them, and sof/lib_manager.h from modules.c. pipeline-stream.c includes rtos/timer.h, which it uses, instead of rtos/wait.h.
  • Volume peak meter: peak_vol_update() moves from volume.h to volume.c, its only caller, so the other volume sources no longer include sof/lib/mailbox.h.

Effect

Measured with scripts/check_kernel_includes.py on PTL, as the number of user-space sources including each header, before and after this PR:

Header Before After
sof/lib/memory.h (platform memory map) 34 19
sof/lib/mailbox.h 20 12
Platform clock headers / rtos/clk.h 14 11
sof/platform.h 11 8
rtos/userspace_helper.h 10 2
rtos/timer.h 10 8
rtos/interrupt.h 8 5
Any kernel-only header 45 26

Not in this PR

What remains is mostly real kernel use from user-space code:

  • IPC4 mailbox registers: volume peak meter, pipeline registers and the IPC gateway, plus MAILBOX_HOSTBOX_SIZE/MAILBOX_DSPBOX_SIZE in the data blob and module adapter code.
  • DAI and DMA: the copier, dai-zephyr.c, host-zephyr.c, chain DMA, and asrc's DAI timestamping.
  • The IDC dispatchers in component_ext.h: used by the pipeline.
  • Other kernel services:
    • IRQ locking in the pipeline and copier;
    • the cycle counter in kpb and perf_cnt;
    • KCPS;
    • the system agent;
    • lib_manager.h, which is a mixed header.
  • pipeline-stream.c and lib/dma.c: both reach into the copier's private data ("../audio/copier/copier.h"). Fixing that needs a small copier API, which is better discussed on its own.

Testing

  • Per commit:
    • Firmware builds: tgl, tgl-h, mtl, lnl, ptl, wcl, nvl, imx8, imx8x, imx8m, imx8m_cm7, imx8ulp, imx95 and qemu_xtensa.
    • Extra CI configurations:
      • native_sim IPC3/IPC4 stub builds;
      • imx93 64-bit;
      • PTL with each userspace overlay;
      • PTL with CONFIG_SOF_USERSPACE_PROXY=n;
      • PTL and MTL with os_linux_overlay.conf;llext_relocatable.conf.
    • Cadence xt-clang (RI-2022.10): MTL, PTL and NVL compile at every commit, which covers the HiFi code paths that the Zephyr SDK builds never compile.
    • Object comparison: every object file and LLEXT module has the same non-debug section sizes as in the previous commit. CONFIG_ACE_VERSION_2_0_OR_LATER is set on LNL, PTL, WCL and NVL and not on MTL.
    • Host: the host library and cmocka build and pass.
  • At the tip:
    • all cmocka configurations, the testbench and the tools pass;
    • the platforms that already fail on main (acp_6_0, acp_7_0, acp_7_x, mt8186, mt8188, mt8195, mt8196, mt8365) have unchanged error sets.

All of the above was run on 5d007c0 (current main, including #11364).

🤖 Generated with Claude Code

lrgirdwo and others added 5 commits November 1, 2026 19:32
The copier DAI and IPC4 DAI code checks ACE_VERSION > ACE_VERSION_1_5
for the gateway handling that changed after ACE 1.5, which makes it
include sof/platform.h for the ACE version header.

Add a hidden Kconfig option that is set for ACE 2.0 and later, matching
how zephyr/Kconfig already tests the ACE version, and use it instead.
No functional change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
The copier DAI and IPC4 DAI code only included sof/platform.h for
ACE_VERSION, which they no longer use. No functional change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
The DRC, multiband DRC and SRC sources only use __cold from
sof/lib/memory.h, so include sof/lib/cold.h instead. asrc_farrow.c and
src.c use nothing from it. No functional change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
Drop rtos/interrupt.h, rtos/timer.h, rtos/wait.h and
rtos/userspace_helper.h from the audio sources that use nothing from
them, and sof/lib_manager.h from modules.c. pipeline-stream.c includes
rtos/timer.h, whose timestamp helpers it uses, instead of rtos/wait.h.
The pipeline graph, the pipeline scheduler, the copier and the xrun
code keep the includes whose IRQ locking and timer helpers they still
use. No functional change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
peak_vol_update() writes the peak meter to the IPC4 mailbox registers,
and is only called from volume.c. Defining it in volume.h made every
volume source include sof/lib/mailbox.h and, through it, the platform
memory map.

Move it to volume.c, under CONFIG_COMP_PEAK_VOL like its only caller,
and include sof/lib/mailbox.h in volume.c and volume_ipc4.c, the two
sources that write the mailbox. No functional change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Liam Girdwood <[email protected]>
@lgirdwood
lgirdwood force-pushed the kernel-user/phase1d branch from 6757b6e to d5549ca Compare November 1, 2026 19:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the kernel-header dependency cleanup.

No open issues 🎉

What changed in this PR

This PR reduces kernel-header dependencies in SOF user-space code, advancing the kernel/user-space partition in #11306 without intended functional changes. The reviewed diff also includes the stacked cleanup from #11364.

Changes:

  • Replaces platform-header dependencies with Kconfig options, centralized cache helpers, and narrower component and scheduler headers.
  • Removes unused kernel includes and adds direct includes where needed.
  • Moves the volume peak-update helper into volume.c, removing the mailbox dependency from the shared volume header.
File Description
zephyr/​include/​rtos/​cache.h Centralizes platform cache-alias helpers.
test/​cmocka/​src/​audio/​mixer/​mixer_test.c Uses the Kconfig stream limit.
src/​probe/​probe.c Removes unused component extension include.
src/​platform/​tigerlake/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​qemu_xtensa/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​posix/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​posix/​include/​platform/​lib/​memory.h Removes relocated cache-alias macros.
src/​platform/​novalake/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​mtk/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​mtk/​include/​platform/​lib/​memory.h Removes relocated cache-alias macros.
src/​platform/​meteorlake/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​lunarlake/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​library/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​library/​include/​platform/​lib/​memory.h Removes relocated cache-alias macros.
src/​platform/​Kconfig Defines stream limits and ACE-version capability.
src/​platform/​intel/​cavs/​include/​cavs/​lib/​memory.h Removes relocated cache-alias helpers.
src/​platform/​intel/​ace/​include/​ace/​lib/​memory.h Removes relocated cache-alias macros.
src/​platform/​imx95/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​imx95/​include/​platform/​lib/​memory.h Removes relocated cache-alias macros.
src/​platform/​imx93_a55/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​imx93_a55/​include/​platform/​lib/​memory.h Removes relocated cache-alias macros.
src/​platform/​imx8ulp/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​imx8ulp/​include/​platform/​lib/​memory.h Removes relocated cache-alias macros.
src/​platform/​imx8m/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​imx8m/​include/​platform/​lib/​memory.h Removes relocated cache-alias macros.
src/​platform/​imx8m_cm7/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​imx8m_cm7/​include/​platform/​lib/​memory.h Removes relocated cache-alias macros.
src/​platform/​imx8/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​imx8/​include/​platform/​lib/​memory.h Removes relocated cache-alias macros.
src/​platform/​amd/​rembrandt/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​amd/​rembrandt/​include/​platform/​lib/​memory.h Removes relocated cache-alias macros.
src/​platform/​amd/​acp_7_x/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​amd/​acp_7_x/​include/​platform/​lib/​memory.h Removes relocated cache-alias macros.
src/​platform/​amd/​acp_7_0/​include/​platform/​platform.h Removes migrated stream limit.
src/​platform/​amd/​acp_7_0/​include/​platform/​lib/​memory.h Removes relocated cache-alias macros.
src/​platform/​ace30/​include/​platform/​platform.h Removes migrated stream limit.
src/​library_manager/​lib_manager.c Adds direct DMA include.
src/​ipc/​ipc4/​helper.c Uses Kconfig for ACE-version selection.
src/​ipc/​ipc4/​dai.c Replaces platform version checks with Kconfig.
src/​ipc/​ipc3/​handler.c Adds direct DAI include.
src/​ipc/​ipc3/​dai.c Includes the extracted DAI component helper.
src/​include/​sof/​tlv.h Adds direct RTOS string include.
src/​include/​sof/​schedule/​ll_schedule.h Receives timer constants and user scheduling-lock declarations.
src/​include/​sof/​schedule/​ll_schedule_domain.h Delegates relocated declarations to ll_schedule.h.
src/​include/​sof/​coherent.h Uses cache header instead of memory map.
src/​include/​sof/​audio/​component.h Includes cold-code attributes directly.
src/​include/​sof/​audio/​component_ext.h Removes DAI helper and dependency.
src/​include/​sof/​audio/​component_dai.h Houses the extracted DAI configuration helper.
src/​audio/​volume/​volume.h Removes peak-update helper and mailbox include.
src/​audio/​volume/​volume.c Hosts the private peak-update helper.
src/​audio/​volume/​volume_ipc4.c Makes mailbox dependency explicit; removes unused include.
src/​audio/​volume/​volume_ipc3.c Removes unused component extension include.
src/​audio/​up_down_mixer/​up_down_mixer.h Removes unused component extension include.
src/​audio/​up_down_mixer/​up_down_mixer_hifi3.c Adds panic include for fallback stubs.
src/​audio/​src/​src.c Removes unused memory-map include.
src/​audio/​src/​src_ipc4.c Uses narrower scheduler and cold-attribute headers.
src/​audio/​src/​src_common.c Replaces memory-map include with cold attributes.
src/​audio/​pipeline/​static_pipeline_modules.c Removes unused component extension include.
src/​audio/​pipeline/​static_pipeline_loader.c Includes the extracted DAI component helper.
src/​audio/​pipeline/​pipeline-xrun.c Removes unused component extension include.
src/​audio/​pipeline/​pipeline-stream.c Uses direct timer and narrower scheduler headers.
src/​audio/​pipeline/​pipeline-schedule.c Removes unused scheduler-domain and userspace-helper includes.
src/​audio/​pipeline/​pipeline-graph.c Narrows scheduler dependency; removes unused helper include.
src/​audio/​mux/​mux.h Uses Kconfig stream limit without platform header.
src/​audio/​multiband_drc/​multiband_drc.c Replaces memory-map include with cold attributes.
src/​audio/​multiband_drc/​multiband_drc_ipc4.c Replaces memory-map include with cold attributes.
src/​audio/​module_adapter/​module/​modules.c Removes unused userspace-helper and library-manager includes.
src/​audio/​module_adapter/​module/​cadence_ipc4.c Uses narrower scheduler header.
src/​audio/​module_adapter/​module_adapter.c Uses Kconfig stream limits and narrower scheduler header.
src/​audio/​module_adapter/​module_adapter_ipc4.c Removes unused interrupt include.
src/​audio/​module_adapter/​library/​native_system_service.c Removes unused userspace-helper include.
src/​audio/​module_adapter/​library/​kpb_service_bridge.c Removes unused userspace-helper include.
src/​audio/​mixer/​mixer.c Uses Kconfig stream limit without platform header.
src/​audio/​intel_uaol.c Adds direct logging include; removes component extension dependency.
src/​audio/​google/​google_rtc_audio_processing.c Removes unused wait include.
src/​audio/​drc/​drc.c Replaces memory-map include with cold attributes.
src/​audio/​copier/​ipcgtw_copier.h Removes unused component extension include.
src/​audio/​copier/​host_copier.h Removes unused component extension include.
src/​audio/​copier/​copier.c Narrows dependencies and adds direct DAI include.
src/​audio/​copier/​copier_ipcgtw.c Removes unused component extension include.
src/​audio/​copier/​copier_host.c Uses cold attributes; removes unused includes.
src/​audio/​copier/​copier_hifi.c Uses cold attributes; removes component extension include.
src/​audio/​copier/​copier_generic.c Uses narrower component and cold-attribute headers.
src/​audio/​copier/​copier_gain.c Uses direct component, DAI, and cold-attribute headers.
src/​audio/​copier/​copier_dai.c Uses extracted DAI helper and Kconfig ACE check.
src/​audio/​component.c Removes unused interrupt include.
src/​audio/​chain_dma.c Removes unused component extension and scheduler-domain includes.
src/​audio/​buffers/​comp_buffer.c Removes unused userspace-helper include.
src/​audio/​asrc/​asrc_farrow.c Removes unused memory-map include.
src/​audio/​aria/​aria.h Removes unused component extension include.
posix/​include/​sof/​lib/​memory.h Includes relocated host cache helpers.
posix/​include/​rtos/​cache.h Hosts identity cache-alias helpers.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants