Skip to content

Phase 3 (part 3): split lib/dma.c, lib/dai.c and intel_uaol.c, kernel parts to src/kernel - #11459

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

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

Conversation

@lgirdwood

@lgirdwood lgirdwood commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Phase 3 of #11306 (kernel / user-space partition), third part: split lib/dma.c, lib/dai.c and audio/intel_uaol.c, and move their kernel parts into src/kernel. Based on current main (7f002a2), which includes #11422.

As in the earlier parts, 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.

Patches

  1. lib/dma.c → kernel/lib/dma-kernel.c:
    • Moves to the kernel half:
      • the kernel half of the sof_dma_get()/sof_dma_put() syscalls: DMA controller lookup, reference counting and channel allocation, with the accessors of the kernel-only DMA state;
      • the legacy (non-native) dma_get()/dma_put();
      • the DMA log module, UUID and trace context, which only that code uses.
    • Stays in dma.c: the scatter-gather helpers and the buffer copy functions that the host, DAI and copier components use, also in the user-space LL thread.
  2. lib/dai.c → kernel/lib/dai-kernel.c:
    • Moves to the kernel half:
      • the Zephyr DAI device table and dai_get_device_list(), which the user-space access grants use;
      • the kernel half of the dai_get_device() syscall;
      • the native and legacy dai_get()/dai_put(), which probe and remove the DAI drivers and are called by the IPC3 handler and the platform code.
    • Stays in dai.c: the DAI groups, which the DAI component uses.
  3. audio/intel_uaol.c → kernel/audio/intel_uaol-kernel.c:
    • Moves to the kernel half: the capabilities and stream mapping queries, which only the base firmware uses, with the IPC4 UAOL capabilities structures.
    • Stays in intel_uaol.c: the code that the DAI component runs in the LL thread: the feedback, rate adjustment and feedback DMA code, and the UAOL device table with its lookup, get_uaol_zdevice(). The table is in rodata, readable from user space. It is no longer static: sof/audio/intel_uaol.h declares it, sized from the devicetree, for the kernel queries.
    • Include checker: the user half is user code now, so it is dropped from the kernel sources listed under src/audio in the checker's manifest.
  4. Docs: the src/lib and user-space READMEs.

The dma/dai kernel halves are built wherever dma.c and dai.c are, including the host library. The UAOL kernel half has the same condition as intel_uaol.c.

Functional change

None. Every function of the three original files is present, character for character apart from static/inline, in the user or kernel half. The per-function disassembly of every image was compared before and after each commit. It differs only in:

  • dma.c: the line numbers the buffer copy functions pass to the assertion handler in qemu_xtensa, which has assertions enabled.
  • dai.c: nothing.
  • intel_uaol.c: the two kernel queries load the device from the table. With a single UAOL device, the compiler had reduced the static table to a constant. The code that runs in the LL thread is unchanged.

Symbols, the SYS_INIT() order, every build's .config and the generated rimage configurations are otherwise unchanged; compiler-generated switch tables are renumbered.

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.

      LNL, PTL, WCL and NVL build the UAOL support.

    • 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. Some of them build the legacy getters, now from the kernel halves.
  • Hardware: TGL (UP Xtreme i11), sof-hda-generic-cavs25-2ch.tplg, comparing main and the previous push of this branch. That covers the DMA and DAI getters; TGL has no UAOL, and the dma.c and dai.c commits are unchanged since. Both boot, play 5 s, and play again after runtime suspend, with no DSP errors.

All of the above, apart from the hardware test, was rerun on 7f002a2 (current main).

Changes since the last push

  • Rebased onto current main.
  • UAOL device table and lookup moved back to intel_uaol.c (Copilot review). get_uaol_zdevice() runs in the LL user thread, so it belongs in the user half, not in the supervisor-only src/kernel. The table is now shared with the kernel queries through sof/audio/intel_uaol.h. The LL-thread code is back to exactly main's code.

🤖 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 moved lookup remains directly callable from the LL user thread without a syscall boundary, violating the supervisor-only kernel contract.

1 open issue
What changed in this PR

This PR continues #11306’s kernel/user-space partition by splitting DMA, DAI and Intel UAOL code into application and kernel halves, with no intended functional change.

Changes:

  • Moves DMA controller management, DAI device management and UAOL firmware queries into src/kernel.
  • Updates build rules to include the new kernel files under the existing conditions.
  • Updates partition documentation and classifies the remaining UAOL audio code as user code.
