Skip to content

ASoC: SOF: Rework how Wake-on-Voice streams are kept running in S0ix - #6073

Open
ujfalusi wants to merge 10 commits into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/wov-suspend-resume-take2
Open

ujfalusi wants to merge 10 commits into
thesofproject:topic/sof-devfrom
ujfalusi:peter/sof/pr/wov-suspend-resume-take2

Conversation

@ujfalusi

@ujfalusi ujfalusi commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Today a WoV stream is kept running during S0ix by ignoring its SUSPEND trigger. ALSA/ASoC don't know about this: the PCM and the BEs' DPCM state go to SUSPENDED while the DSP pipelines and DMAs keep running. Userspace then gets -ESTRPIPE. If the stream is closed instead, no STOP is sent before hw_free, so the firmware is asked to free widgets of running pipelines.

This series reverts that approach and uses ASoC's ignore_suspend instead:

  • Reverts the four existing WoV suspend patches: the ignored SUSPEND trigger, the WoV stream definition, the hda-dai BE retention and the SNDRV_PCM_INFO_RESUME for VoW.
  • pm: moves the suspend target selection into a helper (no functional change).
  • pcm: clears suspend_ignored on STOP/PAUSE_PUSH, and frees the pipelines of such streams on everything except S0ix suspend (e.g. shutdown, remove).
  • pcm/pm: in the PM prepare callback, picks the running D0i3-compatible streams and sets ignore_suspend on their FE dai_link. The FE and BEs get no SUSPEND trigger and stay RUNNING, so the state bookkeeping matches the hardware. The flag is cleared in PM complete.
  • WoV definition (re-added): a WoV stream is a capture stream with CAPTURE_COMPATIBLE_D0I3 that is not Deep Buffer. This lifts the IPC4 block and drops d0i3_supported_in_s0ix.
  • soundwire: intel: doesn't stop the bus, or reinit it on resume, when it carries an enabled (kept-running) stream.
  • pcm: sets ignore_suspend on the FE DAI widget and the connected DAPM endpoints so the path stays powered while the card is in D3hot. The original flags are restored on the next suspend. If this fails, all streams are suspended normally.

ujfalusi and others added 10 commits December 1, 2026 16:47
…treams"

This reverts commit 1a9289d.

The Wake-on-Voice streams are going to be kept running during the system
suspend by skipping the suspend of their PCM. The stream stays in RUNNING
state and there is no need for the RESUME support anymore.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
…ng system suspend"

This reverts commit 21281ff.

The Wake-on-Voice streams are going to be kept running during the system
suspend by skipping the suspend of their PCM. The FE is not suspended,
the BEs will not receive SUSPEND trigger and they stay running without
special handling.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
…rted_in_s0ix"

This reverts commit 03fde15.

The definition of a Wake-on-Voice stream is going to be re-introduced as
part of the new handling of the WoV streams during system suspend.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
This reverts commit 2b79acd.

The handling of the Wake-on-Voice streams during system suspend is going
to be reworked.

The ignored SUSPEND trigger leaves the PCM in SUSPENDED state while the
stream is running in the firmware. ALSA does not send STOP for a
SUSPENDED stream before hw_free, the pipeline state bookkeeping is left
out of sync and the firmware is asked to free widgets of running
pipelines on close.
The DPCM state of the BEs is also out of sync with the hardware.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Move the code selecting the system suspend target out of snd_sof_prepare()
to a new sof_set_system_suspend_target() helper function.

The early returns in the target selection are no longer return from
snd_sof_prepare(), which allows further steps to be added to the prepare
callback which must be executed regardless of the selected target.

No functional change.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
…pped

The suspend_ignored flag marks the streams which are kept running with the
DSP in D0i3 during S0ix. A stream which is stopped or paused is no longer
running, clear the flag on STOP and PAUSE_PUSH triggers.

sof_pcm_free_all_streams() is used to tear down the pipelines on system
suspend and also on shutdown and remove. The streams with suspend_ignored
set must only be skipped when the system is suspending to S0ix, in all
other cases their pipelines must be freed as well.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
…re_suspend

When the system enters S0ix the D0i3 compatible streams are kept running
with the DSP in D0i3 to support Wake-on-Voice. Currently this is done by
ignoring the SUSPEND trigger of the stream.

The ALSA and ASoC core is not aware of this: the PCM is moved to SUSPENDED
state, the DPCM state of the BEs is also SUSPEND while the pipelines and
the DMAs are running.
Userspace gets -ESTRPIPE and it needs to restart the stream. If the stream
is closed instead, ALSA does not send STOP for the SUSPENDED stream before
hw_free and the pipelines are freed while they are running.

Use the ignore_suspend flag of the FE dai_link instead. ASoC skips the
suspend of the PCMs on dai_links with ignore_suspend set. There is no
SUSPEND trigger for the FE and the BEs, the stream stays in RUNNING state
and all state bookkeeping stays in sync with the hardware. A STOP or close
after the system resume is handled as a normal STOP.

The flag can not be static (from topology) since the streams can only be
kept running if the system enters S0ix. Select the streams to be kept
running from the PM prepare callback, which is executed before the sound
card is suspended. A stream is kept running if it is running, it is D0i3
compatible and there is no other running stream on the PCM which needs to
be suspended. The ignore_suspend flag is cleared in the PM complete
callback.

The suspend_ignored flag of the streams is now set in prepare, it is used
to keep the DSP in D0 and to skip the freeing of the stream during suspend.
Besides the stop and pause it is also cleared on the next system suspend.
It cannot be cleared on resume as the IPC3 keyword detect widget events are
checking it during the deferred resume of the card.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
…s0ix

Historically the CAPTURE_COMPATIBLE_D0I3 have been added to mark the WoV
stream during IPC3 era. For symmetry the PLAYBACK_COMPATIBLE_D0I3 token
was added as well.
Later IPC4 declared that WoV is not supported and started to use the
playback token to mark Deep Buffer streams (host can enter lower power
state) and after that using this example a Deep Buffer support for capture
was added - again, keeping the WoV unsupported by IPC4.

To lift the WoV block for IPC4 and keeping the IPC3 support intact the
definition of WoV stream is:
a capture stream,
CAPTURE_COMPATIBLE_D0I3 is set for the PCM,
it is not a Deep Buffer stream.

With this rule we can clearly identify the WoV stream and we can tell it
apart from Deep Buffer capture.

Only the WoV streams are kept running during S0ix, which allows the
d0i3_supported_in_s0ix flag to be dropped.

If Deep Buffer will be needed for WoV then we need bigger changes in
firmware, topology (new token) and kernel.

Signed-off-by: Jyri Sarha <jyri.sarha@linux.intel.com>
Co-developed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
…suspend

A stream can be kept running during system suspend, for example a
Wake-on-Voice capture while the system is in S0ix. Stopping the bus under
such a stream breaks the stream.

The sound card is suspended before the SoundWire links. A stream is only
enabled while it is running: it is disabled on PAUSE_PUSH, STOP and
SUSPEND triggers, and the card's suspend sends SUSPEND to all the running
streams which are not kept running. When the link is suspended, an
enabled stream on the bus is a stream which is kept running.

Add sdw_bus_has_enabled_stream() and skip the stop of the bus in the
suspend callback when the bus carries an enabled stream. Record this, so
the resume callback skips the re-initialization of the bus. Do not mark
the DAIs with enabled streams as suspended, so they are not reconfigured
on resume.

A bus with only paused or stopped streams is suspended as before.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Co-developed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
The sound card is moved to D3hot during system suspend and DAPM powers down
all paths unless their endpoints are marked with ignore_suspend. The
ignore_suspend flag of the FE dai_link only prevents the suspend of the
PCM, the path of a stream kept running during S0ix is still powered down.

When a stream is selected to be kept running in sof_pcm_suspend_prepare(),
set the ignore_suspend flag of the FE DAI widget and of all the endpoint
widgets connected to it. The card's suspend re-evaluates the endpoints
after the power state change, so the new flags are taken into account.

The initial value of the flags is saved and restored on the next system
suspend: the flag has no effect while the card is powered and the path
stays powered until the stream is stopped. A widget shared between kept
streams is only tracked once.

If the path cannot be kept powered, none of the streams are kept running,
they are suspended normally.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Co-developed-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Critical suspend/resume issues tear down retained IPC3 WoV pipelines without rebuilding them on D0 resume and can free duplex playback resources while leaving playback unsuspended.

2 open issues
What changed in this PR

Reworks SOF Wake-on-Voice retention during S0ix to use ASoC’s ignore_suspend, keeping software stream state aligned with running hardware.

Changes:

  • Selects eligible capture streams during PM prepare and preserves their DAPM paths.
  • Removes trigger-based suspend bypasses and updates stream cleanup.
  • Keeps Intel SoundWire buses active when they carry retained streams.
File Description
sound/​soc/​sof/​sof-priv.h Tracks DAPM widgets with temporary suspend overrides.
sound/​soc/​sof/​sof-audio.h Adds retained-link tracking and suspend helper declarations.
sound/​soc/​sof/​pm.c Integrates retention helpers and adjusts pipeline teardown.
sound/​soc/​sof/​pcm.c Implements stream selection, DAPM retention, and cleanup.
sound/​soc/​sof/​intel/​hda.h Removes obsolete HDA stream retention state.
sound/​soc/​sof/​intel/​hda-pcm.c Removes WoV’s advertised RESUME support.
sound/​soc/​sof/​intel/​hda-dsp.c Updates the S0ix power-state explanation comment.
sound/​soc/​sof/​intel/​hda-dai.c Removes backend trigger-based retention logic.
sound/​soc/​sof/​core.c Initializes the DAPM retention tracking list.
include/​linux/​soundwire/​sdw.h Declares the enabled-stream query helper.
drivers/​soundwire/​stream.c Implements the bus enabled-stream query.
drivers/​soundwire/​intel.h Tracks bus retention across system suspend.
drivers/​soundwire/​intel.c Avoids marking enabled streams suspended.
drivers/​soundwire/​intel_auxdevice.c Skips bus shutdown and reinitialization for retained buses.
drivers/​soundwire/​intel_ace2x.c Preserves enabled streams in ACE2x suspend handling.

Review effort: Balanced

Comment thread sound/soc/sof/pcm.c
Comment on lines +480 to +481
if (!sof_pcm_stream_is_running(substream))
continue;
Comment thread sound/soc/sof/pm.c
Comment on lines +251 to 252
if (tplg_ops && tplg_ops->tear_down_all_pipelines && (old_state == SOF_DSP_PM_D0))
tplg_ops->tear_down_all_pipelines(sdev, false);
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