Skip to content

Phase 2 (part 5): move the host-built kernel code to src/kernel - #11415

Open
lgirdwood wants to merge 7 commits into
thesofproject:mainfrom
lgirdwood:kernel-user/phase2e
Open

lgirdwood wants to merge 7 commits into
thesofproject:mainfrom
lgirdwood:kernel-user/phase2e

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

Phase 2 of #11306 (kernel / user-space partition), fifth part: move the kernel-only code that the host builds (testbench, host library, unit tests) also compile into src/kernel, one commit per move. arch and platform follow in a separate PR. As before, moved code keeps its path below src/kernel.

Patches

  1. Host build plumbing: src/CMakeLists.txt, which only the host builds use, now adds src/kernel. Everything already in src/kernel is Zephyr-only, so those subdirectories are only added for Zephyr builds. The host builds compile exactly the same files.
  2. ipc/ipc3/ → kernel/ipc/ipc3/:
    • Zephyr (i.MX and the other IPC3 builds) and the host builds now get it from src/kernel/ipc.
    • The 19 cmocka and 2 ztest unit test CMake files that build ipc3/helper.c are updated, along with the example patch in scripts/fuzz.sh and the comments that name the files.
    • src/kernel/ipc gets the same CODEOWNERS as src/ipc.
  3. ipc/ipc4/{handler-kernel,logging,notification}.c → kernel/ipc/ipc4/:
    • These are the kernel IPC4 dispatcher, the mtrace notifications and the host notifications. They hold the kernel half (z_impl_/z_vrfy_) of the compound-message, reply and send_resource_notif() system calls.
    • The user-side IPC4 files stay in src/ipc/ipc4. Its READMEs now say where the kernel half is.
  4. ipc/notification_pool.c → kernel/ipc/: only used by the kernel notification code; takes a spinlock.
  5. lib/agent.c → kernel/lib/: the system agent. src/kernel/lib keeps the CONFIG_LIBRARY early return, so the host builds still compile only agent.c from there.
  6. drivers/ → kernel/drivers/:
    • SOF_DRIVERS_PATH in zephyr/CMakeLists.txt points to the new location and is used for the entries that spelled the path out.
    • The drivers Kconfig is sourced from src/kernel/Kconfig.
    • CODEOWNERS and the docs are updated.
    • The i.MX, AMD and MediaTek drivers are still built into modules_sof, because zephyr/CMakeLists.txt lists them together with the platform code. They move to sof_kernel together with platform in the next PR.
  7. CODEOWNERS: src/kernel/schedule gets the scheduler owners. zephyr_ll_user.c lost them when Phase 2 (part 4): move the Zephyr-only kernel code to src/kernel #11411 moved it.

Functional change

None.

  • Objects and LLEXT modules: unchanged.
  • Configuration: every build's .config and every Intel platform's generated rimage configuration are unchanged.
  • Firmware images: the symbols and the SYS_INIT() order of every image are unchanged. The link-order effects are as in the previous parts: alignment padding in some sections, the kernel object hash table in the PTL userspace builds, and sof_init() changing size with the git hash on Cortex-M7.
  • acp_6_0 (already fails on main): the error set is the same, with the moved files' new paths.

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 above.
    • Signing: rimage runs for every Intel platform, and the generated configs are compared.
    • Cadence xt-clang (RI-2022.10): MTL, PTL and NVL compile.
    • ZTest: the unit tests pass, run as in CI (twister, native_sim, ASan + LSan), 18 of 18 configurations.
    • Host: the host library and cmocka build and pass.
  • At the tip:
    • the cmocka unit tests pass for all nine defconfigs, as in test-all-defconfigs.sh;
    • 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 main and this branch. That covers the IPC4 kernel files and the notification pool. Both boot, play 5 s, and play again after runtime suspend, with no DSP errors. No IPC3 hardware was available.

All of the above was run on 856cf13 (current main).

🤖 Generated with Claude Code

lrgirdwo and others added 7 commits November 6, 2026 20:47
The next moves bring kernel code that the host builds (testbench, host
library) also compile to src/kernel. Add src/kernel to
src/CMakeLists.txt, which only the host builds use; Zephyr adds it
from zephyr/CMakeLists.txt.

