Skip to content

kernel/user partition, Phase 4 part 2: untangle the IDC and component headers, remove unused kernel includes - #11466

Draft
lgirdwood wants to merge 11 commits into
thesofproject:mainfrom
lgirdwood:kernel-user/phase4b
Draft

lgirdwood wants to merge 11 commits into
thesofproject:mainfrom
lgirdwood:kernel-user/phase4b

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

Phase 4 of #11306 (kernel / user-space partition), second part: remove kernel-only includes from user-space code that only come from header untangling, and shrink the leak baseline that #11464 added.

What changes

  • The IDC driver header no longer reaches user-space code. rtos/idc.h is the IDC driver header, but it also has the message format that user-space code needs to send cross-core component and pipeline messages. The message format moves to a new rtos/idc_msg.h, which rtos/idc.h includes.
  • The component API includes no kernel-only headers. component_ext.h included rtos/idc.h and ll_schedule_domain.h (for zephyr_ll_user_heap()), and through them the platform clock headers and the memory map.
  • Unused includes: 32 includes of kernel-only headers that user-space sources do not use are removed.
  • User headers: ll_schedule_domain.h, dai-zephyr.h, intel_uaol.h and ipc4/dmic.h drop includes of the memory map, sof/lib/io.h and the DMIC driver header that they did not need.

In the CI configurations, five kernel-only headers no longer reach any user-space source: rtos/idc.h, sof/ipc/driver.h, sof/llext_manager.h, sof/drivers/dmic.h and sof/lib/mm_heap.h. They can move to src/kernel/include in a later part. Overall, the (user-space source, kernel-only header) pairs go from 854 to 686, and two sources leave the baseline.

Patches

  1. rtos: idc: move the message format to rtos/idc_msg.h:

    • the send modes, the message types and fields, struct idc_msg and idc_send_msg();
    • the prototypes of the user-space LL cross-core path, idc_cmd_user() and ipc_user_xcore_send().

    The core power-up message stays in rtos/idc.h: its extension is the firmware text address from the platform memory map. The host builds have no user/kernel split, so their rtos/idc_msg.h just includes rtos/idc.h.

  2. schedule: declare zephyr_ll_user_heap() in the user-space LL section of ll_schedule.h. It returns the address of the user-space LL heap, which user-space code passes to the heap system calls. ll_schedule_domain.h includes ll_schedule.h, so its users still see it.

  3. audio: component_ext: include rtos/idc_msg.h and ll_schedule.h instead of rtos/idc.h and ll_schedule_domain.h.

  4. ipc, notifier: the user-space halves of ipc-common.c and notifier.c include rtos/idc_msg.h instead of rtos/idc.h.

  5. posix: declare heap_trace_all() in the host rtos/alloc.h, where the Zephyr builds declare it. The host builds only declared it in sof/lib/mm_heap.h, which the pipeline code would otherwise have to keep including.

  6. Unused includes: remove 32 unused kernel-only includes from user-space sources in src/audio, src/ipc, src/lib and src/schedule.

    • Each source was compiled without the include in every firmware configuration that builds it, and the host builds below pass.
    • None uses anything that the header declares.
    • Includes that a source uses, but also gets through another header, stay. For example, the copier keeps rtos/interrupt.h for irq_local_disable().
  7. schedule: ll_schedule_domain: drop the memory map. zephyr/lib/alloc.c used the memory map through this header, so it now includes it directly.

  8. lib: dai-zephyr: drop the memory map and sof/lib/io.h.

  9. audio: intel_uaol: include sof/lib/cold.h, for __cold, instead of the memory map.

  10. ipc4: dmic: drop the DMIC driver header.

  11. Baseline: remove the two sources that are now clean.

What is left

Most remaining leaks are not unused includes but uses of kernel APIs from user-space code. Next parts:

  • sof/lib/dma.h: split into a user part (scatter-gather structures, buffer copy, sof_dma_* system calls) and a kernel part. Through it, zephyr/drivers/dma.h, sof/lib/io.h and the memory map reach 13 sources.
  • Mailbox writes (mailbox_sw_regs_write(), mailbox_stream_write()) and the mailbox layout constants, used by the copier, volume, DAI, host, pipeline and IPC code (13 sources).
  • irq_local_disable()/irq_local_enable() in the copier, DAI, pipeline, IPC and LL scheduler code, and the platform timestamp functions from rtos/timer.h.
  • domain_init() in ll_schedule_domain.h: a kernel-only inline that needs rtos/clk.h.
  • idc_cmd_user() and the IDC component handlers that it calls run in the user-space IPC thread, but they live in src/kernel/idc/idc.c. This is added to the Phase 5 list in [FEATURE] Partition SOF into DSP kernel and userspace source/include trees #11306.

