From: "Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>
To: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>
Cc: 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: Tue, 8 Apr 2025 12:45:00 +0300 [thread overview]
Message-ID: <2f456ffa-72f0-4efd-be26-f96249d2d1ee@linux.intel.com> (raw)
In-Reply-To: <0cada872-b247-49f4-9684-b168a7425956@perex.cz>
On 08/04/2025 11:51, Jaroslav Kysela wrote:
>>> bool no_device_suspend; /* don't invoke device PM suspend */
>>> + bool do_suspend_and_resume_in_pause; /* allow direct PAUSED ->
>>> SUSPENDED and
>>> + SUSPENDED -> PAUSED
>>> transitions */
>>
>> I think the issue is bit different than this.
>> What needs to be flagged is that the driver is not treating the PAUSE
>> trigger in the same way as it treats the STOP or SUSPEND, in other
>> worlds, the PAUSED state is not equal to STOPPED/SUSPENDED.
>>
>> If the PAUSED state is equal to SUSPENDED state, then the trigger could
>> be skipped (as it is ignored before my patch unconditionally), but if
>> the two states are not equal then the SUSPEND must be sent, but the
>> patches from me and Takashi-san stil can be used as fallback in case the
>> RESUME is not supported as in that case the driver will certainly not
>> going to be able to resume to PAUSE_RESUME, so stopping a stream in that
>> case is appropriate.
>
> The question is if the fallback is required when we had this issue for
> years.
This discussion is a proof that we might want.
We ended up disabling testing the suspend while paused case entirely for
quite some time and I could only get it working with my RFC attempt
before Takashi-san suggestion to do this in core level.
I agree that this is a rare corner case, more academic than not, users
will likely not going to face with as none of the audio servers use
pause so the chances that the system goes suspend while audio is paused
is close to zero.
> Using only a new trigger - to not release pause but directly do
> stop from the pause state - is acceptable for me. It should be easy to
> fix affected drivers. But on other side, the allowing state transitions
> (and even multiple triggers for finer driver notifications) may have
> also benefits for drivers.
>
>> Side note: I think we might also have broken case when we stop a PAUSED
>> stream if the driver's PAUSED state is not equal to STOPPED/SUSPENDED.
>> It is just that applications never do this, at least I ave never seen a
>> missing STOP trigger. aplay is doing a pause release before stop at
>> least.
>
> Aplay implementation is just about simplicity. The pause is handled in
> one routine which releases pause at the end. When the file descriptor is
> closed,
> snd_pcm_drop() is called and the pause is released there, too.
> Logically, it's not 100% correct thing. We know that we want to stop
> stream before the pause release is called.
The assumption is that PAUSED == STOPPED == SUSPENDED is not correct
either. This is not true for some drivers or devices.
I would go as far as to say that most drivers are mishandling the PAUSE
as stop, they likely cannot resume from the exact place where the pause
taken - they stop and if they have FIFO, they drop that as well...
>
> Jaroslav
>
--
Péter
next prev parent reply other threads:[~2025-04-08 9:44 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 [this message]
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=2f456ffa-72f0-4efd-be26-f96249d2d1ee@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=tiwai@suse.de \
--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