Skip to content

kernel/user partition, Phase 4 part 1: enforce the include checker, fix a telemetry include regression - #11464

Merged
lgirdwood merged 4 commits into
thesofproject:mainfrom
lgirdwood:kernel-user/phase4a
Nov 15, 2026
Merged

lgirdwood merged 4 commits into
thesofproject:mainfrom
lgirdwood:kernel-user/phase4a

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

Phase 4 of #11306 (kernel / user-space partition), first part: turn on enforcement of the include checker, so that new kernel-only includes from user-space code fail CI. It also fixes a regression that this would have caught.

The regression

Commit 20206e3 ("telemetry: headers: add extended TEL2 and PMW2 window definitions") added rtos/timer.h to telemetry.h. component.h includes telemetry.h, and rtos/timer.h includes sof/platform.h. So every component source got the platform headers back:

Platform User-space sources including kernel-only headers: before the regression main this PR
PTL 28 140 28
TGL 23 121 23
imx8m 15 88 15

That undid most of the Phase 1 header untangling (#11330, #11345, #11364, #11386). Nobody noticed, because the CI step only reports.

Patches

  1. Drop rtos/timer.h from telemetry.h: nothing in the header needs it. It only names sof_cycle_get_64() in the telemetry_timestamp macro. The two sources that expand that macro, component.c and zephyr_ll.c, already get rtos/timer.h, as they did before that commit.
  2. Check all user-space sources: the checker's list of user-space sources was written before the kernel code moved to src/kernel. Now every source in src/ outside src/kernel is user-space code. This adds the user halves of the Phase 3 splits in src/ipc, src/schedule, src/lib and src/debug, which were not checked. The legacy host and DAI drivers stay excluded until they are deleted.
  3. Leak baseline: a [leak-baseline] section in scripts/kernel_user_partition.txt lists the 41 user-space sources that still include kernel-only headers in the CI configurations and with the user-space overlays.
    • With --strict, the checker fails only when a source outside the baseline includes a kernel-only header.
    • Baseline sources that were built without leaks are reported, so the list can only shrink.
  4. CI: the Linux build jobs run the checker with --strict.
    • The README in src/kernel describes the baseline.

Next parts of Phase 4

  • Remove the remaining leaks, shrinking the baseline. Most come from:
    • sof/platform.h, the platform memory map and rtos/clk.h/rtos/timer.h, in the DMA, DAI, pipeline and copier code;
    • zephyr/drivers/dma.h and rtos/idc.h;
    • the user halves of the IPC and scheduler splits.
  • Move the kernel-only headers that user code no longer includes to src/kernel/include/sof/kernel/.

Functional change

None. The telemetry patch changes no object in any configuration below, and no image symbol, section or SYS_INIT() entry. The other patches only touch the checker, its manifest, CI and docs.

Testing

  • Checker:
    • with each of the 12 CI build configurations, built locally as CI does (repro-build.conf, -Werror): --strict passes;
    • with every other configuration listed below: --strict also passes. Across all of them, exactly the 41 baseline sources leak;
    • with the regression: --strict fails;
    • with a source removed from the baseline: --strict fails and names the source and its kernel-only headers;
    • CI's paths resolve: main's PTL job reports 146 sources, so the checker sees the CI build's dependencies.
  • 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:
    • Comparisons: objects, LLEXT modules and firmware images (sections, symbols, SYS_INIT() order), and the per-function disassembly. Only the imx93 sof_init() differs, because it embeds the git hash.
    • Signing: rimage runs for every Intel platform, and the generated configs are unchanged.
    • 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 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 e9b5dd8 (current main).

🤖 Generated with Claude Code

lrgirdwo and others added 4 commits November 15, 2026 15:20
Commit 20206e3 ("telemetry: headers: add extended TEL2 and PMW2
window definitions") added rtos/timer.h to telemetry.h. telemetry.h
is included by component.h, and rtos/timer.h includes sof/platform.h,
so every component source got the platform headers back: on PTL the
user-space sources that include kernel-only headers went from 28 to
140, undoing most of the header untangling of thesofproject#11306 Phase 1.

Nothing in telemetry.h needs the include. It only names
sof_cycle_get_64() in the telemetry_timestamp macro, and the two
sources that expand that macro, component.c and zephyr_ll.c, already
get rtos/timer.h, as they did before that commit.

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 manifest's user-space source list was written before the kernel
code moved to src/kernel. Now that it has, every source in src/
outside of src/kernel is user-space code: that also covers the user
halves of the Phase 3 splits in src/ipc, src/schedule, src/lib and
src/debug, which were not checked. The legacy host and DAI drivers
stay excluded until they are deleted.

The checked builds now report 11 more user-space sources that include
kernel-only headers: the user halves of the IPC, scheduler, DMA and
DAI splits, the notifier and a tester module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add a [leak-baseline] section to the partition manifest, listing the
41 user-space sources that still include kernel-only headers in the
CI configurations and with the user-space overlays. With --strict,
the checker now only fails when a user-space source outside of the
baseline includes a kernel-only header, so it can be enforced before
the remaining leaks are removed, and new leaks are caught when they
are added.

Baseline sources that were built without leaks are reported, so that
they can be dropped from the list once they are clean in every
configuration.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run the kernel/user-space include checker with --strict, so that the
Linux build jobs fail when a user-space source that is not in the
checker's leak baseline includes a kernel-only header. Such a
regression went unnoticed with the report alone: one header change
brought the platform headers back into every component source.

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 are identified for the kernel/user-space include-checking changes.

No open issues 🎉

What changed in this PR

This PR advances SOF’s kernel/user-space partitioning by enforcing include checks in Linux CI and removing a telemetry include that reintroduced kernel-only headers into component sources.

Changes:

  • Removes the unnecessary rtos/timer.h include from telemetry.h.
  • Expands checking to all src/ sources except kernel code and legacy host/DAI drivers, with a 41-source baseline for existing leaks.
  • Enables strict CI checks for leaks outside the baseline and reports baseline sources built without leaks.
File Description
src/​kernel/​README.md Documents CI enforcement and the shrinking leak baseline.
src/​include/​sof/​debug/​telemetry/​telemetry.h Removes the timer include responsible for transitive platform-header exposure.
scripts/​kernel_user_partition.txt Broadens source coverage and records existing leak exceptions.
scripts/​check_kernel_includes.py Adds baseline-aware strict checks and clean-source reporting.
.github/​workflows/​zephyr.yml Enables strict checks and propagates failures across platform builds.

Review effort: Balanced

@lgirdwood
lgirdwood marked this pull request as ready for review November 15, 2026 17:05
@intel-sofci

intel-sofci commented Nov 15, 2026 •

Copy link
Copy Markdown

PR 11464: test results

Run date: 2026-11-16 10:29 UTC

Tested commit: 2d08b0d481027a03a0b897d665e6620e08e780d5

mtl pass rate lnl pass rate ptl pass rate wcl pass rate nvl pass rate

@lgirdwood

Copy link
Copy Markdown
Member Author

unrelated CI error

@lgirdwood
lgirdwood merged commit a4ce5dd into thesofproject:main Nov 15, 2026
44 of 45 checks passed
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.

4 participants