File Description
src/​lib/​README.md Documents the DMA and DAI split.
src/​lib/​dma.c Retains scatter-gather and buffer helpers.
src/​lib/​dai.c Retains DAI group management.
src/​kernel/​lib/​dma-kernel.c Houses DMA lookup, reference counting and channel allocation.
src/​kernel/​lib/​dai-kernel.c Houses DAI device lookup and driver lifecycle operations.
src/​kernel/​lib/​CMakeLists.txt Builds both library kernel halves, including host builds.
src/​kernel/​audio/​intel_uaol-kernel.c Houses UAOL device lookup, capabilities and stream mapping.
src/​kernel/​audio/​CMakeLists.txt Builds the UAOL kernel half conditionally.
src/​include/​sof/​userspace/​README.md Updates DMA and DAI implementation paths.
src/​audio/​intel_uaol.c Retains feedback, rate adjustment and feedback DMA code.
scripts/​kernel_user_partition.txt Removes UAOL audio code from the kernel-source exceptions.

Review effort: Balanced

Comment thread src/kernel/audio/intel_uaol-kernel.c Outdated
return -1;
}

const struct device *get_uaol_zdevice(int uaol_link_id)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed, fixed in 928dd0b. The UAOL device table and get_uaol_zdevice() are back in src/audio/intel_uaol.c, so the code the LL user thread runs is exactly main's again. src/kernel/audio/intel_uaol-kernel.c now only has the two base firmware queries (tlv_value_set_uaol_caps() and uaol_stream_id_to_hda_link_stream_id()). They read the table through a declaration in sof/audio/intel_uaol.h, sized from the devicetree (DT_NUM_INST_STATUS_OKAY(intel_adsp_uaol)), so they still use ARRAY_SIZE() on it. The table stays in rodata, readable from user space. The only code change is one extra load in each kernel query, because the compiler can no longer fold the single-entry table into a constant.

lrgirdwo and others added 4 commits November 15, 2026 10:41
dma.c mixes the DMA controller lookup with DMA buffer helpers that the
host, DAI and copier components use, also in the user-space LL thread.
Move the kernel part to src/kernel/lib/dma-kernel.c:
- the kernel half of the sof_dma_get() and sof_dma_put() system calls,
  which pick a DMA controller, keep its reference count and allocate its
  channel array, with the accessors of the kernel-only DMA state;
- dma_get() and dma_put() of the legacy (non-native) DMA drivers;
- the DMA log module, UUID and trace context, which only that code uses.

dma.c keeps the scatter-gather list helpers and the buffer copy
functions. The kernel part is built wherever dma.c is, including the
host library.

The generated code is unchanged, apart from the line numbers that the
DMA buffer copy functions pass to the assertion handler in builds with
assertions (qemu_xtensa).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
dai.c mixes the DAI device lookup and the DAI getters with the DAI
groups, which the DAI component uses, also in the user-space LL thread.
Move the kernel part to src/kernel/lib/dai-kernel.c:
- the Zephyr DAI device table and dai_get_device_list(), which the
  user-space access grants use;
- the kernel half of the dai_get_device() system call;
- dai_get() and dai_put() of the native and legacy DAI drivers, which
  probe and remove the DAI drivers and are called by the IPC3 handler
  and the platform code.

dai.c keeps the DAI groups and the DAI log module and trace context,
which both parts use. It no longer includes the Zephyr DAI driver and
LL scheduler domain headers. The kernel part is built wherever dai.c
is, including the host library.

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>
The UAOL feedback support made intel_uaol.c mixed: the DAI component
calls the UAOL feedback, rate adjustment and feedback DMA functions from
the user-space LL thread, while the base firmware queries the UAOL
capabilities and stream mapping in kernel mode. Move the kernel part,
tlv_value_set_uaol_caps() and uaol_stream_id_to_hda_link_stream_id(),
with the IPC4 UAOL capabilities structures, to
src/kernel/audio/intel_uaol-kernel.c.

intel_uaol.c keeps the code that runs in the LL thread, including the
UAOL device table and its lookup, get_uaol_zdevice(). The table is in
rodata, readable from user space. It is no longer static: it is
declared in sof/audio/intel_uaol.h, sized from the devicetree, so the
kernel queries keep using ARRAY_SIZE() on it. intel_uaol.c is user code
now, so drop it from the kernel sources listed under src/audio in the
kernel include checker's manifest. The kernel part is built with the
same condition as intel_uaol.c.

The code is unchanged, but the two kernel queries now load the device
from the table: with a single UAOL device, the compiler had reduced the
static table to a constant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Update the src/lib and user-space READMEs for the split of dma.c and
dai.c: their kernel parts, with the kernel halves of the sof_dma_get(),
sof_dma_put() and dai_get_device() system calls, are now in
src/kernel/lib.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
@lgirdwood
lgirdwood marked this pull request as ready for review November 15, 2026 12:12
@intel-sofci

intel-sofci commented Nov 15, 2026 •

Copy link
Copy Markdown

PR 11459: test results

Run date: 2026-11-16 09:12 UTC

Tested commit: 1d75ad585596336c4da7b4b17464238e502e87f9

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

@lgirdwood

Copy link
Copy Markdown
Member Author

CI failure unrelated.

@lgirdwood
lgirdwood merged commit e9b5dd8 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