From: Takashi Iwai <tiwai@suse.de>
To: Shengjiu Wang <shengjiu.wang@nxp.com>
Cc: lars@metafoo.de, perex@perex.cz, tiwai@suse.com,
broonie@kernel.org, linux-sound@vger.kernel.org,
linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org,
shengjiu.wang@gmail.com
Subject: Re: [RESEND PATCH] ALSA: dmaengine_pcm: terminate dmaengine before synchronize
Date: Thu, 20 Jun 2024 09:57:00 +0200 [thread overview]
Message-ID: <87frt82gj7.wl-tiwai@suse.de> (raw)
In-Reply-To: <1718851218-27803-1-git-send-email-shengjiu.wang@nxp.com>
On Thu, 20 Jun 2024 04:40:18 +0200,
Shengjiu Wang wrote:
>
> When dmaengine supports pause function, in suspend state,
> dmaengine_pause() is called instead of dmaengine_terminate_async(),
>
> In end of playback stream, the runtime->state will go to
> SNDRV_PCM_STATE_DRAINING, if system suspend & resume happen
> at this time, application will not resume playback stream, the
> stream will be closed directly, the dmaengine_terminate_async()
> will not be called before the dmaengine_synchronize(), which
> violates the call sequence for dmaengine_synchronize().
Hmm, I can't follow this state change.
Do you mean that:
- snd_pcm_drain() is performed for a playback stream
- while draining operation, the system goes to suspend
- the system resumes (but the application doesn't call resume yet)
- The stream is closed (without calling resume)
??
If so, it's rather an inconsistent PCM state in the core side, and can
be fixed by a simple call like below:
-- 8< --
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -2700,6 +2700,7 @@ void snd_pcm_release_substream(struct snd_pcm_substream *substream)
if (substream->ref_count > 0)
return;
+ snd_pcm_resume(substream);
snd_pcm_drop(substream);
if (substream->hw_opened) {
if (substream->runtime->state != SNDRV_PCM_STATE_OPEN)
-- 8< --
This will be no-op for the PCM device without SNDRV_PCM_INFO_RESUME.
But, this may need more rework, too; admittedly it imposes the
unnecessary resume of the stream although it shall be stopped and
closed immediately after that. We may have some optimization in
addition.
thanks,
Takashi
next prev parent reply other threads:[~2024-06-20 7:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-20 2:40 [RESEND PATCH] ALSA: dmaengine_pcm: terminate dmaengine before synchronize Shengjiu Wang
2024-06-20 7:57 ` Takashi Iwai [this message]
2024-06-21 2:21 ` Shengjiu Wang
2024-06-24 12:39 ` Takashi Iwai
2024-06-25 11:26 ` 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=87frt82gj7.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=shengjiu.wang@gmail.com \
--cc=shengjiu.wang@nxp.com \
--cc=tiwai@suse.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