Functional change

None.

Testing

  • Include checker: with --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 39 baseline sources leak.
  • Per commit:
    • Builds: tgl, tgl-h, mtl, lnl, ptl, wcl, nvl, imx8, imx8x, imx8m, imx8m_cm7, imx8ulp, imx95 and qemu_xtensa, and the 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;
      • PTL and TGL with app/debug_stream_overlay.conf, and PTL with that overlay and user-space LL.
    • Comparisons: objects, LLEXT modules and firmware images (sections, symbols, SYS_INIT() order), and the per-function disassembly. No object changes at any commit. The only image difference is sof_init() on imx8m_cm7, imx93 and imx95, which embeds the git hash.
    • Signing: rimage runs for every Intel platform, and the generated configs are unchanged.
    • Cadence xt-clang (RI-2022.10): MTL, PTL and NVL compile.
    • ZTest: the unit tests pass, run as in CI (18 of 18 configurations).
    • Host: the host library and the cmocka unit tests build and pass.
  • At the tip:
    • the testbench and the tools pass;
    • the host library and the cmocka unit tests pass for all nine defconfigs and the library config;
    • 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 a4ce5dd (current main).

🤖 Generated with Claude Code

lrgirdwo and others added 11 commits November 15, 2026 22:26
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 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>

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 remain for the IDC interface separation and header-dependency cleanup.

No open issues 🎉

What changed in this PR

This PR advances SOF’s kernel/user-space partitioning by separating IDC message definitions from driver internals and reducing kernel-only header dependencies. It builds on the include-checker enforcement in #11464, with no intended functional changes.

Changes:

  • Introduces a user-facing IDC message header and switches component, IPC, and notifier code to narrower headers.
  • Relocates heap declarations and removes unused kernel-only includes.
  • Removes two clean sources from the include-leak baseline.
File Description
zephyr/​lib/​alloc.c Adds the memory header directly.
zephyr/​include/​rtos/​idc.h Delegates message definitions to the new header.
zephyr/​include/​rtos/​idc_msg.h Defines the user-facing IDC message interface.
src/​schedule/​zephyr_ll.c Removes an unused memory include.
src/​schedule/​zephyr_dp_schedule.c Removes unused kernel-only includes.
src/​schedule/​zephyr_dp_schedule_thread.c Removes the unused userspace-helper include.
src/​schedule/​zephyr_dp_schedule_application.c Removes unused kernel-only includes.
src/​lib/​notifier.c Uses the IDC message header; drops the interrupt include.
src/​lib/​dma.c Removes an unused memory include.
src/​lib/​dai.c Removes an unused memory include.
src/​ipc/​ipc4/​helper.c Removes an unused memory include.
src/​ipc/​ipc4/​handler-user.c Removes unused kernel-only includes.
src/​ipc/​ipc4/​dai.c Removes unused IDC-driver and memory includes.
src/​ipc/​ipc-helper.c Removes unused kernel-only includes.
src/​ipc/​ipc-common.c Uses the IDC message header and removes unused includes.
src/​include/​sof/​schedule/​ll_schedule.h Adds the user-space LL heap declaration.
src/​include/​sof/​schedule/​ll_schedule_domain.h Drops the memory include and relocated heap declaration.
src/​include/​sof/​lib/​dai-zephyr.h Removes unused I/O and memory includes.
src/​include/​sof/​audio/​intel_uaol.h Includes the specific header for __cold.
src/​include/​sof/​audio/​component_ext.h Uses narrower IDC and LL scheduling headers.
src/​include/​ipc4/​dmic.h Removes the unused DMIC driver include.
src/​audio/​pipeline/​pipeline-graph.c Removes the heap-internals include.
src/​audio/​module_adapter/​module_adapter_ipc3.c Removes the unused interrupt include.
src/​audio/​kpb.c Removes unused clock and platform includes.
src/​audio/​copier/​copier_ipcgtw.c Removes an unused memory include.
src/​audio/​chain_dma.c Removes an unused memory include.
scripts/​kernel_user_partition.txt Removes two sources from the leak baseline.
posix/​include/​sof/​lib/​mm_heap.h Removes the relocated heap-tracing declaration.
posix/​include/​rtos/​idc_msg.h Provides a host-compatible IDC header wrapper.
posix/​include/​rtos/​alloc.h Declares heap_trace_all() in the allocation interface.

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