Skip to content

Phase 3 (part 2): split the schedulers, kernel parts to src/kernel/schedule - #11424

Draft
lgirdwood wants to merge 9 commits into
thesofproject:mainfrom
lgirdwood:kernel-user/phase3b
Draft

lgirdwood wants to merge 9 commits into
thesofproject:mainfrom
lgirdwood:kernel-user/phase3b

Conversation

@lgirdwood

@lgirdwood lgirdwood commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Phase 3 of #11306 (kernel / user-space partition), second part: split the scheduler sources and move their kernel parts into src/kernel/schedule. Based on current main; it no longer depends on #11422 (the IPC split), which is being reworked separately.

As in the first part, the kernel half of src/X/foo.c is src/kernel/X/foo-kernel.c, and each user half says where its kernel half is.

What counts as kernel:

  • boot-time scheduler and domain setup;
  • thread, timer and kernel-object creation;
  • memory domains and access grants;
  • the z_impl_/z_vrfy_ halves of the scheduler syscalls.

What stays in src/schedule: what runs in the scheduler, DP and IPC threads, which are user threads with user-space LL:

  • the thread functions;
  • task scheduling, cancel and free;
  • the deadline and readiness calculation;
  • the IPC forwarding to DP threads.

Patches

  1. zephyr_domain.c → zephyr_domain-kernel.c:

    • Moves to the kernel half:
      • the LL thread stacks and the timer interrupt handler;
      • register and unregister for builds without user-space LL, which create and abort the threads and start and stop the timer;
      • the user-space LL thread init and free, which also register the LL threads as SOF syscall callers, with the kernel-only per-core thread table and the thread lookups used for grants;
      • the domain ops and zephyr_domain_init().
    • Stays: the thread function, the user-space LL register and unregister bookkeeping, the cross-core block and unblock, and ll_sch_is_current().
    • New header: the domain structures go into a new scheduler-private header, sof/schedule/zephyr_ll.h.
  2. zephyr_ll.c → zephyr_ll-kernel.c: the kernel half gets

    • zephyr_ll_scheduler_init(), zephyr_ll_scheduler_free() and the ops;
    • the kernel-only copy of the per-core lock table that the access grants use;
    • the kernel half of the zephyr_ll_task_sem_alloc()/_free() syscalls, with their caller checks;
    • zephyr_ll_init_context() and user_ll_grant_access().

    The scheduler structures and the per-core lock table go into sof/schedule/zephyr_ll.h, and zephyr_ll_assert_core(), which both halves use, becomes a static inline there.

  3. Move the DP scheduler's private header to sof/schedule/zephyr_dp_schedule.h, so that the kernel halves can include it, and give it an include guard.

  4. zephyr_dp_schedule.c → zephyr_dp_schedule-kernel.c: the kernel half gets

    • the per-core DP locks (kernel objects) and scheduler_dp_grant();
    • the scheduler_dp_ll_tick() and scheduler_dp_check_deadline() syscalls;
    • scheduler_dp_init() with the ops, UUID, trace context and log module.
  5. zephyr_dp_schedule_thread.c → zephyr_dp_schedule_thread-kernel.c: the kernel half gets scheduler_dp_task_init() (thread, stack, event, pinning, grants, memory domain) and the scheduler_dp_internal_free() syscall.

  6. zephyr_dp_schedule_application.c → zephyr_dp_schedule_application-kernel.c:

    • Moves to the kernel half:
      • scheduler_dp_task_init();
      • the kernel-only record of each task's kernel objects;
      • the memory domain pool and teardown;
      • the scheduler_dp_internal_free() syscall and its caller checks;
      • the DP thread semaphores (kernel objects).
    • Now in the shared header: the task memory layout and the packed IPC structure.
  7. Move the TWB scheduler to src/kernel/schedule. It isn't split because it is kernel-only:

    • it serializes with irq_lock(), in its thread function too;
    • it sets thread priorities and time slices from an interrupt-context budget callback;
    • it allocates the thread stacks.
  8. schedule.c → schedule-kernel.c: scheduler_init() and scheduler_register(). scheduler_is_user() becomes a static inline in sof/schedule/schedule.h.

  9. Docs: the scheduler README and the syscall table of the user-space README.

The DP thread variant still creates kernel-mode DP threads when the module isn't a user-space module. That is a configuration choice and is unchanged. Some user-half code still calls kernel functions, for example user_stack_free() and k_thread_abort() in DP task free. The issue tracks those in Phase 5.

Functional change

None. The per-function disassembly of every image was compared before and after each commit. It differs only where the compiler inlines differently across the split:

  • zephyr_ll.c (builds with user-space support): zephyr_ll_task_done() now inlines a log message's syscall wrapper instead of calling a local out-of-line copy. The register allocation of zephyr_ll_task_free() and zephyr_ll_task_init() differs.
  • zephyr_dp_schedule.c: z_impl_scheduler_dp_ll_tick() calls the lock helpers instead of inlining them. In the application variant, scheduler_dp_task_free() calls scheduler_dp_task_stop() instead of inlining it.
  • Everything else: unchanged. The only other differences are layout effects:
    • Zephyr vector literal words;
    • the PTL userspace kernel-object hash;
    • Cortex-M sof_init(), which embeds the git hash.

