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: Fri, 4 Apr 2025 11:58:18 +0300 [thread overview]
Message-ID: <517d9020-379f-42e5-89c6-9d81e4666af6@linux.intel.com> (raw)
In-Reply-To: <2bc811f1-7fbd-45f1-924e-e6241dcef537@perex.cz>
On 03/04/2025 18:24, Jaroslav Kysela wrote:
> On 03. 04. 25 16:01, Takashi Iwai wrote:
>
>> I agree that your patch can be a good start, at least, it addresses
>> the existing issue with the minimal change. There are still rough
>> edges and we'll need to address, but I believe the patch (or modified
>> / fixed one) can be applied to 6.15 kernel, while keeping the
>> development for 6.16.
>
> I did a quick research how is RESUME/SUSPEND implemented in current
> drivers and I found that it may be considered to enable SUSPEND trigger
> also in the paused state:
>
> find sound/ -name "*.[ch]" -exec grep -A 2 -B 2 -H -E \
> "SNDRV_PCM_TRIGGER_(RESUME|SUSPEND)" {} \;
>
> My comments - seems almost all drivers handles SUSPEND as STOP:
>
> sound/pci/ymfpci/ymfpci_main.c
> - STOP/SUSPEND different, should not be a problem
> sound/pci/nm256/nm256.c
> sound/pci/intel8x0.c
> - only saves suspend flag additionaly to STOP
> sound/soc
> - some drivers ignores suspend/resume (ignore_suspend flag)
> sound/soc/pxa/pxa-ssp.c
> - should not be a problem (enable/disable hw parts)
> sound/soc/sti/uniperif_player.c
> - only resume trigger is supported ? but no resume info is set
> sound/soc/sof/intel/hda-dai.c
> - only suspend support, but resume is not supported
> sound/xen/xen_snd_front_alsa.c
> - it's just rpc
> sound/virtio/virtio_pcm_ops.c
> - only suspend support, no resume
>
> It would be probably nice if more eyes verifies this, but the only
> suspicious place is the xen front end. And some drivers may be broken
> already (no changes for them).
>
> I believe that this patch should be enough to resolve the issue instead
> the non-elegant pause release and may be applied also to 6.15:
>
> diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
> index 4057f9f10aee..63a1b37cc098 100644
> --- a/sound/core/pcm_native.c
> +++ b/sound/core/pcm_native.c
> @@ -1694,8 +1694,17 @@ static int snd_pcm_do_suspend(struct
> snd_pcm_substream *substream,
> struct snd_pcm_runtime *runtime = substream->runtime;
> if (runtime->trigger_master != substream)
> return 0;
> - if (! snd_pcm_running(substream))
> - return 0;
> + if (! snd_pcm_running(substream)) {
> + if (runtime->info & SNDRV_PCM_INFO_RESUME)
> + return 0;
> + if (runtime->state != SNDRV_PCM_STATE_PAUSED)
> + return 0;
> + /*
> + * When resume is not supported, SUSPEND should STOP
> stream.
> + * For futher operation, the stream must be fully restarted
> + * to leave the permanent SUSPEND state.
> + */
> + }
> substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND);
> runtime->stop_operating = true;
> return 0; /* suspend unconditionally */
I have tried similar thing and the original problem remains that we are
missing the PAUSE_RELEASE trigger for the PUSH and ASoC core stops the
SUSPEND trigger to reach the drivers.
>
> Jaroslav
>
>> I did some quick work on it, and now implemented
>> SNDRV_PCM_PAUSE_RELEASE_STOP trigger. I guess it's more or less
>> aligned with what Jaroslav suggested.
>
> Nice cleanups. The "ALSA: pcm: Save the proper suspended_state for non-
> resumable case, too" should be recoded. The state should be handled in
> action callbacks for all streams separetely.
>
> Also, I would consider to call suspend/resume triggers (depending on a
> flag like can_pause_release_stop) when the stream is paused, too. Some
> drivers may want this scheme.
>
> Jaroslav
>
--
Péter
next prev parent reply other threads:[~2025-04-04 8:57 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 [this message]
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=517d9020-379f-42e5-89c6-9d81e4666af6@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