Skip to content

Phase 2 (part 4): move the Zephyr-only kernel code to src/kernel - #11411

Merged
lgirdwood merged 12 commits into
thesofproject:mainfrom
lgirdwood:kernel-user/phase2d
Nov 6, 2026
Merged

lgirdwood merged 12 commits into
thesofproject:mainfrom
lgirdwood:kernel-user/phase2d

Conversation

@lgirdwood

@lgirdwood lgirdwood commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Phase 2 of #11306 (kernel / user-space partition), fourth part: move the remaining kernel-only code that only Zephyr builds into src/kernel, one commit per move. Moves of code the host builds also compile, and of arch/platform, follow in two further PRs. Stacked on #11402: its commit (rebased onto current main) comes first and will drop out when #11402 is merged.

Moved code keeps its path below src/kernel (src/<path> → src/kernel/<path>). Only the kernel-only files of mixed directories move.

Patches

  1. src/kernel/README.md (new):
    • states the kernel-only tier ("Runs in" banner), the layout rule and the sof_kernel library;
    • the user-space README's directory table now points to it instead of listing each kernel subdirectory.
  2. logging/ → kernel/logging/: the SOF probe log backend.
  3. probe/ → kernel/probe/:
    • Kconfig: now sourced from src/kernel/Kconfig;
    • rimage configs: the seven tools/rimage/config/*.toml.h files that include probe.toml get the new path.
  4. audio/base_fw.c, audio/base_fw_intel.c → kernel/audio/. base_fw_intel.c includes the copier's private copier_gain.h, now by a path relative to its new location.
  5. audio/mic_privacy_manager/ → kernel/audio/mic_privacy_manager/.
  6. audio/module_adapter/library/userspace_proxy.c → kernel/audio/module_adapter/library/: the kernel half of the user-space proxy. The user half, userspace_proxy_user.c, stays.
  7. ipc/ipc-zephyr.c → kernel/ipc/: the Intel ADSP IPC transport.
  8. lib/clk.c, lib/cpu-clk-manager.c, lib/ams.c → kernel/lib/. The src/lib README listed ams.c as context-agnostic, but it disables interrupts and sends IDC messages; corrected.
  9. debug/telemetry/ → kernel/debug/telemetry/: its Kconfig is now sourced from src/kernel/Kconfig.
  10. debug/dram.c → kernel/debug/: the CONFIG_COLD_STORE_EXECUTE_DEBUG checker.
  11. schedule/zephyr_ll_user.c → kernel/schedule/: despite its name, this is the kernel-side setup of the user LL memory domain and heap. The READMEs no longer give it as an example of a user-side file.

audio/intel_uaol.c was going to move as well, but since the UAOL feedback support it also contains functions that the DAI component calls from the user-space LL thread. It is now mixed, so it stays where it is and will be split in Phase 3.

Each commit drops its files from the kernel exceptions in scripts/kernel_user_partition.txt (which only lists user-space directories), and updates the READMEs that name them.

Functional change

None. Every object and LLEXT module is unchanged, every build's .config has the same option values, and the generated rimage configuration (rimage_config.toml) of every Intel platform is identical. The symbols (name, type and size) of every firmware image are identical. Link-order effects:

  • Padding: alignment padding in some sections, and the gperf-generated kernel object hash table (wordlist) in the PTL builds with Zephyr userspace, as in Phase 2 (part 1): add src/kernel and a sof_kernel library, move src/init #11394–Phase 2 (part 3): move src/library_manager to src/kernel/library_manager #11402.
  • SYS_INIT() ties: the probe, base firmware and telemetry moves change the order among APPLICATION-level entries with the same priority, which Zephyr runs in link order.
    • What moves: the probe and base firmware component driver registrations, telemetry_init() and performance_monitor_init() now run before the other component registrations instead of after them.
    • Why it's safe: driver registration only appends to the driver list, and lookups are by UUID. The two telemetry inits set up their own debug window and state. The only other debug-window slot user, the debug stream, does not initialize at this level. Logging and sof_init() still run earlier, at POST_KERNEL.

Known kernel calls from user-space code (not changed here)

  • User-space code calls zephyr_ll_user_heap() (host-zephyr.c) and the telemetry functions (component.c, the host and DAI components). User-space LL builds disable telemetry for now. Both need system calls in a later phase.
  • base_fw_intel.c uses the copier's private header.

Testing

  • 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.
    • Comparisons: objects, LLEXT modules and firmware images, as described above.
    • Signing: rimage runs for every Intel platform, since it is the only step that preprocesses the *.toml.h configs. The generated configs are compared with the previous commit.
    • Cadence xt-clang (RI-2022.10): MTL, PTL and NVL compile.
    • 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.
  • Hardware: TGL (UP Xtreme i11), sof-hda-generic-cavs25-2ch.tplg, comparing Phase 2 (part 3): move src/library_manager to src/kernel/library_manager #11402 and this branch. That covers the base firmware, IPC transport, AMS and probe moves (tested before the rebase, on 414a8a2). Both boot, register the probes card, play 5 s, and play again after runtime suspend, with no DSP errors.
    • Not yet tested on hardware: an ACE platform, which would also cover telemetry and the clock and KCPS code. The ARL-S test board was offline; it will be added when it is back.

All of the above was run on 0ebaf49 (current main, Zephyr 76f604468505) with #11402 rebased onto it, except for the TGL hardware test, which was run on 414a8a2.

🤖 Generated with Claude Code

lrgirdwo and others added 12 commits November 6, 2026 14:47
The library manager loads and links library and LLEXT modules and holds
the kernel half of the lib_manager_free_module() system call. None of
it runs in a user thread. Move it to src/kernel/library_manager, where
it is built into the sof_kernel library.

Source its Kconfig from src/kernel/Kconfig instead of src/Kconfig; the
option values are unchanged. In the user-space README, list it with the
kernel-only directories and update the path in the system call table.
Only Zephyr builds the library manager, so the host builds are not
affected. No functional change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Describe src/kernel: what belongs there, that moved code keeps its
path below src/kernel, and that Zephyr builds it into the sof_kernel
library. The README carries the "Runs in: Kernel-only" banner, so
moved directories without a README of their own are covered by it.

Point the user-space README's directory table at it instead of
listing each kernel subdirectory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The SOF probe log backend registers a Zephyr logging backend and runs
in kernel mode. Move it to src/kernel/logging, where it is built into
the sof_kernel library, and drop it from the not-yet-moved kernel-only
directories in the docs. Only Zephyr builds 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>
The probe component drives DMA directly and runs in kernel mode. Move
it to src/kernel/probe, where it is built into the sof_kernel library,
or as before as an LLEXT module when CONFIG_PROBE=m. Its Kconfig is
sourced from src/kernel/Kconfig instead of src/Kconfig; the option
values are unchanged. Drop it from the not-yet-moved kernel-only
directories in the docs. Only Zephyr builds 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>
The IPC4 base firmware module reports firmware and hardware
configuration, manages DSP state and reads the memory windows. It runs
in kernel mode. Move it to src/kernel/audio, where it is built into the
sof_kernel library, and drop the files from the kernel exceptions in
the include checker's manifest, which only lists user-space
directories.

base_fw_intel.c includes the copier's private copier_gain.h by a path
relative to src/audio; it now uses a path relative to its new
location. The base firmware module is not built for the host library.
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 microphone privacy manager handles the privacy interrupt and
programs the DMIC and gateway hardware, and runs in kernel mode. Move
it to src/kernel/audio/mic_privacy_manager, where it is built into the
sof_kernel library, and drop it from the kernel exceptions in the
include checker's manifest. Only Zephyr builds 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>
The user-space proxy is split in two: userspace_proxy_user.c runs in
the user thread, and userspace_proxy.c creates that thread, its memory
domain and object grants, and forwards the module calls to it from the
kernel. Move the kernel half to
src/kernel/audio/module_adapter/library, where it is built into the
sof_kernel library. Drop it from the kernel exceptions in the include
checker's manifest and update the module adapter README. Only Zephyr
builds 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>
ipc-zephyr.c is the Intel ADSP IPC transport: it handles the host IPC
interrupt and mailbox and the power state transitions requested over
IPC, and runs in kernel mode. Move it to src/kernel/ipc, where it is
built into the sof_kernel library. Only Zephyr builds 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>
The clock code takes spinlocks and calls the platform clock drivers,
the KCPS manager requests clock changes from the platform, and the AMS
messaging service disables interrupts and sends IDC messages to other
cores. All three run in kernel mode. Move them to src/kernel/lib, where
they are built into the sof_kernel library.

The src/lib README listed ams.c among the context-agnostic helpers;
correct that and point to the new location. None of these files is
built for the host library. 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 telemetry code writes the performance and I/O measurements to the
debug memory window and runs in kernel mode; components report to it
through function calls, which is why user-space LL builds disable it
for now. Move it to src/kernel/debug/telemetry, where it is built into
the sof_kernel library. Its Kconfig is sourced from src/kernel/Kconfig
instead of src/Kconfig; the option values are unchanged. Only Zephyr
builds 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>
dram.c is the CONFIG_COLD_STORE_EXECUTE_DEBUG checker that tracks hot
and cold code paths under a spinlock, and runs in kernel mode;
user-space LL builds disable it for now. Move it to src/kernel/debug,
where it is built into the sof_kernel library. Only Zephyr builds 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>
zephyr_ll_user.c creates the memory domain and heap of the user-space
LL scheduler thread and checks the heap pointers passed to the heap
system calls. Despite its name it runs in kernel mode. Move it to
src/kernel/schedule, where it is built into the sof_kernel library.

Update the schedule and user-space READMEs, and stop giving it as an
example of a user-side file. Only Zephyr builds it, for
CONFIG_SOF_USERSPACE_LL. No functional change.

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.

🔵 Needs a closer look

A critical issue remains: moving the mixed translation unit into sof_kernel violates the kernel-only contract because userspace_proxy_process() still executes directly in a K_USER DP thread.

No open issues 🎉

What changed in this PR

Continues the kernel/user-space partition in #11306 by relocating Zephyr-only subsystems into src/kernel and the sof_kernel library. Includes the stacked library-manager move from #11402, with no intended functional changes.

Changes:

  • Relocates logging, probes, base firmware, privacy management, IPC transport, clock services, telemetry, and scheduler setup.
  • Updates CMake, Kconfig, and rimage paths for the new layout.
  • Revises tier documentation and removes obsolete partition exceptions.
File Description
zephyr/​CMakeLists.txt Removes old subsystem build paths.
tools/​rimage/​config/​wcl.toml.h Updates probe manifest include.
tools/​rimage/​config/​tgl.toml.h Updates probe manifest include.
tools/​rimage/​config/​tgl-h.toml.h Updates probe manifest include.
tools/​rimage/​config/​ptl.toml.h Updates probe manifest include.
tools/​rimage/​config/​nvl.toml.h Updates probe manifest include.
tools/​rimage/​config/​mtl.toml.h Updates probe manifest include.
tools/​rimage/​config/​lnl.toml.h Updates probe manifest include.
src/​schedule/​README.md Documents relocated LL memory setup.
src/​schedule/​CMakeLists.txt Removes relocated scheduler source.
src/​platform/​posix/​include/​platform/​lib/​clk.h Updates source path in a comment.
src/​lib/​README.md Corrects clock and AMS tier descriptions.
src/​lib/​CMakeLists.txt Removes relocated kernel services.
src/​kernel/​schedule/​zephyr_ll_user.c Relocates LL memory-domain and heap setup.
src/​kernel/​schedule/​CMakeLists.txt Builds relocated LL setup conditionally.
src/​kernel/​README.md Defines kernel tier, layout, and build rules.
src/​kernel/​probe/​probe.toml Relocates probe module metadata.
src/​kernel/​probe/​llext/​llext.toml.h Relocates probe extension manifest.
src/​kernel/​probe/​llext/​CMakeLists.txt Relocates probe extension build rules.
src/​kernel/​probe/​Kconfig Relocates probe options.
src/​kernel/​probe/​CMakeLists.txt Relocates probe build selection.
src/​kernel/​logging/​log_backend_probe.c Relocates probe logging backend.
src/​kernel/​logging/​CMakeLists.txt Builds relocated logging backend.
src/​kernel/​library_manager/​llext_manager_dram.c Relocates extension context persistence.
src/​kernel/​library_manager/​lib_notification.c Relocates library notification handling.
src/​kernel/​library_manager/​lib_manager.c Relocates library loading and management.
src/​kernel/​library_manager/​Kconfig Relocates library-manager options.
src/​kernel/​library_manager/​CMakeLists.txt Relocates library-manager build rules.
src/​kernel/​lib/​cpu-clk-manager.c Relocates CPU clock budgeting.
src/​kernel/​lib/​CMakeLists.txt Builds relocated kernel services.
src/​kernel/​lib/​clk.c Relocates clock-control implementation.
src/​kernel/​lib/​ams.c Relocates asynchronous messaging service.
src/​kernel/​Kconfig Sources relocated subsystem options.
src/​kernel/​ipc/​ipc-zephyr.c Relocates Intel ADSP IPC transport.
src/​kernel/​ipc/​CMakeLists.txt Builds transport on supported Intel platforms.
src/​kernel/​debug/​telemetry/​telemetry.c Relocates scheduler telemetry.
src/​kernel/​debug/​telemetry/​README.md Relocates telemetry documentation.
src/​kernel/​debug/​telemetry/​performance_monitor.c Relocates performance monitoring.
src/​kernel/​debug/​telemetry/​Kconfig Relocates telemetry options.
src/​kernel/​debug/​telemetry/​CMakeLists.txt Relocates telemetry build rules.
src/​kernel/​debug/​dram.c Relocates cold-path execution checker.
src/​kernel/​debug/​CMakeLists.txt Builds relocated debug facilities.
src/​kernel/​CMakeLists.txt Adds relocated subsystem directories.
src/​kernel/​audio/​module_adapter/​library/​userspace_proxy.c Relocates proxy implementation.
src/​kernel/​audio/​mic_privacy_manager/​README.md Relocates privacy-manager documentation.
src/​kernel/​audio/​mic_privacy_manager/​mic_privacy_manager_intel.c Relocates Intel microphone privacy implementation.
src/​kernel/​audio/​mic_privacy_manager/​CMakeLists.txt Relocates privacy-manager build rules.
src/​kernel/​audio/​CMakeLists.txt Builds relocated audio-side services.
src/​kernel/​audio/​base_fw.c Relocates base-firmware IPC handlers.
src/​kernel/​audio/​base_fw_intel.c Relocates Intel handlers and adjusts copier include.
src/​Kconfig Removes old subsystem option paths.
src/​ipc/​CMakeLists.txt Removes relocated IPC transport source.
src/​include/​sof/​userspace/​README.md Updates tier table and relocated references.
src/​debug/​CMakeLists.txt Removes relocated debug facilities.
src/​audio/​module_adapter/​README.md Updates proxy implementation paths.
src/​audio/​module_adapter/​CMakeLists.txt Keeps user-side proxy source in place.
src/​audio/​CMakeLists.txt Removes relocated firmware and privacy sources.
scripts/​kernel_user_partition.txt Removes exceptions for relocated audio files.
AGENTS.md Updates remaining kernel-directory guidance.

Review effort: Balanced

@lgirdwood
lgirdwood requested a review from lbetlej as a code owner November 6, 2026 16:48

@kv2019i kv2019i left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks great!

@intel-sofci

Copy link
Copy Markdown

PR 11411: test results

Run date: 2026-11-06 18:01 UTC

Tested commit: 45c04781c8037ec3cf481bda3e991603e6da53fb

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

@lgirdwood
lgirdwood merged commit 7bd9403 into thesofproject:main Nov 6, 2026
47 checks passed
@lgirdwood
lgirdwood deleted the kernel-user/phase2d branch November 6, 2026 20:03
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.

5 participants