Everything in src/kernel so far is only built for Zephyr, so add those
subdirectories only for Zephyr builds. No functional change: the host
builds compile the same files as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The IPC3 handler runs in kernel mode. Move it to src/kernel/ipc/ipc3,
where Zephyr builds it into the sof_kernel library. The host builds
(the IPC3 testbench and host library) now get it from src/kernel/ipc,
which is added for them as well.

Update the cmocka and ztest unit tests that build ipc3/helper.c, the
example patch in fuzz.sh, the comments that name the files and the
user-space README. Give src/kernel/ipc the same CODEOWNERS as src/ipc.
No functional change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
handler-kernel.c is the kernel IPC4 dispatcher and holds the kernel
half of the compound-message and reply system calls, notification.c
sends notifications to the host and holds the kernel half of
send_resource_notif(), and logging.c drives the mtrace log buffer
notifications. All three run in kernel mode. Move them to
src/kernel/ipc/ipc4, where Zephyr builds them into the sof_kernel
library; the host builds get them from src/kernel/ipc as well.

The user-side files handler-user.c, notification-user.c, helper.c,
dai.c and ams_helpers.c stay in src/ipc/ipc4. Update the IPC READMEs,
the user-space README and a comment in the posix IPC fuzzing harness.
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 notification message pool is used by the kernel IPC4 notification
code and takes a spinlock. Move it to src/kernel/ipc, where Zephyr
builds it into the sof_kernel library; the host builds get it from
src/kernel/ipc as well. 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 system agent checks the timing of the LL scheduler from a timer
task and runs in kernel mode. Move it to src/kernel/lib, where Zephyr
builds it into the sof_kernel library for CONFIG_HAVE_AGENT. The host
library, which always builds it, now gets it from src/kernel/lib, which
keeps the early return for CONFIG_LIBRARY so that the host builds
compile nothing else from 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>
The platform drivers (i.MX, AMD and MediaTek IPC, DMA and DAI drivers,
the generic dummy DMA, the legacy interrupt layer and the host
library's IPC and timer) access hardware and run in kernel mode. Move
them to src/kernel/drivers.

The Zephyr build lists the drivers in zephyr/CMakeLists.txt, so point
SOF_DRIVERS_PATH there and use it for the entries that spelled the path
out. They are still built into modules_sof, like the platform code
listed next to them. The host builds now get drivers/host from
src/kernel. The drivers Kconfig is sourced from src/kernel/Kconfig
instead of src/Kconfig; the option values are unchanged.

Update CODEOWNERS, the drivers README, the kernel-only directory lists
in the docs and a comment in the IPC3 host page table code.
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 moved from src/schedule to src/kernel/schedule and
lost its code owners. Give src/kernel/schedule the same owners as
src/schedule.

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 reported for the kernel-only code relocation into src/kernel.

No open issues 🎉

What changed in this PR

This PR continues the kernel/user-space partition in #11306 by moving kernel-only code used by host builds into src/kernel. It follows #11411 while leaving architecture and platform moves for a later PR, with no intended functional changes.

Changes:

  • Relocates IPC3, kernel-side IPC4, notification pooling, the system agent, and drivers.
  • Updates host, Zephyr, and unit-test build paths while preserving source selection.
  • Updates ownership rules, documentation, and comments to reflect the new layout.
File Description
zephyr/​CMakeLists.txt Points driver sources to src/kernel/drivers.
test/​ztest/​unit/​math/​fft/​CMakeLists.txt Updates the IPC3 helper path.
test/​ztest/​unit/​audio/​drc/​CMakeLists.txt Updates the IPC3 helper path.
test/​cmocka/​src/​math/​fft/​CMakeLists.txt Updates the IPC3 helper path.
test/​cmocka/​src/​audio/​volume/​CMakeLists.txt Updates the IPC3 helper path.
test/​cmocka/​src/​audio/​selector/​CMakeLists.txt Updates the IPC3 helper path.
test/​cmocka/​src/​audio/​pipeline/​CMakeLists.txt Updates IPC3 helper paths across pipeline tests.
test/​cmocka/​src/​audio/​pcm_converter/​CMakeLists.txt Updates the IPC3 helper path.
test/​cmocka/​src/​audio/​mux/​CMakeLists.txt Updates the IPC3 helper path.
test/​cmocka/​src/​audio/​mixer/​CMakeLists.txt Updates the IPC3 helper path.
test/​cmocka/​src/​audio/​eq_iir/​CMakeLists.txt Updates the IPC3 helper path.
test/​cmocka/​src/​audio/​eq_fir/​CMakeLists.txt Updates the IPC3 helper path.
test/​cmocka/​src/​audio/​dcblock/​CMakeLists.txt Updates the IPC3 helper path.
test/​cmocka/​src/​audio/​component/​CMakeLists.txt Updates the IPC3 helper path.
test/​cmocka/​src/​audio/​buffer/​CMakeLists.txt Updates IPC3 helper paths across buffer tests.
src/​platform/​posix/​ipc.c Updates a kernel-handler path in a comment.
src/​lib/​dai.c Updates IPC3 caller paths in comments.
src/​lib/​CMakeLists.txt Removes the relocated system agent from this directory’s sources.
src/​kernel/​lib/​CMakeLists.txt Builds the relocated agent, preserving host-library selection.
src/​kernel/​lib/​agent.c Relocates the system agent into the kernel tree.
src/​kernel/​Kconfig Sources the relocated driver configuration.
src/​kernel/​ipc/​notification_pool.c Relocates the kernel notification pool.
src/​kernel/​ipc/​ipc4/​notification.c Relocates kernel-side IPC4 notifications and validation.
src/​kernel/​ipc/​ipc4/​logging.c Relocates IPC4 logging control and notifications.
src/​kernel/​ipc/​ipc4/​CMakeLists.txt Builds the relocated kernel-side IPC4 sources.
src/​kernel/​ipc/​ipc3/​README.md Relocates IPC3 architecture documentation.
src/​kernel/​ipc/​ipc3/​host-page-table.c Relocates page-table handling and updates a comment path.
src/​kernel/​ipc/​ipc3/​CMakeLists.txt Relocates IPC3 source selection.
src/​kernel/​ipc/​CMakeLists.txt Adds IPC-version subdirectories and notification pooling.
src/​kernel/​drivers/​README.md Updates the driver directory name and documentation link.
src/​kernel/​drivers/​mediatek/​afe/​zephyr_mtk_host_dma.c Relocates the MediaTek host DMA driver.
src/​kernel/​drivers/​mediatek/​afe/​zephyr_mtk_dai.c Relocates the MediaTek Zephyr DAI driver.
src/​kernel/​drivers/​mediatek/​afe/​zephyr_mtk_afe_memif.c Relocates the MediaTek memory-interface DMA driver.
src/​kernel/​drivers/​mediatek/​afe/​afe-drv.c Relocates MediaTek AFE hardware support.
src/​kernel/​drivers/​mediatek/​afe/​afe-dai.c Relocates legacy MediaTek AFE DAI support.
src/​kernel/​drivers/​Kconfig Relocates driver configuration definitions.
src/​kernel/​drivers/​interrupt.c Relocates interrupt-controller support.
src/​kernel/​drivers/​imx/​ipc.c Relocates the i.MX IPC driver.
src/​kernel/​drivers/​host/​timer.c Relocates host timer and timestamp stubs.
src/​kernel/​drivers/​host/​ipc.c Relocates host IPC support.
src/​kernel/​drivers/​host/​CMakeLists.txt Relocates host-driver source selection.
src/​kernel/​drivers/​CMakeLists.txt Selects host drivers for library builds.
src/​kernel/​drivers/​amd/​rembrandt/​ipc.c Relocates Rembrandt IPC support.
src/​kernel/​drivers/​amd/​rembrandt/​acp_sp_dma.c Relocates Rembrandt serial-port DMA support.
src/​kernel/​drivers/​amd/​rembrandt/​acp_sp_dai.c Relocates Rembrandt serial-port DAI support.
src/​kernel/​drivers/​amd/​rembrandt/​acp_hs_dai.c Relocates Rembrandt headset DAI support.
src/​kernel/​drivers/​amd/​rembrandt/​acp_dmic_dma.c Relocates Rembrandt digital-microphone DMA support.
src/​kernel/​drivers/​amd/​rembrandt/​acp_dma.c Relocates Rembrandt ACP DMA support.
src/​kernel/​drivers/​amd/​Kconfig Relocates AMD driver configuration.
src/​kernel/​drivers/​amd/​common/​ipc.c Relocates shared AMD IPC support.
src/​kernel/​drivers/​amd/​common/​acp_sp_dma.c Relocates shared AMD serial-port DMA support.
src/​kernel/​drivers/​amd/​common/​acp_dmic_dma.c Relocates shared AMD digital-microphone DMA support.
src/​kernel/​drivers/​amd/​common/​acp_dmic_dai.c Relocates shared AMD digital-microphone DAI support.
src/​kernel/​drivers/​amd/​common/​acp_dma.c Relocates shared AMD ACP DMA support.
src/​kernel/​drivers/​amd/​common/​acp_bt_dai.c Relocates shared AMD Bluetooth DAI support.
src/​kernel/​drivers/​amd/​acp_7_x/​ipc.c Relocates ACP 7.x IPC support.
src/​kernel/​CMakeLists.txt Separates Zephyr-only subdirectories from host-compatible sources.
src/​Kconfig Removes the old driver configuration inclusion.
src/​ipc/​README.md Documents the relocated kernel IPC4 handler.
src/​ipc/​ipc4/​README.md Documents the new kernel-side IPC4 location.
src/​ipc/​ipc4/​CMakeLists.txt Removes relocated kernel-side IPC4 sources.
src/​ipc/​CMakeLists.txt Removes relocated IPC3 and notification-pool sources.
src/​include/​sof/​userspace/​README.md Updates directory tiers and syscall implementation paths.
src/​CMakeLists.txt Includes the kernel tree in host builds.
src/​audio/​README.md Updates the kernel-driver directory reference.
src/​audio/​dai-zephyr.c Updates IPC3 caller paths in comments.
scripts/​fuzz.sh Updates paths in the example test patch.
CODEOWNERS Updates driver ownership and adds kernel IPC/scheduler owners.
AGENTS.md Removes drivers from the list of pending directory moves.

Review effort: Balanced

@lgirdwood

Copy link
Copy Markdown
Member Author

CI showing unrelated topology failure

FAILED: [code=1] topology/topology2/development/sof-hda-generic-idisp-uaol.tplg.validated /home/runner/work/sof/sof/sof/tools/build_tools/topology/topology2/development/sof-hda-generic-idisp-uaol.tplg.validated 
cd /home/runner/work/sof/sof/sof/tools/build_tools/topology/topology2/development && /usr/bin/python3.14 /home/runner/work/sof/sof/sof/tools/topology/validator/tplg_validate.py --quiet --waivers /home/runner/work/sof/sof/sof/tools/topology/validator/known-issues.txt sof-hda-generic-idisp-uaol.tplg && /usr/local/bin/cmake -E touch sof-hda-generic-idisp-uaol.tplg.validated
sof-hda-generic-idisp-uaol.tplg: error: W004 widget 'dai-copier.UAOL.UAOL0-Play0.playback': unknown DAI type 'UAOL' (kernel: find_dai, sof_ipc4_dai_config)
sof-hda-generic-idisp-uaol.tplg: error: W004 widget 'dai-copier.UAOL.UAOL0-Cap0.capture': unknown DAI type 'UAOL' (kernel: find_dai, sof_ipc4_dai_config)
sof-hda-generic-idisp-uaol.tplg: error: W004 widget 'dai-copier.UAOL.UAOL0-Play1.playback': unknown DAI type 'UAOL' (kernel: find_dai, sof_ipc4_dai_config)
sof-hda-generic-idisp-uaol.tplg: error: W004 widget 'dai-copier.UAOL.UAOL0-Cap1.capture': unknown DAI type 'UAOL' (kernel: find_dai, sof_ipc4_dai_config)
sof-hda-generic-idisp-uaol.tplg: 4 errors, 24 warnings, 95 info
[870/1390] Generating sof-mtl-rt5650-ctc.tplg.validated

@intel-sofci

Copy link
Copy Markdown

PR 11415: test results

Run date: 2026-11-07 15:29 UTC

Tested commit: 986201f0d23fa45074c91ae95ce7591f8ab321d7

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

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