From: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
To: lgirdwood@gmail.com, broonie@kernel.org, tiwai@suse.com, perex@perex.cz
Cc: linux-sound@vger.kernel.org, kai.vehmanen@linux.intel.com,
ranjani.sridharan@linux.intel.com,
yung-chuan.liao@linux.intel.com, pierre-louis.bossart@linux.dev,
liam.r.girdwood@intel.com
Subject: [PATCH] ALSA: pcm: Release paused streams before suspend if resume is not supported
Date: Tue, 1 Apr 2025 16:36:52 +0300 [thread overview]
Message-ID: <20250401133652.11617-1-peter.ujfalusi@linux.intel.com> (raw)
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
next reply other threads:[~2025-04-01 13:36 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 13:36 Peter Ujfalusi [this message]
2025-04-01 14:49 ` [PATCH] ALSA: pcm: Release paused streams before suspend if resume is not supported 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250401133652.11617-1-peter.ujfalusi@linux.intel.com \
--to=peter.ujfalusi@linux.intel.com \
--cc=broonie@kernel.org \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=liam.r.girdwood@intel.com \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=pierre-louis.bossart@linux.dev \
--cc=ranjani.sridharan@linux.intel.com \
--cc=tiwai@suse.com \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox