Skip to content

kernel/user partition, Phase 5 part 2: mic privacy state without the notifier - #11503

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

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

Conversation

@lgirdwood

@lgirdwood lgirdwood commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Phase 5 of #11306 (kernel / user-space partition), second part: mic privacy state changes no longer go through the notifier. This changes behaviour, see below.

Background

The mic privacy manager tells the copiers about mic privacy state changes with a NOTIFIER_ID_MIC_PRIVACY_STATE_CHANGE event.

  • Producers: the DMIC and firmware-managed mic privacy interrupts, the IRQ enable path, the base firmware's mic privacy IPC, and DAI resume after D3. All of them are kernel code.
  • Consumers: the copiers with mic privacy. On copiers on other cores, the notifier delivers the event through IDC, also from the interrupts.

The notifier is not usable from user space, and Phase 5 removes it.

What changes

  • The state word: the kernel posts the state as a single atomic word: an 8-bit sequence number, the mic disable state and the DMA data zeroing wait time.
    • The wait time is the 16-bit DDZWT field, which the copier turns into its ramp time.
    • The word lives in the sysuser partition, so the copiers can read it from user-space LL threads.
  • Taking it: each copier with mic privacy takes the word at the start of its next copy (copier_process()), in its own LL thread, on any core. No IDC is needed.
  • Which states: a copier records the sequence number when it configures mic privacy, where it registered for the notifier, so it only takes the states posted since then. With patch 2 it also starts from the current state.
  • The transitions: fade in from muted, fade out otherwise, and the ramp time are unchanged.
  • Removed: NOTIFIER_ID_MIC_PRIVACY_STATE_CHANGE.

This follows the same pattern as the KPB draining requests in #11497.

Patch 2: start a copier muted when the mic is muted

A copier that configures mic privacy starts unmuted, and only mutes at the next state change, on main as with patch 1. A capture started while the mic is muted records the mic until then (see Hardware below).

  • The fix: the state word holds the last state posted, so the copier takes its mute state and ramp time when it configures mic privacy.
  • At boot: the manager posts the state at boot, including after D3, when a mic privacy policy is set, so that the word holds it before the first change.

Behaviour changes

  • Timing: a copier applies a state change at its next copy, so within one LL period. With the notifier, the copier's state changed in the interrupt or IDC handler.
  • Stopped copiers: a copier that is not running takes the latest state when it runs again, instead of every change in turn.
    • With the notifier, a mute followed by an unmute while a copier was stopped left it fading out, because the unmute only applies to a muted copier.
    • Now it stays unmuted, which matches the mic.
  • New copiers (patch 2): a copier configured while the mic is muted starts muted, instead of unmuted until the next change.

Not in this part

The copier still calls kernel functions of the mic privacy manager when it configures mic privacy (mic_privacy_enable_dmic_irq(), mic_privacy_get_dma_zeroing_wait_time()). And mic_privacy_process(), which runs in the copier, is in the kernel file. Both are on the Phase 5 list, as is re-enabling mic privacy for user-space LL.

Testing

  • Builds, per commit: tgl, tgl-h, mtl, lnl, ptl, wcl, nvl, imx8, imx8x, imx8m, imx8m_cm7, imx8ulp, imx95 and qemu_xtensa, and the extra CI configurations:

    • PTL and WCL with internal_ci_overlay.conf;
    • 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;
    • PTL and TGL with app/debug_stream_overlay.conf, and PTL with that overlay and user-space LL.

    Only the internal CI configurations build mic privacy.

  • Object changes: as expected, and nothing else:

    • patch 1: copier.c and mic_privacy_manager_intel.c in the PTL and WCL internal CI builds, notifier.c in the imx93 and native_sim stub builds (the notifier ID count changes), and the PTL internal CI kernel object hash tables, which is layout;
    • patch 2: copier.c and mic_privacy_manager_intel.c in the PTL and WCL internal CI builds.
  • 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 (37 of 37 configurations).

  • Host: the host library builds. The CMocka tests were removed from main.

  • Testbench and tools: pass.

  • Include checker: passes with --strict, for the builds and for the sources.

  • Failing platforms: 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.

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

Hardware

Tested on a WCL board (RT722 and 4 DMICs). It has no remote mic privacy switch, so a test-only firmware timer posted a mute toggle every 2.5 s from interrupt context, as the DMIC mic privacy interrupt does. The board reports no mic privacy policy and a zero DDZWT, so there is no hardware zeroing and no fade: the copier's mute is a hard cut. The 4-channel DMIC capture was checked per 1 ms block.

main patch 1 patches 1 and 2
Mute and unmute after each toggle within ~20 ms within ~20 ms within ~20 ms
Capture started while muted (3 runs) mic recorded for 0.9 to 2.3 s, until the next change the same muted from the first sample until the unmute
Firmware errors none none none

Without the test timer, at the tip: DMIC captures are never muted, playback works, and capture works after a D3 cycle.

Found by the test, not changed here: the host copier's mic privacy code never runs. It is set up for a capture copier on ipc4_hda_host_output_class, which is the playback (host to DSP) class. Only the DAI copiers apply mic privacy.

Changes since the last push

  • Added patch 2, which fixes the start of a capture while the mic is muted.
  • Tested on hardware.

🤖 Generated with Claude Code

The mic privacy manager tells the copiers about mic privacy state
changes with a notifier event. The events come from the mic privacy
interrupts, the base firmware IPC and DAI resume, all kernel code, and
reach copiers on other cores through IDC. The notifier is not usable
from user space, and Phase 5 of the kernel / user-space partition
removes it.

Post the state in a single atomic word instead: a sequence number,
the mic disable state and the DMA data zeroing wait time, the 16-bit
DDZWT field. Each copier with mic privacy takes it at the start of its
next copy, in its own LL thread, on any core. As with the notifier,
which the copier registered for when it configured mic privacy, a
copier only takes the states posted since then.

A copier that is not running takes the latest state when it runs
again, instead of every change in turn. With the notifier, a mute
followed by an unmute while a copier was stopped left it fading out:
the unmute only applies to a muted copier. Now it stays unmuted.

Remove NOTIFIER_ID_MIC_PRIVACY_STATE_CHANGE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
A copier that configures mic privacy starts unmuted, and only mutes at
the next mic privacy state change. A capture started while the mic is
muted records the mic until then: tested on WCL, with a test hook that
toggles the mute state every 2.5 s, DMIC captures started while muted
recorded the mic for their first 0.9 to 2.3 s, until the next change.

The state word holds the last state posted, so a copier can start from
it: take its mute state and ramp time when configuring mic privacy, and
post the state at boot, including after D3, when a mic privacy policy is
set, so that the word holds it before the first change.

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.

2 participants