Symbols are unchanged apart from the functions and objects that are now shared between the halves becoming global. The SYS_INIT() order, every build's .config and the generated rimage configurations are unchanged.

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, including the DP application variant;
      • PTL with CONFIG_SOF_USERSPACE_PROXY=n;
      • PTL and MTL with os_linux_overlay.conf;llext_relocatable.conf.

      MTL builds the TWB scheduler.

    • Comparisons: objects, LLEXT modules and firmware images (sections, symbols, SYS_INIT() order), plus the per-function disassembly comparison above.

    • 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 for all nine defconfigs and the library config.

  • At the tip:
    • 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 (a206532) and this branch. That covers the LL scheduler, its timer domain, scheduler registration and the DP scheduler init. Both boot, play 5 s, and play again after runtime suspend, with no DSP errors. No ACE hardware was available, so the user-space LL and DP application paths were only build-tested.

All of the above was run after rebasing onto a206532 (current main).

Changes since the last push

  • Rebased directly onto current main, without Phase 3 (part 1): split the mixed IPC files, kernel halves to src/kernel/ipc #11422.
  • Main's new scheduler code is placed by the same rule:
    • Kernel halves:
      • the LL thread registration in the syscall-caller registry;
      • the kernel-only LL lock table;
      • the syscall caller checks;
      • the new scheduler_dp_check_deadline() syscall.
    • User halves:
      • the telemetry task counts;
      • the DP deadline-miss tracking;
      • user_ll_unlock_sched_all() and user_ll_relock_sched().
    • Moves with them: zephyr_ll_scheduler_free() now writes the kernel-only lock table, so it moves to the kernel half.
  • Check that no code was lost: every function of main's six scheduler sources is present, character for character apart from static/inline, in the user or kernel half.
  • Review: the build.sh root path comment was fixed in Phase 2 (part 6): move arch and platform to src/kernel, build src/kernel into sof_kernel #11420, now merged.

🤖 Generated with Claude Code

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.

🟡 Changes recommended

The build script’s four-parent traversal now resolves to the repository’s src directory rather than its root, producing incorrect source and include paths when run as documented.

1 open issue
What changed in this PR

Advances SOF’s kernel/user-space partition by moving privileged scheduler setup and syscall implementations into src/kernel/schedule, while retaining LL/DP thread execution in src/schedule. The reviewed changes also include stacked platform and architecture relocations, IPC build updates, and legacy DMA-trace cleanup.

Changes:

  • Builds scheduler kernel halves and the kernel-only TWB scheduler under the kernel tree.
  • Updates platform, architecture, tool, and test paths; integrates split IPC kernel sources.
  • Removes obsolete DMA-trace configuration and hooks, and updates partition documentation.

This pull request requires changes. One unresolved moderate issue remains (3 votes): at src/kernel/platform/mtk/tools/build.sh:16, the four-parent traversal initializes SOF to src rather than the repository root when run as documented. Traverse five parents to correct the generated source and include paths.

File Description
zephyr/​include/​sof/​trace/​trace.h Removes obsolete DMA-trace commentary.
zephyr/​include/​sof/​trace/​preproc.h Removes legacy trace configuration rejection.
zephyr/​include/​rtos/​sof.h Removes legacy trace context fields.
tools/​tplg_parser/​CMakeLists.txt Updates relocated host include paths.
tools/​testbench/​README.md Updates the configuration patch example.
tools/​testbench/​CMakeLists.txt Uses relocated configuration and headers.
test/​ztest/​unit/​objpool/​CMakeLists.txt Updates POSIX include path.
test/​ztest/​unit/​math/​matrix/​CMakeLists.txt Updates POSIX include path.
test/​ztest/​unit/​math/​fft/​CMakeLists.txt Updates headers and links kernel IPC half.
test/​ztest/​unit/​math/​fft_multi/​CMakeLists.txt Updates POSIX include path.
test/​ztest/​unit/​math/​dct/​CMakeLists.txt Updates POSIX include path.
test/​ztest/​unit/​math/​auditory/​CMakeLists.txt Updates POSIX include path.
test/​ztest/​unit/​math/​advanced/​functions/​CMakeLists.txt Updates POSIX include path.
test/​ztest/​unit/​fast-get/​CMakeLists.txt Updates POSIX include path.
test/​ztest/​unit/​dsrc/​CMakeLists.txt Updates POSIX include path.
test/​ztest/​unit/​audio/​drc/​CMakeLists.txt Updates headers and links kernel IPC half.
test/​ztest/​unit/​audio/​crossover/​CMakeLists.txt Updates POSIX include path.
test/​cmocka/​src/​math/​fft/​CMakeLists.txt Links kernel IPC half.
test/​cmocka/​src/​lib/​fast-get/​CMakeLists.txt Uses relocated platform memory source.
test/​cmocka/​src/​lib/​alloc/​CMakeLists.txt Updates platform source and headers.
test/​cmocka/​src/​common_mocks.c Removes legacy trace mocks.
test/​cmocka/​src/​audio/​volume/​CMakeLists.txt Links kernel IPC half.
test/​cmocka/​src/​audio/​selector/​CMakeLists.txt Links kernel IPC half.
test/​cmocka/​src/​audio/​pipeline/​CMakeLists.txt Links kernel IPC half across tests.
test/​cmocka/​src/​audio/​pcm_converter/​CMakeLists.txt Links kernel IPC half.
test/​cmocka/​src/​audio/​mixer/​CMakeLists.txt Links kernel IPC half.
test/​cmocka/​src/​audio/​eq_iir/​CMakeLists.txt Links kernel IPC half.
test/​cmocka/​src/​audio/​eq_fir/​CMakeLists.txt Links kernel IPC half.
test/​cmocka/​src/​audio/​dcblock/​CMakeLists.txt Links kernel IPC half.
test/​cmocka/​src/​audio/​component/​CMakeLists.txt Links kernel IPC half.
test/​cmocka/​src/​audio/​buffer/​CMakeLists.txt Links kernel IPC half across tests.
test/​cmocka/​configs/​rembrandt_defconfig Removes legacy trace-channel setting.
test/​cmocka/​configs/​acp_7_x_defconfig Removes legacy trace-channel setting.
test/​cmocka/​configs/​acp_7_0_defconfig Removes legacy trace-channel setting.
test/​cmocka/​CMakeLists.txt Updates Intel platform include paths.
src/​trace/​CMakeLists.txt Deletes legacy trace build wiring.
src/​schedule/​README.md Documents scheduler kernel/user split.
src/​schedule/​CMakeLists.txt Removes kernel-only TWB source.
src/​kernel/​schedule/​CMakeLists.txt Builds scheduler kernel halves and TWB.
src/​kernel/​platform/​tigerlake/​include/​platform/​trace/​trace.h Relocates platform trace header.
src/​kernel/​platform/​tigerlake/​include/​platform/​platform.h Relocates platform definitions.
src/​kernel/​platform/​tigerlake/​include/​platform/​lib/​memory.h Removes conditional legacy trace allocation.
src/​kernel/​platform/​tigerlake/​include/​platform/​lib/​mailbox.h Relocates mailbox header.
src/​kernel/​platform/​README.md Updates location and documentation link.
src/​kernel/​platform/​qemu_xtensa/​platform.c Relocates platform stubs.
src/​kernel/​platform/​qemu_xtensa/​include/​platform/​trace/​trace.h Relocates trace stub header.
src/​kernel/​platform/​qemu_xtensa/​include/​platform/​platform.h Relocates platform stub definitions.
src/​kernel/​platform/​qemu_xtensa/​include/​platform/​lib/​memory.h Relocates memory stub header.
src/​kernel/​platform/​qemu_xtensa/​include/​platform/​lib/​mailbox.h Relocates mailbox stubs.
src/​kernel/​platform/​qemu_xtensa/​include/​platform/​lib/​dma.h Relocates DMA definitions.
src/​kernel/​platform/​qemu_xtensa/​include/​platform/​lib/​dai.h Relocates DAI stub header.
src/​kernel/​platform/​qemu_xtensa/​include/​platform/​lib/​clk.h Relocates clock definitions.
src/​kernel/​platform/​posix/​include/​platform/​trace/​trace.h Relocates trace stub header.
src/​kernel/​platform/​posix/​include/​platform/​platform.h Relocates platform definitions.
src/​kernel/​platform/​posix/​include/​platform/​lib/​pm_runtime.h Relocates runtime-PM stubs.
src/​kernel/​platform/​posix/​include/​platform/​lib/​memory.h Relocates mailbox backing definitions.
src/​kernel/​platform/​posix/​include/​platform/​lib/​mailbox.h Relocates mailbox stubs.
src/​kernel/​platform/​posix/​include/​platform/​lib/​dma.h Relocates DMA definitions.
src/​kernel/​platform/​posix/​include/​platform/​lib/​dai.h Relocates DAI definitions.
src/​kernel/​platform/​posix/​include/​platform/​lib/​cpu.h Relocates CPU declarations.
src/​kernel/​platform/​posix/​include/​platform/​lib/​clk.h Relocates clock declarations.
src/​kernel/​platform/​posix/​include/​platform/​fuzz.h Relocates fuzz-state API.
src/​kernel/​platform/​posix/​include/​platform/​drivers/​interrupt.h Relocates interrupt definitions.
src/​kernel/​platform/​posix/​include/​platform/​drivers/​idc.h Relocates IDC stub.
src/​kernel/​platform/​novalake/​lib/​clk.c Relocates CPU frequency table.
src/​kernel/​platform/​novalake/​include/​platform/​trace/​trace.h Relocates trace header.
src/​kernel/​platform/​novalake/​include/​platform/​platform.h Relocates platform definitions.
src/​kernel/​platform/​novalake/​include/​platform/​lib/​mailbox.h Relocates mailbox header.
src/​kernel/​platform/​novalake/​include/​platform/​lib/​clk.h Relocates clock definitions.
src/​kernel/​platform/​mtk/​tools/​README.txt Relocates generator instructions.
src/​kernel/​platform/​mtk/​tools/​build.sh Updates generator paths; root traversal needs correction.
src/​kernel/​platform/​mtk/​include/​platform/​trace/​trace.h Relocates trace stub header.
src/​kernel/​platform/​mtk/​include/​platform/​platform.h Relocates platform definitions.
src/​kernel/​platform/​mtk/​include/​platform/​lib/​pm_runtime.h Relocates runtime-PM stubs.
src/​kernel/​platform/​mtk/​include/​platform/​lib/​mailbox.h Relocates mailbox definitions.
src/​kernel/​platform/​mtk/​include/​platform/​lib/​dma.h Relocates DMA definitions.
src/​kernel/​platform/​mtk/​include/​platform/​lib/​dai.h Relocates DAI stub header.
src/​kernel/​platform/​mtk/​include/​platform/​lib/​cpu.h Relocates CPU definitions.
src/​kernel/​platform/​mtk/​include/​platform/​lib/​clk.h Relocates clock definitions.
src/​kernel/​platform/​meteorlake/​lib/​clk.c Relocates CPU frequency table.
src/​kernel/​platform/​meteorlake/​include/​platform/​trace/​trace.h Relocates trace header.
src/​kernel/​platform/​meteorlake/​include/​platform/​platform.h Relocates platform definitions.
src/​kernel/​platform/​meteorlake/​include/​platform/​lib/​mailbox.h Relocates mailbox header.
src/​kernel/​platform/​meteorlake/​include/​platform/​lib/​clk.h Relocates clock definitions.
src/​kernel/​platform/​lunarlake/​lib/​clk.c Relocates CPU frequency table.
src/​kernel/​platform/​lunarlake/​include/​platform/​trace/​trace.h Relocates trace header.
src/​kernel/​platform/​lunarlake/​include/​platform/​platform.h Relocates platform definitions.
src/​kernel/​platform/​lunarlake/​include/​platform/​lib/​mailbox.h Relocates mailbox header.
src/​kernel/​platform/​lunarlake/​include/​platform/​lib/​clk.h Relocates clock definitions.
src/​kernel/​platform/​library/​schedule/​CMakeLists.txt Relocates host scheduler build wiring.
src/​kernel/​platform/​library/​platform.c Relocates host platform initialization.
src/​kernel/​platform/​library/​panic.c Relocates host panic implementation.
src/​kernel/​platform/​library/​lib/​trace.c Removes DMA-trace include.
src/​kernel/​platform/​library/​lib/​pm_runtime.c Relocates runtime-PM stubs.
src/​kernel/​platform/​library/​lib/​dai.c Relocates host DAI initialization.
src/​kernel/​platform/​library/​lib/​CMakeLists.txt Builds host trace support unconditionally.
src/​kernel/​platform/​library/​lib/​clk.c Relocates clock stubs.
src/​kernel/​platform/​library/​lib/​alloc.c Relocates host allocation wrappers.
src/​kernel/​platform/​library/​init.c Relocates host firmware context.
src/​kernel/​platform/​library/​include/​platform/​lib/​ll_schedule.h Relocates host LL scheduler API.
src/​kernel/​platform/​library/​include/​platform/​lib/​dma.h Relocates DMA definitions.
src/​kernel/​platform/​library/​include/​platform/​lib/​dai.h Relocates DAI definitions.
src/​kernel/​platform/​library/​include/​platform/​lib/​cpu.h Relocates CPU definitions.
src/​kernel/​platform/​library/​include/​platform/​lib/​clk.h Relocates clock definitions.
src/​kernel/​platform/​library/​include/​platform/​drivers/​pmc.h Relocates PMC declarations.
src/​kernel/​platform/​library/​include/​platform/​drivers/​idc.h Relocates IDC stubs.
src/​kernel/​platform/​library/​CMakeLists.txt Relocates host platform build wiring.
src/​kernel/​platform/​intel/​cavs/​include/​cavs/​version.h Relocates hardware version definitions.
src/​kernel/​platform/​intel/​cavs/​include/​cavs/​trace/​trace.h Relocates platform trace implementation.
src/​kernel/​platform/​intel/​cavs/​include/​cavs/​mem_window.h Relocates memory-window API.
src/​kernel/​platform/​intel/​cavs/​include/​cavs/​lib/​power_down.h Relocates power-down API.
src/​kernel/​platform/​intel/​cavs/​include/​cavs/​ext_manifest.h Relocates manifest definitions.
src/​kernel/​platform/​intel/​cavs/​include/​cavs/​drivers/​timestamp.h Relocates timestamp register definitions.
src/​kernel/​platform/​intel/​cavs/​include/​cavs/​drivers/​sideband-ipc.h Relocates IPC register definitions.
src/​kernel/​platform/​intel/​cavs/​include/​cavs/​drivers/​mn.h Relocates clock-divider definitions.
src/​kernel/​platform/​intel/​ace/​include/​auth/​intel_status_logger_api.h Relocates status-logger wrappers.
src/​kernel/​platform/​intel/​ace/​include/​ace/​version.h Relocates hardware version definitions.
src/​kernel/​platform/​intel/​ace/​include/​ace/​lib/​memory.h Relocates shared memory header.
src/​kernel/​platform/​intel/​ace/​include/​ace/​lib/​clk.h Relocates shared clock declarations.
src/​kernel/​platform/​imx95/​linker/​data-sections.ld Relocates firmware metadata linker section.
src/​kernel/​platform/​imx95/​lib/​clk.c Relocates clock initialization.
src/​kernel/​platform/​imx95/​include/​platform/​trace/​trace.h Relocates trace stub header.
src/​kernel/​platform/​imx95/​include/​platform/​platform.h Relocates platform definitions.
src/​kernel/​platform/​imx95/​include/​platform/​lib/​memory.h Relocates memory definitions.
src/​kernel/​platform/​imx95/​include/​platform/​lib/​mailbox.h Relocates mailbox layout.
src/​kernel/​platform/​imx95/​include/​platform/​lib/​dma.h Relocates DMA stub header.
src/​kernel/​platform/​imx95/​include/​platform/​lib/​clk.h Relocates clock API.
src/​kernel/​platform/​imx93_a55/​lib/​clk.c Relocates clock initialization.
src/​kernel/​platform/​imx93_a55/​include/​platform/​trace/​trace.h Relocates trace stub header.
src/​kernel/​platform/​imx93_a55/​include/​platform/​platform.h Relocates platform definitions.
src/​kernel/​platform/​imx93_a55/​include/​platform/​lib/​memory.h Relocates memory definitions.
src/​kernel/​platform/​imx93_a55/​include/​platform/​lib/​dma.h Relocates DMA definitions.
src/​kernel/​platform/​imx93_a55/​include/​platform/​lib/​dai.h Relocates DAI stub header.
src/​kernel/​platform/​imx93_a55/​include/​platform/​lib/​clk.h Relocates clock API.
src/​kernel/​platform/​imx93_a55/​include/​platform/​drivers/​idc.h Relocates IDC stub.
src/​kernel/​platform/​imx8ulp/​platform.c Removes legacy DMA-trace initialization.
src/​kernel/​platform/​imx8ulp/​lib/​clk.c Relocates clock initialization.
src/​kernel/​platform/​imx8ulp/​include/​platform/​trace/​trace.h Relocates trace stub header.
src/​kernel/​platform/​imx8ulp/​include/​platform/​lib/​dma.h Relocates DMA definitions.
src/​kernel/​platform/​imx8ulp/​include/​platform/​lib/​dai.h Relocates DAI stub header.
src/​kernel/​platform/​imx8ulp/​include/​platform/​lib/​cpu.h Relocates CPU definitions.
src/​kernel/​platform/​imx8ulp/​include/​platform/​lib/​clk.h Relocates clock API.
src/​kernel/​platform/​imx8ulp/​include/​platform/​drivers/​interrupt.h Relocates interrupt definitions.
src/​kernel/​platform/​imx8ulp/​include/​platform/​drivers/​idc.h Relocates IDC stubs.
src/​kernel/​platform/​imx8ulp/​include/​arch/​xtensa/​config/​defs.h Relocates Xtensa compatibility header.
src/​kernel/​platform/​imx8m/​platform.c Removes legacy DMA-trace initialization.
src/​kernel/​platform/​imx8m/​lib/​clk.c Relocates clock initialization.
src/​kernel/​platform/​imx8m/​include/​platform/​trace/​trace.h Relocates trace stub header.
src/​kernel/​platform/​imx8m/​include/​platform/​lib/​pm_runtime.h Relocates runtime-PM stubs.
src/​kernel/​platform/​imx8m/​include/​platform/​lib/​dai.h Relocates DAI stub header.
src/​kernel/​platform/​imx8m/​include/​platform/​lib/​cpu.h Relocates CPU definitions.
src/​kernel/​platform/​imx8m/​include/​platform/​lib/​clk.h Relocates clock API.
src/​kernel/​platform/​imx8m/​include/​platform/​drivers/​idc.h Relocates IDC stubs.
src/​kernel/​platform/​imx8m/​include/​arch/​xtensa/​config/​defs.h Relocates Xtensa compatibility header.
src/​kernel/​platform/​imx8m_cm7/​linker/​data-sections.ld Relocates firmware metadata linker section.
src/​kernel/​platform/​imx8m_cm7/​lib/​clk.c Relocates clock initialization.
src/​kernel/​platform/​imx8m_cm7/​include/​platform/​trace/​trace.h Relocates trace stub header.
src/​kernel/​platform/​imx8m_cm7/​include/​platform/​platform.h Relocates platform definitions.
src/​kernel/​platform/​imx8m_cm7/​include/​platform/​lib/​memory.h Relocates memory definitions.
src/​kernel/​platform/​imx8m_cm7/​include/​platform/​lib/​mailbox.h Relocates mailbox layout.
src/​kernel/​platform/​imx8m_cm7/​include/​platform/​lib/​dma.h Relocates DMA stub header.
src/​kernel/​platform/​imx8m_cm7/​include/​platform/​lib/​clk.h Relocates clock API.
src/​kernel/​platform/​imx8/​lib/​clk.c Relocates clock initialization.
src/​kernel/​platform/​imx8/​include/​platform/​trace/​trace.h Relocates trace stub header.
src/​kernel/​platform/​imx8/​include/​platform/​lib/​dma.h Relocates DMA definitions.
src/​kernel/​platform/​imx8/​include/​platform/​lib/​dai.h Relocates DAI stub header.
src/​kernel/​platform/​imx8/​include/​platform/​lib/​cpu.h Relocates CPU definitions.
src/​kernel/​platform/​imx8/​include/​platform/​lib/​clk.h Relocates clock API.
src/​kernel/​platform/​imx8/​include/​platform/​drivers/​idc.h Relocates IDC stubs.
src/​kernel/​platform/​imx8/​include/​arch/​xtensa/​config/​defs.h Relocates Xtensa compatibility header.
src/​kernel/​platform/​CMakeLists.txt Builds relocated host platform.
src/​kernel/​platform/​amd/​rembrandt/​platform.c Removes legacy DMA-trace setup.
src/​kernel/​platform/​amd/​rembrandt/​include/​arch/​xtensa/​config/​defs.h Relocates Xtensa compatibility header.
src/​kernel/​platform/​amd/​common/​include/​platform/​trace/​trace.h Relocates trace stub header.
src/​kernel/​platform/​amd/​common/​include/​platform/​lib/​pm_runtime.h Relocates runtime-PM stubs.
src/​kernel/​platform/​amd/​common/​include/​platform/​lib/​mailbox.h Relocates mailbox definitions.
src/​kernel/​platform/​amd/​common/​include/​platform/​lib/​dma.h Relocates DMA definitions.
src/​kernel/​platform/​amd/​common/​include/​platform/​lib/​cpu.h Relocates CPU definitions.
src/​kernel/​platform/​amd/​common/​include/​platform/​lib/​clk.h Relocates clock API.
src/​kernel/​platform/​amd/​common/​include/​platform/​ipc.h Relocates IPC declarations.
src/​kernel/​platform/​amd/​common/​include/​platform/​drivers/​idc.h Relocates IDC stubs.
src/​kernel/​platform/​amd/​common/​include/​platform/​acp_sp_dma.h Relocates serial-port DMA API.
src/​kernel/​platform/​amd/​common/​include/​platform/​acp_dmic_dma.h Relocates DMIC DMA API.
src/​kernel/​platform/​amd/​common/​include/​platform/​acp_dma.h Relocates DMA structures and API.
src/​kernel/​platform/​amd/​acp_7_x/​platform.c Removes DMA-trace include.
src/​kernel/​platform/​amd/​acp_7_0/​platform.c Removes DMA-trace include.
src/​kernel/​platform/​amd/​acp_7_0/​include/​arch/​xtensa/​config/​defs.h Relocates Xtensa compatibility header.
src/​kernel/​platform/​ace30/​lib/​clk.c Relocates CPU frequency table.
src/​kernel/​platform/​ace30/​include/​platform/​trace/​trace.h Relocates trace header.
src/​kernel/​platform/​ace30/​include/​platform/​platform.h Relocates platform definitions.
src/​kernel/​platform/​ace30/​include/​platform/​lib/​mailbox.h Relocates mailbox header.
src/​kernel/​platform/​ace30/​include/​platform/​lib/​clk.h Relocates clock definitions.
src/​kernel/​logging/​Kconfig Relocates probe logging configuration.
src/​kernel/​Kconfig Sources relocated logging configuration.
src/​kernel/​ipc/​ipc4/​CMakeLists.txt Builds split IPC4 kernel halves.
src/​kernel/​ipc/​ipc3/​helper.c Removes legacy trace-message helpers.
src/​kernel/​ipc/​CMakeLists.txt Builds common IPC kernel half.
src/​kernel/​init/​README.md Removes obsolete trace initialization description.
src/​kernel/​init/​init.c Removes legacy trace initialization.
src/​kernel/​CMakeLists.txt Builds relocated host architecture/platform.
src/​kernel/​arch/​xtensa/​Kconfig Relocates Xtensa configuration.
src/​kernel/​arch/​README.md Updates location and documentation link.
src/​kernel/​arch/​Kconfig Relocates architecture configuration dispatch.
src/​kernel/​arch/​host/​lib/​notifier.c Relocates host notifier context.
src/​kernel/​arch/​host/​lib/​CMakeLists.txt Relocates host architecture build wiring.
src/​kernel/​arch/​host/​lib/​ams.c Relocates host AMS context.
src/​kernel/​arch/​host/​include/​arch/​sof.h Relocates architecture context header.
src/​kernel/​arch/​host/​include/​arch/​schedule/​task.h Relocates task compatibility header.
src/​kernel/​arch/​host/​include/​arch/​lib/​wait.h Relocates wait stubs.
src/​kernel/​arch/​host/​include/​arch/​lib/​cpu.h Relocates CPU stubs.
src/​kernel/​arch/​host/​include/​arch/​lib/​cache.h Relocates cache stubs.
src/​kernel/​arch/​host/​include/​arch/​drivers/​timer.h Relocates timer stubs.
src/​kernel/​arch/​host/​include/​arch/​drivers/​interrupt.h Relocates interrupt stubs.
src/​kernel/​arch/​host/​include/​arch/​drivers/​idc.h Relocates IDC compatibility header.
src/​kernel/​arch/​host/​include/​arch/​debug/​panic.h Relocates panic stub.
src/​kernel/​arch/​host/​include/​arch/​debug/​backtrace.h Relocates host backtrace implementation.
src/​kernel/​arch/​host/​include/​arch/​compiler_info.h Relocates compiler metadata definitions.
src/​kernel/​arch/​host/​configs/​library_defconfig Removes verbose legacy trace setting.
src/​kernel/​arch/​host/​CMakeLists.txt Updates public host include paths.
src/​kernel/​arch/​CMakeLists.txt Builds relocated architecture directory.
src/​Kconfig Updates kernel paths and removes trace configuration.
src/​ipc/​README.md Updates platform driver location.
src/​ipc/​ipc4/​README.md Documents split kernel message routers.
src/​ipc/​CMakeLists.txt Removes trace-only DMA-copy build wiring.
src/​include/​sof/​schedule/​schedule.h Shares scheduler classification inline helper.
src/​include/​sof/​ipc/​topology.h Declares shared IPC4 helpers.
src/​include/​sof/​ipc/​msg.h Removes legacy trace-message declarations.
src/​include/​sof/​ipc/​common.h Shares user IPC entry/events; removes trace API.
src/​include/​sof/​debug/​debug.h Removes legacy hexadecimal trace macros.
src/​debug/​panic.c Removes legacy trace flushing.
src/​CMakeLists.txt Routes host architecture/platform through kernel tree.
src/​audio/​README.md Updates kernel-only platform path.
src/​audio/​module_adapter/​module/​waves/​waves.c Removes legacy verbose trace dumps.
src/​audio/​Kconfig Removes legacy trace-channel option.
scripts/​rebuild-testbench.sh Updates documented permanent configuration path.
scripts/​kernel_user_partition.txt Updates platform classification and removes trace header.
scripts/​cmake/​kconfig.cmake Updates host configuration search paths.
scripts/​cmake/​defconfigs.cmake Discovers relocated architecture configurations.
posix/​include/​rtos/​sof.h Removes legacy trace context fields.
doc/​sof.doxygen.in Removes legacy trace preprocessing definition.
CODEOWNERS Updates platform ownership paths.
CMakeLists.txt Uses relocated host architecture for tests.
app/​prj.conf Removes obsolete trace setting.
app/​CMakeLists.txt Uses relocated Xtensa include path.
app/​boards/​intel_adsp_ace40_nvls.conf Removes obsolete trace setting.
app/​boards/​intel_adsp_ace40_nvl.conf Removes obsolete trace setting.
app/​boards/​imx8mp_evk_mimx8ml8_adsp.conf Removes obsolete trace setting.
app/​boards/​acp_7_x_adsp.conf Removes obsolete trace setting.
app/​boards/​acp_7_0_adsp.conf Removes obsolete trace setting.
AGENTS.md Updates kernel-directory tier guidance.

Review effort: Balanced

Comment thread src/kernel/platform/mtk/tools/build.sh Resolved

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

The scheduler refactor crosses user/kernel boundaries, and ACE user-space LL and DP paths lack hardware runtime validation, requiring maintainer judgment on whether build and disassembly evidence is sufficient.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

lrgirdwo and others added 9 commits November 13, 2026 22:13
…hedule

zephyr_domain.c mixes the LL scheduler thread function and the parts of
the timer domain that run in the LL scheduler threads with the thread
and timer setup, which needs kernel mode. Move the kernel part to
src/kernel/schedule/zephyr_domain-kernel.c:
- the LL scheduler thread stacks and the timer interrupt handler;
- domain register and unregister of builds without user-space LL, which
  create and abort the scheduler threads and start and stop the timer;
- the user-space LL thread init and free, which also register the LL
  threads as SOF system call callers, the kernel-only per-core thread
  table and the thread lookups used for access grants;
- the domain ops and zephyr_domain_init().

zephyr_domain.c keeps the thread function, the user-space LL register
and unregister bookkeeping, the cross-core stream block and unblock and
ll_sch_is_current(). The domain data structures and the functions the
kernel part refers to are declared in the new scheduler-private header
sof/schedule/zephyr_ll.h. zephyr_domain.c no longer includes the timer,
userspace helper, platform and memory map headers.

The code is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
zephyr_ll.c is the LL scheduler, which runs in the LL scheduler threads
and, with user-space LL, in user mode. Its setup and a few other parts
need kernel mode. Move them to src/kernel/schedule/zephyr_ll-kernel.c:
- zephyr_ll_scheduler_init(), zephyr_ll_scheduler_free() and the
  scheduler ops, which allocate and free the per-core scheduler data and
  lock and register the scheduler at boot;
- the kernel-only copy of the per-core lock table, which the access
  grants use;
- the kernel half of the zephyr_ll_task_sem_alloc() and
  zephyr_ll_task_sem_free() system calls, with their caller checks, which
  allocate the per-task semaphores as kernel objects and grant the LL
  thread access to them;
- zephyr_ll_init_context(), which sets up the LL thread of a core and
  grants it access to the scheduler lock and the task semaphore;
- user_ll_grant_access(), which grants a thread access to the scheduler
  lock of a core.

The scheduler and per-task data structures, the per-core lock table and
the scheduler ops are declared in sof/schedule/zephyr_ll.h, and
zephyr_ll_assert_core(), which both parts use, becomes a static inline
there. The kernel part is built under the same condition as
zephyr_ll.c.

The code is unchanged, but the compiler inlines differently in the
smaller zephyr_ll.c: in builds with user-space support,
zephyr_ll_task_done() now inlines the system call wrapper of a log
message instead of calling an out-of-line copy of it, and the register
allocation of zephyr_ll_task_free() and zephyr_ll_task_init() differs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
zephyr_dp_schedule.h holds the DP scheduler data structures and helpers
shared by the DP scheduler sources. The kernel parts of those sources
move to src/kernel/schedule in the next patches and need it too, so move
it to sof/schedule/zephyr_dp_schedule.h. Add the include guard that it
did not have.

The generated code is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…el/schedule

zephyr_dp_schedule.c holds the DP scheduler code common to its thread
and application variants. Part of it needs kernel mode. Move it to
src/kernel/schedule/zephyr_dp_schedule-kernel.c:
- the per-core DP scheduler locks, which are kernel objects, and
  scheduler_dp_grant(), which grants threads access to them;
- the scheduler_dp_ll_tick() system call, with the description of the
  DP scheduling it drives, and the scheduler_dp_check_deadline() system
  call;
- scheduler_dp_init(), which allocates the per-core scheduler data,
  registers the scheduler and its ops at boot and sets up the LL tick
  task, together with the scheduler UUID, trace context and log module.

zephyr_dp_schedule.c keeps the lock and unlock helpers, the task
schedule, stop, cancel and free ops and the task info query. The locks
and the ops are declared in sof/schedule/zephyr_dp_schedule.h.

The code is unchanged, but z_impl_scheduler_dp_ll_tick() now calls the
lock and unlock helpers instead of inlining them, and in the application
variant scheduler_dp_task_free() calls scheduler_dp_task_stop() instead
of inlining it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…rc/kernel/schedule

In the thread variant of the DP scheduler, scheduler_dp_task_init()
allocates the DP thread, its stack and event, creates and pins the
thread and, for user-space modules, grants it access to its objects
and adds it to the module memory domain. Move it, and the kernel half
of the scheduler_dp_internal_free() system call, which frees those
objects, to src/kernel/schedule/zephyr_dp_schedule_thread-kernel.c.

