From bcc45e843f36c689629f400c54f9fa827447cd77 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 27 Nov 2026 11:25:07 +0200 Subject: [PATCH 01/10] Revert "ASoC: SOF: Intel:hda-pcm: Set SNDRV_PCM_INFO_RESUME for VoW streams" This reverts commit 1a9289de5c48. 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 --- sound/soc/sof/intel/hda-pcm.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/sound/soc/sof/intel/hda-pcm.c b/sound/soc/sof/intel/hda-pcm.c index 70abff12fef0ee..83efc9bdf418af 100644 --- a/sound/soc/sof/intel/hda-pcm.c +++ b/sound/soc/sof/intel/hda-pcm.c @@ -352,20 +352,6 @@ int hda_dsp_pcm_open(struct snd_sof_dev *sdev, spcm->stream[substream->stream].d0i3_compatible) flags |= SOF_HDA_STREAM_DMI_L1_COMPATIBLE; - /* - * Set the RESUME supported flag for WoV streams. The core will ignore - * the trigger but applications must not try to restart the WoV stream - * due to not supported RESUME. - * WoV streams can be indetified by: - * They are capture streams and - * They have the d0i3_compatible flag set and - * They don't use Deep Buffer - */ - if (direction == SNDRV_PCM_STREAM_CAPTURE && - spcm->stream[substream->stream].d0i3_compatible && - spcm->stream[substream->stream].dsp_max_burst_size_in_ms <= 1) - runtime->hw.info |= SNDRV_PCM_INFO_RESUME; - dsp_stream = hda_dsp_stream_get(sdev, direction, flags); if (!dsp_stream) { dev_err(sdev->dev, "error: no stream available\n"); From 4983d59ff4599fee92b2f7d4d419848d4fbf2dc4 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 27 Nov 2026 11:25:07 +0200 Subject: [PATCH 02/10] Revert "ASoC: SOF: Intel: hda-dai: Keep BEs used for WoV enabled during system suspend" This reverts commit 21281fffac7e. 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 --- sound/soc/sof/intel/hda-dai.c | 49 +---------------------------------- sound/soc/sof/intel/hda.h | 1 - 2 files changed, 1 insertion(+), 49 deletions(-) diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index 7a8875a885ab34..c8729b6d82bd4b 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -135,9 +135,6 @@ hda_link_dma_cleanup(struct snd_pcm_substream *substream, if (!hlink) return -EINVAL; - hda_stream = hstream_to_sof_hda_stream(hext_stream); - hda_stream->suspend_ignored = false; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { stream_tag = hdac_stream(hext_stream)->stream_tag; snd_hdac_ext_bus_link_clear_stream_id(hlink, stream_tag); @@ -160,6 +157,7 @@ hda_link_dma_cleanup(struct snd_pcm_substream *substream, hext_stream->link_prepared = 0; /* free the host DMA channel reserved by hostless streams */ + hda_stream = hstream_to_sof_hda_stream(hext_stream); hda_stream->host_reserved = 0; return 0; @@ -282,32 +280,6 @@ static int __maybe_unused hda_dai_hw_params(struct snd_pcm_substream *substream, return hda_dai_hw_params_data(substream, params, dai, &data, flags); } -static bool hda_dai_has_wov_fe(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); - struct snd_soc_dpcm *dpcm; - struct snd_sof_pcm *spcm; - - if (substream->stream != SNDRV_PCM_STREAM_CAPTURE) - return false; - - /* - * Only retain the BE for a connected WoV capture FE that is running - * or has already ignored its suspend trigger. An idle WoV FE may - * still be connected to the BE. - */ - for_each_dpcm_fe(rtd, SNDRV_PCM_STREAM_CAPTURE, dpcm) { - spcm = snd_sof_find_spcm_dai(sdev->component, dpcm->fe); - if (spcm && spcm->stream[SNDRV_PCM_STREAM_CAPTURE].d0i3_compatible && - spcm->stream[SNDRV_PCM_STREAM_CAPTURE].dsp_max_burst_size_in_ms <= 1 && - (dpcm->fe->dpcm[SNDRV_PCM_STREAM_CAPTURE].state == SND_SOC_DPCM_STATE_START || - spcm->stream[SNDRV_PCM_STREAM_CAPTURE].suspend_ignored)) - return true; - } - - return false; -} - /* * In contrast to IPC3, the dai trigger in IPC4 mixes pipeline state changes * (over IPC channel) and DMA state change (direct host register changes). @@ -317,7 +289,6 @@ static int __maybe_unused hda_dai_trigger(struct snd_pcm_substream *substream, i { const struct hda_dai_widget_dma_ops *ops = hda_dai_get_ops(substream, dai); struct hdac_ext_stream *hext_stream; - struct sof_intel_hda_stream *hda_stream; struct snd_sof_dev *sdev; int ret; @@ -334,24 +305,6 @@ static int __maybe_unused hda_dai_trigger(struct snd_pcm_substream *substream, i hext_stream = ops->get_hext_stream(sdev, dai, substream); if (!hext_stream) return -EINVAL; - hda_stream = hstream_to_sof_hda_stream(hext_stream); - - if (cmd == SNDRV_PCM_TRIGGER_RESUME && hda_stream->suspend_ignored) { - hda_stream->suspend_ignored = false; - return 0; - } - - /* - * Set the suspend_ignored flag for BE which is used with - * D0I3-compatible streams used for WoV to keep the firmware pipeline - * running. - */ - if (cmd == SNDRV_PCM_TRIGGER_SUSPEND && - sdev->system_suspend_target == SOF_SUSPEND_S0IX && - hda_dai_has_wov_fe(sdev, substream)) { - hda_stream->suspend_ignored = true; - return 0; - } if (ops->pre_trigger) { ret = ops->pre_trigger(sdev, dai, substream, cmd); diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index bc11519427649f..701578ec35cf4d 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -601,7 +601,6 @@ struct sof_intel_hda_stream { struct hdac_ext_stream hext_stream; struct sof_intel_stream sof_intel_stream; int host_reserved; /* reserve host DMA channel */ - bool suspend_ignored; u32 flags; struct completion ioc; }; From 806666c0ef12ab0ac20b6e6bfc7e2931e4850c52 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 27 Nov 2026 11:25:08 +0200 Subject: [PATCH 03/10] Revert "ASoC: SOF: Add definition of a WoV stream and drop d0i3_supported_in_s0ix" This reverts commit 03fde15a32c6. 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 --- sound/soc/sof/ipc3-pcm.c | 1 + sound/soc/sof/pcm.c | 16 ++++++---------- sound/soc/sof/sof-audio.h | 2 ++ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/sound/soc/sof/ipc3-pcm.c b/sound/soc/sof/ipc3-pcm.c index b95e888c0adb84..42f93e596598fd 100644 --- a/sound/soc/sof/ipc3-pcm.c +++ b/sound/soc/sof/ipc3-pcm.c @@ -431,6 +431,7 @@ const struct sof_ipc_pcm_ops ipc3_pcm_ops = { .trigger = sof_ipc3_pcm_trigger, .dai_link_fixup = sof_ipc3_pcm_dai_link_fixup, .reset_hw_params_during_stop = true, + .d0i3_supported_in_s0ix = true, #if IS_ENABLED(CONFIG_SND_SOC_SOF_COMPRESS) .compress_ops = &sof_ipc3_compressed_ops, #endif diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 0161c0ae8bbdb4..2ed475a7db6fbd 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -437,20 +437,16 @@ static int sof_pcm_trigger(struct snd_soc_component *component, return -EINVAL; case SNDRV_PCM_TRIGGER_SUSPEND: /* - * Set the suspend_ignored flag for D0I3-compatible streams used - * for WoV to keep the firmware pipeline running. - * WoV streams can be indetified by: - * They are capture streams and - * They have the d0i3_compatible flag set and - * They don't use Deep Buffer + * If DSP D0I3 is allowed during S0iX, set the suspend_ignored flag for + * D0I3-compatible streams to keep the firmware pipeline running */ - if (sdev->system_suspend_target == SOF_SUSPEND_S0IX && - substream->stream == SNDRV_PCM_STREAM_CAPTURE && - spcm->stream[substream->stream].d0i3_compatible && - spcm->stream[substream->stream].dsp_max_burst_size_in_ms <= 1) { + if (pcm_ops && pcm_ops->d0i3_supported_in_s0ix && + sdev->system_suspend_target == SOF_SUSPEND_S0IX && + spcm->stream[substream->stream].d0i3_compatible) { spcm->stream[substream->stream].suspend_ignored = true; return 0; } + /* On suspend the DMA must be stopped in DSPless mode */ if (sdev->dspless_mode_selected) reset_hw_params = true; diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index 10b41ab18b7990..672879371d1483 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -121,6 +121,7 @@ struct snd_sof_dai_config_data { * triggers. The FW keeps the host DMA running in this case and * therefore the host must do the same and should stop the DMA during * hw_free. + * @d0i3_supported_in_s0ix: Allow DSP D0I3 during S0iX * @compress_ops: Pointer to ops for compressed streams */ struct sof_ipc_pcm_ops { @@ -142,6 +143,7 @@ struct sof_ipc_pcm_ops { bool reset_hw_params_during_stop; bool ipc_first_on_start; bool platform_stop_during_hw_free; + bool d0i3_supported_in_s0ix; const struct snd_compress_ops *compress_ops; }; From 3a8c4dda4199ff0e4ba1ddbfcde20b01e7e43f53 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 27 Nov 2026 11:25:08 +0200 Subject: [PATCH 04/10] Revert "ASoC: SOF: pcm/pm: Fix WoV flow during system suspend / resume" This reverts commit 2b79acd1adf1. 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 --- sound/soc/sof/pcm.c | 7 ------- sound/soc/sof/pm.c | 3 +-- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 2ed475a7db6fbd..b4305dc43d61e4 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -428,13 +428,6 @@ static int sof_pcm_trigger(struct snd_soc_component *component, if (pcm_ops && pcm_ops->ipc_first_on_start) ipc_first = true; break; - case SNDRV_PCM_TRIGGER_RESUME: - if (spcm->stream[substream->stream].suspend_ignored) { - spcm->stream[substream->stream].suspend_ignored = false; - return 0; - } - spcm_err(spcm, substream->stream, "RESUME trigger is not supported\n"); - return -EINVAL; case SNDRV_PCM_TRIGGER_SUSPEND: /* * If DSP D0I3 is allowed during S0iX, set the suspend_ignored flag for diff --git a/sound/soc/sof/pm.c b/sound/soc/sof/pm.c index b5d239b12e59d2..1d71d483588eb1 100644 --- a/sound/soc/sof/pm.c +++ b/sound/soc/sof/pm.c @@ -248,8 +248,7 @@ static int sof_suspend(struct device *dev, bool runtime_suspend) * suspended, it is brought back to full power and then * suspended again */ - if (tplg_ops && tplg_ops->tear_down_all_pipelines && (old_state == SOF_DSP_PM_D0) && - (target_state != SOF_DSP_PM_D0)) + if (tplg_ops && tplg_ops->tear_down_all_pipelines && (old_state == SOF_DSP_PM_D0)) tplg_ops->tear_down_all_pipelines(sdev, false); if (sdev->fw_state != SOF_FW_BOOT_COMPLETE) From 907ebf3bde7cf22c837a25cbb51bb9eaacce4750 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 27 Nov 2026 12:24:19 +0200 Subject: [PATCH 05/10] ASoC: SOF: pm: Move the system suspend target selection to a helper 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 --- sound/soc/sof/pm.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sound/soc/sof/pm.c b/sound/soc/sof/pm.c index 1d71d483588eb1..c45fb133c89279 100644 --- a/sound/soc/sof/pm.c +++ b/sound/soc/sof/pm.c @@ -373,9 +373,8 @@ int snd_sof_suspend(struct device *dev) } EXPORT_SYMBOL(snd_sof_suspend); -int snd_sof_prepare(struct device *dev) +static void sof_set_system_suspend_target(struct snd_sof_dev *sdev) { - struct snd_sof_dev *sdev = dev_get_drvdata(dev); const struct sof_dev_desc *desc = sdev->pdata->desc; /* will suspend to S3 by default */ @@ -387,10 +386,10 @@ int snd_sof_prepare(struct device *dev) */ if (sdev->fw_state == SOF_FW_CRASHED || sdev->fw_state == SOF_FW_BOOT_FAILED) - return 0; + return; if (!desc->use_acpi_target_states) - return 0; + return; #if defined(CONFIG_ACPI) switch (acpi_target_system_state()) { @@ -412,6 +411,13 @@ int snd_sof_prepare(struct device *dev) break; } #endif +} + +int snd_sof_prepare(struct device *dev) +{ + struct snd_sof_dev *sdev = dev_get_drvdata(dev); + + sof_set_system_suspend_target(sdev); return 0; } From 6749838b6cbe5d433b3485eda1bfccfc2b07959c Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 27 Nov 2026 12:24:36 +0200 Subject: [PATCH 06/10] ASoC: SOF: pcm: Clear the suspend_ignored flag when the stream is stopped 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 --- sound/soc/sof/pcm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index b4305dc43d61e4..8951fe0b17c3dd 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -269,7 +269,11 @@ int sof_pcm_free_all_streams(struct snd_sof_dev *sdev) for_each_pcm_streams(dir) { substream = spcm->stream[dir].substream; - if (!substream || !substream->runtime || + if (!substream || !substream->runtime) + continue; + + /* skip the streams kept running during S0ix */ + if (sdev->system_suspend_target == SOF_SUSPEND_S0IX && spcm->stream[dir].suspend_ignored) continue; @@ -408,6 +412,8 @@ static int sof_pcm_trigger(struct snd_soc_component *component, switch (cmd) { case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + /* the stream is paused, it is no longer kept running */ + spcm->stream[substream->stream].suspend_ignored = false; ipc_first = true; break; case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: @@ -446,6 +452,8 @@ static int sof_pcm_trigger(struct snd_soc_component *component, fallthrough; case SNDRV_PCM_TRIGGER_STOP: + /* the stream is stopped, it is no longer kept running */ + spcm->stream[substream->stream].suspend_ignored = false; ipc_first = true; if (pcm_ops && pcm_ops->reset_hw_params_during_stop) reset_hw_params = true; From 17dab7c89bf94e6472a8763cc69967637de0a6ff Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Fri, 27 Nov 2026 12:24:47 +0200 Subject: [PATCH 07/10] ASoC: SOF: pcm/pm: Keep the D0i3 compatible streams running with ignore_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 --- sound/soc/sof/intel/hda-dsp.c | 4 +- sound/soc/sof/pcm.c | 136 ++++++++++++++++++++++++++++------ sound/soc/sof/pm.c | 9 ++- sound/soc/sof/sof-audio.h | 8 +- 4 files changed, 131 insertions(+), 26 deletions(-) diff --git a/sound/soc/sof/intel/hda-dsp.c b/sound/soc/sof/intel/hda-dsp.c index ec49aeaa9bd7af..ed4def3175f9de 100644 --- a/sound/soc/sof/intel/hda-dsp.c +++ b/sound/soc/sof/intel/hda-dsp.c @@ -793,8 +793,8 @@ EXPORT_SYMBOL_NS(hda_dsp_set_power_state_ipc4, "SND_SOC_SOF_INTEL_HDA_COMMON"); * +----------------------------+ +----------------+ * * S0IX suspend: The DSP is in D0I3 if any D0I3-compatible streams - * ignored the suspend trigger. Otherwise the DSP - * is in D3. + * are kept running during the suspend. Otherwise the + * DSP is in D3. */ static int hda_suspend(struct snd_sof_dev *sdev, bool runtime_suspend) diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 8951fe0b17c3dd..af9a513754166d 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -289,6 +289,121 @@ int sof_pcm_free_all_streams(struct snd_sof_dev *sdev) return 0; } +/* Check if the stream can be kept running with the DSP in D0i3 during S0ix */ +static bool sof_pcm_stream_can_ignore_suspend(struct snd_sof_dev *sdev, + struct snd_sof_pcm *spcm, int dir) +{ + const struct sof_ipc_pcm_ops *pcm_ops = sof_ipc_get_ops(sdev, pcm); + + return pcm_ops && pcm_ops->d0i3_supported_in_s0ix && + spcm->stream[dir].d0i3_compatible; +} + +static bool sof_pcm_stream_is_running(struct snd_pcm_substream *substream) +{ + bool running; + + snd_pcm_stream_lock_irq(substream); + running = substream->runtime->state == SNDRV_PCM_STATE_RUNNING; + snd_pcm_stream_unlock_irq(substream); + + return running; +} + +/** + * sof_pcm_suspend_prepare - select the streams to keep running over suspend + * @sdev: SOF device + * + * Called from the PM prepare callback, before the sound card is suspended. + * + * When the system is entering S0ix, the running streams which can work with + * the DSP in D0i3 are kept running. The ignore_suspend flag is set for their + * FE dai_link, which makes ASoC to skip the suspend of the PCM: there is no + * SUSPEND trigger for the FE and the BEs and the stream stays in RUNNING + * state. Userspace does not need to resume or restart the stream and a stop + * or close after the system resume is handled as a normal STOP. + * + * The suspend_ignored flag of these streams tells the PM code that the DSP + * must stay in D0 and that the pipelines of the stream must not be freed. The + * flag is cleared when the stream is stopped or paused or on the next system + * suspend. + */ +void sof_pcm_suspend_prepare(struct snd_sof_dev *sdev) +{ + struct snd_sof_pcm *spcm; + int dir; + + list_for_each_entry(spcm, &sdev->pcm_list, list) { + struct snd_soc_pcm_runtime *rtd = NULL; + bool keep_running = false; + bool must_suspend = false; + + for_each_pcm_streams(dir) { + struct snd_pcm_substream *substream = spcm->stream[dir].substream; + + spcm->stream[dir].suspend_ignored = false; + + if (!substream || !substream->runtime) + continue; + + rtd = snd_soc_substream_to_rtd(substream); + + if (!sof_pcm_stream_is_running(substream)) + continue; + + if (sdev->system_suspend_target == SOF_SUSPEND_S0IX && + !sdev->dspless_mode_selected && + sof_pcm_stream_can_ignore_suspend(sdev, spcm, dir)) { + spcm->stream[dir].suspend_ignored = true; + keep_running = true; + } else { + must_suspend = true; + } + } + + if (!keep_running) + continue; + + /* + * The ignore_suspend flag is per dai_link, it affects both + * directions of the PCM. + */ + if (must_suspend) { + spcm_dbg(spcm, SNDRV_PCM_STREAM_CAPTURE, + "the PCM has a stream which must be suspended\n"); + for_each_pcm_streams(dir) + spcm->stream[dir].suspend_ignored = false; + continue; + } + + if (rtd->dai_link->ignore_suspend) + continue; + + rtd->dai_link->ignore_suspend = 1; + spcm->ignore_suspend_link = rtd->dai_link; + } +} + +/** + * sof_pcm_suspend_complete - restore the FE dai_links after a system suspend + * @sdev: SOF device + * + * Called from the PM complete callback, clears the ignore_suspend flag of the + * dai_links which was set by sof_pcm_suspend_prepare(). + */ +void sof_pcm_suspend_complete(struct snd_sof_dev *sdev) +{ + struct snd_sof_pcm *spcm; + + list_for_each_entry(spcm, &sdev->pcm_list, list) { + if (!spcm->ignore_suspend_link) + continue; + + spcm->ignore_suspend_link->ignore_suspend = 0; + spcm->ignore_suspend_link = NULL; + } +} + static int sof_pcm_hw_free(struct snd_soc_component *component, struct snd_pcm_substream *substream) { @@ -421,31 +536,10 @@ static int sof_pcm_trigger(struct snd_soc_component *component, ipc_first = true; break; case SNDRV_PCM_TRIGGER_START: - if (spcm->stream[substream->stream].suspend_ignored) { - /* - * This case will be triggered when INFO_RESUME is - * not supported, no need to re-start streams that - * remained enabled in D0ix. - */ - spcm->stream[substream->stream].suspend_ignored = false; - return 0; - } - if (pcm_ops && pcm_ops->ipc_first_on_start) ipc_first = true; break; case SNDRV_PCM_TRIGGER_SUSPEND: - /* - * If DSP D0I3 is allowed during S0iX, set the suspend_ignored flag for - * D0I3-compatible streams to keep the firmware pipeline running - */ - if (pcm_ops && pcm_ops->d0i3_supported_in_s0ix && - sdev->system_suspend_target == SOF_SUSPEND_S0IX && - spcm->stream[substream->stream].d0i3_compatible) { - spcm->stream[substream->stream].suspend_ignored = true; - return 0; - } - /* On suspend the DMA must be stopped in DSPless mode */ if (sdev->dspless_mode_selected) reset_hw_params = true; diff --git a/sound/soc/sof/pm.c b/sound/soc/sof/pm.c index c45fb133c89279..43011566a44787 100644 --- a/sound/soc/sof/pm.c +++ b/sound/soc/sof/pm.c @@ -38,7 +38,7 @@ static u32 snd_sof_dsp_power_target(struct snd_sof_dev *sdev) case SOF_SUSPEND_S0IX: /* * Currently, the only criterion for retaining the DSP in D0 - * is that there are streams that ignored the suspend trigger. + * is that there are streams kept running during the suspend. * Additional criteria such Soundwire clock-stop mode and * device suspend latency considerations will be added later. */ @@ -419,6 +419,12 @@ int snd_sof_prepare(struct device *dev) sof_set_system_suspend_target(sdev); + /* + * Select the streams to be kept running during the system suspend. + * This must be done before the sound card is suspended. + */ + sof_pcm_suspend_prepare(sdev); + return 0; } EXPORT_SYMBOL(snd_sof_prepare); @@ -427,6 +433,7 @@ void snd_sof_complete(struct device *dev) { struct snd_sof_dev *sdev = dev_get_drvdata(dev); + sof_pcm_suspend_complete(sdev); sdev->system_suspend_target = SOF_SUSPEND_NONE; } EXPORT_SYMBOL(snd_sof_complete); diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index 672879371d1483..6b71917052fdb3 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -344,8 +344,8 @@ struct snd_sof_pcm_stream { bool pause_supported; /* PCM device supports PAUSE operation */ unsigned int dsp_max_burst_size_in_ms; /* The maximum size of the host DMA burst in ms */ /* - * flag to indicate that the DSP pipelines should be kept - * active or not while suspending the stream + * flag to indicate that the stream is kept running and the DSP + * pipelines should be kept active during system suspend */ bool suspend_ignored; struct snd_sof_pcm_stream_pipeline_list pipeline_list; @@ -366,6 +366,8 @@ struct snd_sof_pcm { bool setup_done[2]; /* the setup of the SOF PCM device is done */ bool pending_stop[2]; /* only used if (!pcm_ops->platform_stop_during_hw_free) */ bool compr_started[2]; /* compress stream has been started */ + /* FE dai_link with ignore_suspend set by sof_pcm_suspend_prepare() */ + struct snd_soc_dai_link *ignore_suspend_link; /* Must be last - ends in a flex-array member. */ struct snd_soc_tplg_pcm pcm; @@ -711,6 +713,8 @@ int sof_widget_list_free(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, int int sof_pcm_dsp_pcm_free(struct snd_pcm_substream *substream, struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm); int sof_pcm_free_all_streams(struct snd_sof_dev *sdev); +void sof_pcm_suspend_prepare(struct snd_sof_dev *sdev); +void sof_pcm_suspend_complete(struct snd_sof_dev *sdev); int get_token_u32(void *elem, void *object, u32 offset); int get_token_u16(void *elem, void *object, u32 offset); int get_token_comp_format(void *elem, void *object, u32 offset); From 5487aa7cc4962f0a0d33523d838a15dc1cf05be2 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Fri, 27 Nov 2026 11:25:59 +0200 Subject: [PATCH 08/10] ASoC: SOF: Add definition of a WoV stream and drop d0i3_supported_in_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 Co-developed-by: Peter Ujfalusi Signed-off-by: Peter Ujfalusi --- sound/soc/sof/ipc3-pcm.c | 1 - sound/soc/sof/pcm.c | 25 +++++++++++++++++-------- sound/soc/sof/sof-audio.h | 2 -- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/sound/soc/sof/ipc3-pcm.c b/sound/soc/sof/ipc3-pcm.c index 42f93e596598fd..b95e888c0adb84 100644 --- a/sound/soc/sof/ipc3-pcm.c +++ b/sound/soc/sof/ipc3-pcm.c @@ -431,7 +431,6 @@ const struct sof_ipc_pcm_ops ipc3_pcm_ops = { .trigger = sof_ipc3_pcm_trigger, .dai_link_fixup = sof_ipc3_pcm_dai_link_fixup, .reset_hw_params_during_stop = true, - .d0i3_supported_in_s0ix = true, #if IS_ENABLED(CONFIG_SND_SOC_SOF_COMPRESS) .compress_ops = &sof_ipc3_compressed_ops, #endif diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index af9a513754166d..bd84aff65a02eb 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -289,14 +289,23 @@ int sof_pcm_free_all_streams(struct snd_sof_dev *sdev) return 0; } -/* Check if the stream can be kept running with the DSP in D0i3 during S0ix */ -static bool sof_pcm_stream_can_ignore_suspend(struct snd_sof_dev *sdev, - struct snd_sof_pcm *spcm, int dir) +/* + * Check if the stream can be kept running with the DSP in D0i3 during S0ix. + * + * Only Wake-on-Voice (WoV) streams can be kept running. A WoV stream is: + * a capture stream, + * the CAPTURE_COMPATIBLE_D0I3 is set for the PCM, + * it is not a Deep Buffer stream. + * + * Historically the CAPTURE_COMPATIBLE_D0I3 token was added to mark the WoV + * stream with IPC3. With IPC4 the COMPATIBLE_D0I3 tokens are also used to mark + * the Deep Buffer streams, which can not be kept running. + */ +static bool sof_pcm_stream_can_ignore_suspend(struct snd_sof_pcm *spcm, int dir) { - const struct sof_ipc_pcm_ops *pcm_ops = sof_ipc_get_ops(sdev, pcm); - - return pcm_ops && pcm_ops->d0i3_supported_in_s0ix && - spcm->stream[dir].d0i3_compatible; + return dir == SNDRV_PCM_STREAM_CAPTURE && + spcm->stream[dir].d0i3_compatible && + spcm->stream[dir].dsp_max_burst_size_in_ms <= 1; } static bool sof_pcm_stream_is_running(struct snd_pcm_substream *substream) @@ -353,7 +362,7 @@ void sof_pcm_suspend_prepare(struct snd_sof_dev *sdev) if (sdev->system_suspend_target == SOF_SUSPEND_S0IX && !sdev->dspless_mode_selected && - sof_pcm_stream_can_ignore_suspend(sdev, spcm, dir)) { + sof_pcm_stream_can_ignore_suspend(spcm, dir)) { spcm->stream[dir].suspend_ignored = true; keep_running = true; } else { diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index 6b71917052fdb3..ca52c3fa8a8f6f 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -121,7 +121,6 @@ struct snd_sof_dai_config_data { * triggers. The FW keeps the host DMA running in this case and * therefore the host must do the same and should stop the DMA during * hw_free. - * @d0i3_supported_in_s0ix: Allow DSP D0I3 during S0iX * @compress_ops: Pointer to ops for compressed streams */ struct sof_ipc_pcm_ops { @@ -143,7 +142,6 @@ struct sof_ipc_pcm_ops { bool reset_hw_params_during_stop; bool ipc_first_on_start; bool platform_stop_during_hw_free; - bool d0i3_supported_in_s0ix; const struct snd_compress_ops *compress_ops; }; From 832cf1653b053200df7776a9aaaaebcc547b78d1 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 30 Nov 2026 12:22:06 +0200 Subject: [PATCH 09/10] soundwire: intel: Keep the bus running for enabled streams in system 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 Co-developed-by: Peter Ujfalusi Signed-off-by: Peter Ujfalusi --- drivers/soundwire/intel.c | 10 ++++++++-- drivers/soundwire/intel.h | 1 + drivers/soundwire/intel_ace2x.c | 10 ++++++++-- drivers/soundwire/intel_auxdevice.c | 21 +++++++++++++++++++++ drivers/soundwire/stream.c | 21 +++++++++++++++++++++ include/linux/soundwire/sdw.h | 1 + 6 files changed, 60 insertions(+), 4 deletions(-) diff --git a/drivers/soundwire/intel.c b/drivers/soundwire/intel.c index af65214836b4d0..88ceb0281ccead 100644 --- a/drivers/soundwire/intel.c +++ b/drivers/soundwire/intel.c @@ -954,9 +954,15 @@ static int intel_component_dais_suspend(struct snd_soc_component *component) struct sdw_cdns_dai_runtime *dai_runtime; dai_runtime = cdns->dai_runtime_array[dai->id]; + if (!dai_runtime) + continue; - if (dai_runtime) - dai_runtime->suspended = true; + /* the stream is kept running during the system suspend */ + if (dai_runtime->stream && + dai_runtime->stream->state == SDW_STREAM_ENABLED) + continue; + + dai_runtime->suspended = true; } return 0; diff --git a/drivers/soundwire/intel.h b/drivers/soundwire/intel.h index 7a2e7e73ad632a..87f1203e74a3b7 100644 --- a/drivers/soundwire/intel.h +++ b/drivers/soundwire/intel.h @@ -78,6 +78,7 @@ struct sdw_intel { struct sdw_intel_link_res *link_res; bool startup_done; struct sdw_intel_bpt bpt_ctx; + bool suspend_bus_retained; #ifdef CONFIG_DEBUG_FS struct dentry *debugfs; #endif diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c index 642b33ab552606..bbbc5d7fc64ebf 100644 --- a/drivers/soundwire/intel_ace2x.c +++ b/drivers/soundwire/intel_ace2x.c @@ -953,9 +953,15 @@ static int intel_component_dais_suspend(struct snd_soc_component *component) struct sdw_cdns_dai_runtime *dai_runtime; dai_runtime = cdns->dai_runtime_array[dai->id]; + if (!dai_runtime) + continue; - if (dai_runtime) - dai_runtime->suspended = true; + /* the stream is kept running during the system suspend */ + if (dai_runtime->stream && + dai_runtime->stream->state == SDW_STREAM_ENABLED) + continue; + + dai_runtime->suspended = true; } return 0; diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c index 5983fbc5725a26..8d7e8b116a4373 100644 --- a/drivers/soundwire/intel_auxdevice.c +++ b/drivers/soundwire/intel_auxdevice.c @@ -650,6 +650,20 @@ static int __maybe_unused intel_suspend(struct device *dev) return 0; } + /* + * The sound card is suspended before the SoundWire links and the + * streams which are not kept running are disabled by then: a stream + * is only enabled while it is running and the card's suspend disables + * all the running streams except the ones kept running during the + * system suspend. Do not stop the bus under an enabled stream. + */ + sdw->suspend_bus_retained = sdw_bus_has_enabled_stream(bus); + if (sdw->suspend_bus_retained) { + dev_dbg(dev, "SoundWire master %d is kept active during system suspend\n", + bus->link_id); + return 0; + } + /* Prevent runtime PM from racing with the code below. */ pm_runtime_disable(dev); @@ -737,6 +751,13 @@ static int __maybe_unused intel_resume(struct device *dev) return 0; } + if (sdw->suspend_bus_retained) { + sdw->suspend_bus_retained = false; + dev_dbg(dev, "SoundWire master %d remained active during system suspend\n", + bus->link_id); + return 0; + } + ret = sdw_intel_link_power_up(sdw); if (ret) { dev_err(dev, "%s failed: %d\n", __func__, ret); diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c index 06a0d89a944378..f7bc6f277dedaf 100644 --- a/drivers/soundwire/stream.c +++ b/drivers/soundwire/stream.c @@ -1690,6 +1690,27 @@ int sdw_enable_stream(struct sdw_stream_runtime *stream) } EXPORT_SYMBOL(sdw_enable_stream); +/** + * sdw_bus_has_enabled_stream() - Check if the bus carries an enabled stream + * + * @bus: SDW bus instance + * + * Return: true if at least one stream on the bus is in ENABLED state + */ +bool sdw_bus_has_enabled_stream(struct sdw_bus *bus) +{ + struct sdw_master_runtime *m_rt; + + guard(mutex)(&bus->bus_lock); + list_for_each_entry(m_rt, &bus->m_rt_list, bus_node) { + if (m_rt->stream->state == SDW_STREAM_ENABLED) + return true; + } + + return false; +} +EXPORT_SYMBOL(sdw_bus_has_enabled_stream); + static int _sdw_disable_stream(struct sdw_stream_runtime *stream) { struct sdw_master_runtime *m_rt; diff --git a/include/linux/soundwire/sdw.h b/include/linux/soundwire/sdw.h index 9e71ae68e9d927..6a049d674b3a61 100644 --- a/include/linux/soundwire/sdw.h +++ b/include/linux/soundwire/sdw.h @@ -1084,6 +1084,7 @@ int sdw_stream_remove_master(struct sdw_bus *bus, int sdw_startup_stream(void *sdw_substream); int sdw_prepare_stream(struct sdw_stream_runtime *stream); int sdw_enable_stream(struct sdw_stream_runtime *stream); +bool sdw_bus_has_enabled_stream(struct sdw_bus *bus); int sdw_disable_stream(struct sdw_stream_runtime *stream); int sdw_deprepare_stream(struct sdw_stream_runtime *stream); void sdw_shutdown_stream(void *sdw_substream); From 57f4813b9dd2c71e3b94d58b4f39b7d6f4208021 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Fri, 27 Nov 2026 13:28:50 +0200 Subject: [PATCH 10/10] ASoC: SOF: pcm: Keep the DAPM path powered for streams kept running 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 Co-developed-by: Peter Ujfalusi Signed-off-by: Peter Ujfalusi --- sound/soc/sof/core.c | 1 + sound/soc/sof/pcm.c | 151 ++++++++++++++++++++++++++++++++++++++- sound/soc/sof/sof-priv.h | 2 + 3 files changed, 153 insertions(+), 1 deletion(-) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 1f38fe03e49395..37fca4c37d59bc 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -690,6 +690,7 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data) INIT_LIST_HEAD(&sdev->dai_list); INIT_LIST_HEAD(&sdev->dai_link_list); INIT_LIST_HEAD(&sdev->route_list); + INIT_LIST_HEAD(&sdev->ignore_suspend_widget_list); INIT_LIST_HEAD(&sdev->ipc_client_list); INIT_LIST_HEAD(&sdev->ipc_rx_handler_list); INIT_LIST_HEAD(&sdev->fw_state_handler_list); diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index bd84aff65a02eb..db2b8744d20377 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -319,6 +319,116 @@ static bool sof_pcm_stream_is_running(struct snd_pcm_substream *substream) return running; } +/* DAPM widget with ignore_suspend set by sof_pcm_suspend_prepare() */ +struct sof_pcm_ignore_suspend_widget { + struct snd_soc_dapm_widget *widget; + bool initial_ignore_suspend; + struct list_head list; +}; + +/* must be called with the DAPM mutex of the card held */ +static int sof_pcm_widget_set_ignore_suspend(struct snd_sof_dev *sdev, + struct snd_soc_dapm_widget *w) +{ + struct sof_pcm_ignore_suspend_widget *isw; + + list_for_each_entry(isw, &sdev->ignore_suspend_widget_list, list) { + if (isw->widget == w) + return 0; + } + + isw = kzalloc(sizeof(*isw), GFP_KERNEL); + if (!isw) + return -ENOMEM; + + isw->widget = w; + isw->initial_ignore_suspend = w->ignore_suspend; + list_add_tail(&isw->list, &sdev->ignore_suspend_widget_list); + + w->ignore_suspend = 1; + dev_dbg(sdev->dev, "ignore suspend for widget %s\n", w->name); + + return 0; +} + +/** + * sof_pcm_dapm_restore_ignore_suspend - restore the DAPM widgets + * @sdev: SOF device + * @restore: restore the ignore_suspend flag of the widgets + * + * Restore the initial ignore_suspend flag of the widgets which was set by + * sof_pcm_dapm_set_ignore_suspend(). If @restore is false, only the tracking + * list is freed, the widgets are not touched. + */ +static void sof_pcm_dapm_restore_ignore_suspend(struct snd_sof_dev *sdev, + bool restore) +{ + struct sof_pcm_ignore_suspend_widget *isw, *tmp; + + if (list_empty(&sdev->ignore_suspend_widget_list)) + return; + + if (restore) + snd_soc_dapm_mutex_lock(sdev->component->card); + + list_for_each_entry_safe(isw, tmp, &sdev->ignore_suspend_widget_list, list) { + if (restore) + isw->widget->ignore_suspend = isw->initial_ignore_suspend; + + list_del(&isw->list); + kfree(isw); + } + + if (restore) + snd_soc_dapm_mutex_unlock(sdev->component->card); +} + +/* + * The sound card is moved to D3hot during system suspend and DAPM powers down + * all paths unless their endpoints are marked with ignore_suspend. + * Set the ignore_suspend flag for the FE DAI widget and for all the endpoints + * connected to it to keep the path of the stream powered. + */ +static int sof_pcm_dapm_set_ignore_suspend(struct snd_sof_dev *sdev, + struct snd_soc_pcm_runtime *rtd, int dir) +{ + struct snd_soc_dai *dai; + int i; + + for_each_rtd_cpu_dais(rtd, i, dai) { + struct snd_soc_dapm_widget_list *list = NULL; + struct snd_soc_dapm_widget *w; + int j, ret; + + ret = snd_soc_dapm_dai_get_connected_widgets(dai, dir, &list, NULL); + if (ret < 0) { + snd_soc_dapm_dai_free_widgets(&list); + return ret; + } + + snd_soc_dapm_mutex_lock(rtd->card); + + w = snd_soc_dai_get_widget(dai, dir); + ret = w ? sof_pcm_widget_set_ignore_suspend(sdev, w) : 0; + + for_each_dapm_widgets(list, j, w) { + if (ret) + break; + + if (w->is_ep) + ret = sof_pcm_widget_set_ignore_suspend(sdev, w); + } + + snd_soc_dapm_mutex_unlock(rtd->card); + snd_soc_dapm_dai_free_widgets(&list); + + if (ret) + return ret; + } + + return 0; +} + /** * sof_pcm_suspend_prepare - select the streams to keep running over suspend * @sdev: SOF device @@ -336,11 +446,21 @@ static bool sof_pcm_stream_is_running(struct snd_pcm_substream *substream) * must stay in D0 and that the pipelines of the stream must not be freed. The * flag is cleared when the stream is stopped or paused or on the next system * suspend. + * + * The DAPM endpoints of the streams are marked with ignore_suspend to keep + * their paths powered. The widgets are restored on the next system suspend, + * the flag has no effect while the card is powered. + * + * If the DAPM path of a stream can not be kept powered, none of the streams are + * kept running and all of them are suspended normally. */ void sof_pcm_suspend_prepare(struct snd_sof_dev *sdev) { struct snd_sof_pcm *spcm; - int dir; + int dir, ret; + + /* restore the DAPM widgets from the previous system suspend */ + sof_pcm_dapm_restore_ignore_suspend(sdev, true); list_for_each_entry(spcm, &sdev->pcm_list, list) { struct snd_soc_pcm_runtime *rtd = NULL; @@ -385,12 +505,36 @@ void sof_pcm_suspend_prepare(struct snd_sof_dev *sdev) continue; } + for_each_pcm_streams(dir) { + if (!spcm->stream[dir].suspend_ignored) + continue; + + ret = sof_pcm_dapm_set_ignore_suspend(sdev, rtd, dir); + if (ret) { + spcm_err(spcm, dir, + "failed to keep the DAPM path powered: %d\n", + ret); + goto err; + } + } + if (rtd->dai_link->ignore_suspend) continue; rtd->dai_link->ignore_suspend = 1; spcm->ignore_suspend_link = rtd->dai_link; } + + return; + +err: + list_for_each_entry(spcm, &sdev->pcm_list, list) { + for_each_pcm_streams(dir) + spcm->stream[dir].suspend_ignored = false; + } + + sof_pcm_suspend_complete(sdev); + sof_pcm_dapm_restore_ignore_suspend(sdev, true); } /** @@ -908,6 +1052,11 @@ static int sof_pcm_probe(struct snd_soc_component *component) static void sof_pcm_remove(struct snd_soc_component *component) { + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); + + /* the widgets might be already freed, do not restore them */ + sof_pcm_dapm_restore_ignore_suspend(sdev, false); + /* remove topology */ snd_soc_tplg_component_remove(component); } diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 83e4d83cc27cbb..1987ea3e02c51a 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -653,6 +653,8 @@ struct snd_sof_dev { struct list_head dai_list; struct list_head dai_link_list; struct list_head route_list; + /* DAPM widgets with ignore_suspend set by sof_pcm_suspend_prepare() */ + struct list_head ignore_suspend_widget_list; struct snd_soc_component *component; u32 enabled_cores_mask; /* keep track of enabled cores */ bool led_present;