Skip to content

Kernel/user partition, Phase 5 part 3: trigger DAI groups without the notifier - #11512

Draft
lgirdwood wants to merge 2 commits into
thesofproject:mainfrom
lgirdwood:kernel-user/phase5c
Draft

lgirdwood wants to merge 2 commits into
thesofproject:mainfrom
lgirdwood:kernel-user/phase5c

Conversation

@lgirdwood

Copy link
Copy Markdown
Member

Phase 5 of #11306 (kernel / user-space partition), third part: DAI groups no longer use the notifier.

Background

A DAI group starts and stops several DAIs together. Each DAI counts the trigger commands it gets. The last DAI of the group to receive the command triggers the whole group, with IRQs locked.

That trigger was a NOTIFIER_ID_DAI_TRIGGER event on the local core, which every DAI of the group registered for. The notifier is not usable from user space, and Phase 5 removes it.

What changes

  • The member list: a group keeps a list of its DAIs.
    • A DAI joins the list when it is assigned to the group (dai_assign_group()), and dai_common_free() removes it.
    • The last DAI to receive the command walks the list and triggers each DAI. The list is in the same order as the notifier list was.
  • Errors: the group still returns the error of the last trigger.
  • Locking: the DAIs are triggered with IRQs locked, as before. In user-space LL builds irq_local_disable() is privileged, so the group trigger takes the LL scheduler lock instead, as the copier does for its channel map update. The lock is re-entrant, so this is safe if the caller already holds it.
  • Removed: NOTIFIER_ID_DAI_TRIGGER and struct dai_group::trigger_ret.

Both the Zephyr DAI (dai-zephyr.c) and the legacy DAI (dai-legacy.c) change. They share the group code in src/lib/dai.c.

Fixes

With IPC4 the DAI is a copier, and dai_assign_group() gets the copier device. Two things were wrong there:

  • The notifier callback took the DAI data from comp_get_drvdata(). For a copier that is the module, not the DAI data.
  • copier_dai_free() did not unregister from the notifier, so a freed copier stayed registered.

The walk uses each member's DAI data and its component, and dai_common_free() removes the DAI from the group, so both are fixed.

In practice, IPC4 never sets a group ID: the Linux driver aggregates links with ALH multi-gateway instead. Only IPC3 hosts can send one, in sof_ipc_dai_config.group_id.

Behaviour changes

  • User-space LL builds: the group trigger is atomic against the LL tasks of its core, but not against interrupts. Before, these builds called the privileged irq_local_disable() from user code.
  • Other builds: none.

Patches

  1. dai: trigger a DAI group by walking its DAIs instead of the notifier.
  2. notifier: remove NOTIFIER_ID_DAI_TRIGGER. The IDs after it are renumbered; they are internal to the firmware.

Testing

  • Per commit, compared with main:
    • 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 user-space LL, which builds DAI groups (CONFIG_COMP_DAI_GROUP=y);
      • PTL with CONFIG_SOF_USERSPACE_PROXY=n;
      • PTL and MTL with os_linux_overlay.conf;llext_relocatable.conf;
      • PTL and TGL with app/debug_stream_overlay.conf, and PTL with that overlay and user-space LL.
    • Object changes: as expected, and nothing else:
      • patch 1: dai-zephyr.c and lib/dai.c, and the sources that use struct dai_data, whose fields after the new list entry move (the copier DAI code, the DAI telemetry, and cpu.c through the inlined resume_dais()). Built with the list entry at the end of struct dai_data instead, only the group functions change, plus register-move encodings elsewhere in dai-zephyr.c;
      • patch 2: notifier.c, because the notifier ID count changes.
    • 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 (22 of 22 configurations).
    • Host: the host library and the cmocka unit tests build and pass.
  • At the tip:
    • the testbench and the tools pass;
    • the host library and the cmocka unit tests pass for all nine defconfigs and the library config;
    • the include checker passes with --strict, for the builds (same 16 baseline sources) and for the sources;
    • 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. The legacy DAI (dai-legacy.c) is only built for some of them.

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

Not tested on hardware

No board here uses DAI groups: IPC4 does not set a group ID, and the boards here run IPC4.

🤖 Generated with Claude Code

lrgirdwo and others added 2 commits November 21, 2026 12:39
The last DAI of a group to receive a trigger command triggered the whole
group with a NOTIFIER_ID_DAI_TRIGGER event on the local core, which every
DAI of the group registered for. The notifier is not usable from user
space, and Phase 5 of the kernel / user-space partition removes it.

Keep the DAIs of a group in a list in the group instead. A DAI joins it
when it is assigned to the group and leaves it when it is freed, and the
last DAI to receive the command walks the list. The list is in the same
order as the notifier list, and the group still returns the error of the
last trigger.

This also fixes two problems with IPC4, where the DAI is a copier and
dai_assign_group() gets the copier device:
- the notifier callback took the DAI data from comp_get_drvdata(), which
  is the module and not the DAI data for a copier;
- copier_dai_free() did not unregister from the notifier.

The walk uses the DAI data of each member and its component, and
dai_common_free() removes the DAI from the group.

irq_local_disable() is privileged in user-space LL builds, so there the
group trigger takes the LL scheduler lock, as the copier does for its
channel map update. It is re-entrant, so this is safe if the caller holds
it. The other builds keep the IRQ lock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
DAI groups no longer use the notifier: the last DAI to receive a trigger
command walks the DAIs of its group. Remove the event ID.

The IDs after it are renumbered. They are internal to the firmware.

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

@lgirdwood lgirdwood left a comment

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.

Can we add a ztest for dai groups and a group in the nocodec topology if possible for pr validation

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.

2 participants