zephyr_dp_schedule_thread.c keeps the DP thread function and the task
readiness and deadline calculation.

The code is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…nto src/kernel/schedule

In the application variant of the DP scheduler, scheduler_dp_task_init()
allocates the DP thread and its kernel objects, sets up the memory
domain of the module, grants the DP, IPC and LL threads access, and
records the kernel objects of the task in a kernel-only list. Move it
to src/kernel/schedule/zephyr_dp_schedule_application-kernel.c, with:
- the kernel object record list and its helpers;
- the memory domain pool and teardown;
- the kernel half of the scheduler_dp_internal_free() system call and
  its verification of the caller;
- the per-core DP thread synchronization semaphores, which are kernel
  objects.

zephyr_dp_schedule_application.c keeps the IPC packing and unpacking,
scheduler_dp_thread_ipc(), the task readiness and deadline calculation
and the DP thread function. The task memory layout and the packed IPC
structure, which both parts use, and the semaphores are declared in
sof/schedule/zephyr_dp_schedule.h.

The code is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
The thread-with-budget scheduler is kernel-only code. It serializes with
irq_lock(), including in its thread function, changes the priority and
time slice of its threads, whose budget callback runs in interrupt
context, and allocates the thread stacks itself. Move it to
src/kernel/schedule, which builds it into sof_kernel, and update the
scheduler README.

The code is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
scheduler_init() and scheduler_register() allocate and register the
schedulers at boot, on the kernel heap or, for the user-space
schedulers with user-space LL, on the system user heap, and panic on
failure. Move them to src/kernel/schedule/schedule-kernel.c.

schedule.c keeps schedule_task_init() and the task info query.
scheduler_is_user(), which both parts use, becomes a static inline in
sof/schedule/schedule.h.

The code is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Update the scheduler README for the split of the scheduler sources: the
kernel parts are in src/kernel/schedule, the TWB scheduler is there in
full, and the shared data structures are in sof/schedule/zephyr_ll.h and
sof/schedule/zephyr_dp_schedule.h. Point the syscall table of the
user-space README at the kernel files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
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