From: Takashi Iwai <tiwai@suse.de>
To: "Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>,
lgirdwood@gmail.com, broonie@kernel.org, tiwai@suse.com,
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: Re: [PATCH] ALSA: pcm: Release paused streams before suspend if resume is not supported
Date: Wed, 02 Apr 2025 13:27:09 +0200 [thread overview]
Message-ID: <87mscyyfaq.wl-tiwai@suse.de> (raw)
In-Reply-To: <1417b256-b9e8-4256-b14f-fdee86e202c1@linux.intel.com>
On Wed, 02 Apr 2025 11:28:55 +0200,
Péter Ujfalusi wrote:
>
>
> On 02/04/2025 11:52, Jaroslav Kysela wrote:
> >>>> Actually, this patch follows the same pattern, too. It calls
> >>>> snd_pcm_pause(false) to set the state to RUNNING again, then proceed
> >>>> to the suspend action immediately that sets to SUSPENDED.
> >>>
> >>> The previous state (suspended_state) will be confusing from the
> >>> application with the proposed patch, because there will be RUNNING
> >>> state instead PAUSED. This previous state is exported via API.
> >>
> >> No, it won't happen. The condition of the new behavior is only when
> >> SNDRV_PCM_INFO_RESUME isn't set -- that is, no resume is possible,
> >> hence no state recovery happens after resume. From the application
> >> POV, it won't change.
> >
> > The suspended_state can be obtained in snd_pcm_status64(). With Peter's
> > patch, there will be RUNNING instead PAUSED, don't?
>
> Yes, that is true, but it does not matter.
> if the SNDRV_PCM_INFO_RESUME is not set, on resume nothing is going to
> be done, the state remains SUSPENDED and the suspended_substate also
> retained, so:
>
> The stream was in RUNNING, after suspend:
> state = SUSPENDED, suspended_state = RUNNING
> After resume:
> state = SUSPENDED, suspended_state = RUNNING
> The the stream goes to xrun and got restarted.
>
> The stream was in RUNNING, after suspend:
> Without my patch / with my patch:
> state = SUSPENDED, suspended_state = PAUSED / RUNNING
> After resume:
> state = SUSPENDED, suspended_state = RUNNING / RUNNING
>
> The stream remains "not running" as resume is not supported and
> application knows that it had left the stream paused.
>
> When it tries to PAUSE_RELEASE the stream, in both case the core will
> look at the state, which is SUSPENDED and thus the pause release fails
> (it is not in paused state), so in both cases we go under a restart
> (suspended_state is reset, ignored).
Well, the suspended_state itself is set no matter whether the resume
is supported or not. The difference is that it's evaluated in the
driver only by the suspended state, but it's free for user-space to
read this out from the output of snd_pcm_status ioctl.
How seriously it needs to be a different question, but there is a
possibility of breakage.
Though, looking through the code, the suspended_state isn't updated at
all except for the suspend, and it means this can keep a bogus state,
too. We should fix the code to clear the suspended_state at init
phase. It's another corner case.
thanks,
Takashi
next prev parent reply other threads:[~2025-04-02 11:27 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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=87mscyyfaq.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--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=peter.ujfalusi@linux.intel.com \
--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