Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ALSA: pcm: Release paused streams before suspend if resume is not supported
@ 2025-04-01 13:36 Peter Ujfalusi
  2025-04-01 14:49 ` Takashi Iwai
  0 siblings, 1 reply; 36+ messages in thread
From: Peter Ujfalusi @ 2025-04-01 13:36 UTC (permalink / raw)
  To: lgirdwood, broonie, tiwai, perex
  Cc: linux-sound, kai.vehmanen, ranjani.sridharan, yung-chuan.liao,
	pierre-louis.bossart, liam.r.girdwood

Streams moved to SUSPENDED state from PAUSED without trigger. If a stream
does not support RESUME then on system resume the RESUME trigger is not
sent, the stream's state and suspended_state remains untouched.
When the user space releases the pause then the core will reject this
because the state of the stream is _not_ PAUSED, it is still SUSPENDED.

From this point user space will do the normal (hw_params) prepare and
START, PAUSE_RELEASE trigger will not be sent by the core after the
system has resumed.

To fix this issue, release the paused stream before handling the suspend
if the resume is not supported.
This will ensure that the stream is properly suspended for suspend entry.
On resume no attempt will be taken to resume the suspended stream as the
resume is not supported, userspace will eventually going restart the audio.

Link: https://github.com/thesofproject/linux/issues/5035
Link: https://github.com/thesofproject/linux/issues/5341
Suggested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
---
 sound/core/pcm_native.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 6c2b6a62d9d2..a16d15ee98fa 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -1730,7 +1730,20 @@ static const struct action_ops snd_pcm_action_suspend = {
  */
 static int snd_pcm_suspend(struct snd_pcm_substream *substream)
 {
+	struct snd_pcm_runtime *runtime = substream->runtime;
+
 	guard(pcm_stream_lock_irqsave)(substream);
+	/*
+	 * Release the paused stream before suspending if resume is not
+	 * supported, because:
+	 * PAUSED streams will not receive the suspend trigger and since the
+	 * driver does not support resuming streams, it is not going to be able
+	 * to handle them properly when the system resumes.
+	 */
+	if (runtime->state == SNDRV_PCM_STATE_PAUSED &&
+	    !(runtime->info & SNDRV_PCM_INFO_RESUME))
+		snd_pcm_pause(substream, false);
+
 	return snd_pcm_action(&snd_pcm_action_suspend, substream,
 			      ACTION_ARG_IGNORE);
 }
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2025-04-08  9:44 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-01 13:36 [PATCH] ALSA: pcm: Release paused streams before suspend if resume is not supported Peter Ujfalusi
2025-04-01 14:49 ` Takashi Iwai
2025-04-01 16:58   ` Jaroslav Kysela
2025-04-01 17:19     ` Takashi Iwai
2025-04-01 18:46       ` Jaroslav Kysela
2025-04-01 19:27         ` Takashi Iwai
2025-04-02  6:41           ` Péter Ujfalusi
2025-04-02  8:14             ` Jaroslav Kysela
2025-04-02  8:09           ` Jaroslav Kysela
2025-04-02  8:39             ` Takashi Iwai
2025-04-02  8:52               ` Jaroslav Kysela
2025-04-02  9:16                 ` Takashi Iwai
2025-04-02 10:45                   ` Jaroslav Kysela
2025-04-02 11:21                     ` Takashi Iwai
2025-04-02 11:43                       ` Péter Ujfalusi
2025-04-02 11:50                         ` Takashi Iwai
2025-04-02 12:52                           ` Péter Ujfalusi
2025-04-02 13:23                             ` Takashi Iwai
2025-04-03 10:13                               ` Péter Ujfalusi
2025-04-03 14:01                                 ` Takashi Iwai
2025-04-03 15:24                                   ` Jaroslav Kysela
2025-04-03 16:09                                     ` Takashi Iwai
2025-04-03 19:05                                       ` Jaroslav Kysela
2025-04-04 10:44                                         ` Takashi Iwai
2025-04-04 11:33                                           ` Jaroslav Kysela
2025-04-04 14:44                                             ` Takashi Iwai
2025-04-08  7:03                                         ` Péter Ujfalusi
2025-04-08  8:51                                           ` Jaroslav Kysela
2025-04-08  9:45                                             ` Péter Ujfalusi
2025-04-04  8:58                                     ` Péter Ujfalusi
2025-04-04  9:08                                       ` Jaroslav Kysela
2025-04-08  6:35                                   ` Péter Ujfalusi
2025-04-02 12:55                           ` Jaroslav Kysela
2025-04-02  9:28                 ` Péter Ujfalusi
2025-04-02 11:27                   ` Takashi Iwai
2025-04-02 11:53                     ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox