Repository navigation
Phase 2 (part 1): add src/kernel and a sof_kernel library, move src/init - #11394
Merged
Merged
Conversation
Phase 2 of the kernel / user-space partition (thesofproject#11306) moves the code that only runs in kernel mode to src/kernel. The firmware init code is the first: it brings up the SOF context and runs from SYS_INIT() in supervisor mode. Move it to src/kernel/init and add src/kernel/CMakeLists.txt, which the Zephyr build now adds instead of src/init. Update the paths in the README and in a ztest comment. Only Zephyr builds src/init, 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>
Add a sof_kernel Zephyr library for the code in src/kernel, so that kernel-only code is built separately from modules_sof and can later be given include directories of its own. The library is created in zephyr/CMakeLists.txt, next to modules_sof, so that it gets the same directory-level compile definitions, and it links the same SOF interface library. It is created first so that modules_sof stays the current Zephyr library there. src/kernel/CMakeLists.txt makes sof_kernel the current library for its own directory tree, so the CMake files of the directories moved there need no change. The trace relative paths are set for it as well. Like all Zephyr libraries it is linked as a whole archive, so the SYS_INIT() entries it holds are kept and their order is unchanged. The generated code is unchanged; only the link order, and with it the alignment padding in some sections, changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the kernel source-tree and library reorganization.
No open issues 🎉
What changed in this PR
This PR begins Phase 2 of #11306 by establishing a kernel-only source tree and library for SOF’s kernel/userspace partition. It moves firmware initialization into that tree without intended functional changes.
Changes:
- Move
src/inittosrc/kernel/init, preserving initialization logic and firmware metadata. - Add the
sof_kernelZephyr library, shared SOF build settings, and relative trace-path definitions. - Update documentation and a test-support comment to reflect the new location.
| File | Description |
|---|---|
zephyr/CMakeLists.txt |
Creates and links sof_kernel, includes the kernel tree, and configures trace paths. |
test/ztest/unit/common/sof_context.c |
Updates the initialization source path in a comment. |
src/kernel/init/README.md |
Updates directory references, the userspace documentation link, and the boot diagram. |
src/kernel/init/init.c |
Relocates firmware initialization code without logic changes. |
src/kernel/init/ext_manifest.c |
Relocates firmware metadata definitions without logic changes. |
src/kernel/init/CMakeLists.txt |
Preserves the relocated initialization source list. |
src/kernel/CMakeLists.txt |
Selects sof_kernel for the directory tree and includes initialization sources. |
Review effort: Balanced
lgirdwood
marked this pull request as ready for review
November 3, 2026 20:37
lgirdwood
requested review from
abonislawski,
dbaluta,
iuliana-prodan,
kv2019i,
lbetlej,
lyakh,
mmaka1 and
plbossart
as code owners
November 3, 2026 20:37
PR 11394: test resultsRun date: 2026-11-03 21:02 UTC Tested commit: 1c51b07250943bc6a21bcb6250590c7767d571f3 |
kv2019i
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 2 of #11306 (kernel / user-space partition), first part: add
src/kerneland asof_kernellibrary for code that only runs in kernel mode, and move the firmware init code there. Further directories follow, one per PR.Patches
src/init→src/kernel/init: a pure move.zephyr/CMakeLists.txtaddssrc/kernelinstead ofsrc/init. The README and a ztest comment get the new path. Only Zephyr builds this code; the host builds don't.sof_kernellibrary:src/kernelis built into a new Zephyr library instead ofmodules_sof. It can then get kernel-only include directories later (Phase 4).zephyr/CMakeLists.txt, next tomodules_sof, so it gets the same directory-level definitions (for exampleCC_OPTIMIZE_FLAGS, used byext_manifest.c). It also links the sameSOFinterface library.sof_kernelis created beforemodules_sof, somodules_sofstays the current library inzephyr/CMakeLists.txt.src/kernel/CMakeLists.txtmakessof_kernelthe current library for its own directory tree, so the CMake files of directories moved there need no change.Functional change
None. The compile flags of the moved files are unchanged apart from their
RELATIVE_FILEpath, and the generated objects are unchanged.What changes is the link order: the init objects now come after the IPC code, from a library of their own. Zephyr links all its libraries as whole archives, so
sof_init()'sSYS_INIT()entry is kept. In every firmware image the symbols (name, type and size) and theSYS_INIT()order are identical before and after. The only section differences are a few bytes of alignment padding in.text,.xt.propand.xt.liton MTL, TGL and TGL-H. The ASan fuzz builds also embed the longer source path. On the Cortex-M7 builds (imx8m_cm7, imx95),sof_init()changes size from commit to commit because it embeds the git hash (SOF_SRC_HASH), and Thumb-2 encodes some constants more compactly than others. Rebuildinginit.cwith each commit's hash value gives the same sizes, and the source path has no effect.Testing
CONFIG_SOF_USERSPACE_PROXY=n;os_linux_overlay.conf;llext_relocatable.conf.SYS_INIT()order and section sizes, with the results above.sof-hda-generic-cavs25-2ch.tplg, comparing main and this branch. Both boot, play 5 s on the HDA analog PCM, and play again after runtime suspend, with no DSP errors.All of the above was run on 78b23ad (current main), except for the hardware test, which was run on the same two patches on d44cbf0.
🤖 Generated with Claude Code