public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: pcm_dmaengine: Don't synchronize DMA channel when DMA is paused
@ 2024-07-17  6:44 Shengjiu Wang
  2024-07-17  8:40 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Shengjiu Wang @ 2024-07-17  6:44 UTC (permalink / raw)
  To: lars, perex, tiwai, broonie, linux-sound, linux-kernel,
	alsa-devel, shengjiu.wang

When suspended, the DMA channel may enter PAUSE state if dmaengine_pause()
is supported by DMA.
At this state, dmaengine_synchronize() should not be called, otherwise
the DMA channel can't be resumed successfully.

Fixes: e8343410ddf0 ("ALSA: dmaengine: Synchronize dma channel after drop()")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
 sound/core/pcm_dmaengine.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c
index b54336d4bffc..b134a51b3fd5 100644
--- a/sound/core/pcm_dmaengine.c
+++ b/sound/core/pcm_dmaengine.c
@@ -352,8 +352,12 @@ EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_open_request_chan);
 int snd_dmaengine_pcm_sync_stop(struct snd_pcm_substream *substream)
 {
 	struct dmaengine_pcm_runtime_data *prtd = substream_to_prtd(substream);
+	struct dma_tx_state state;
+	enum dma_status status;
 
-	dmaengine_synchronize(prtd->dma_chan);
+	status = dmaengine_tx_status(prtd->dma_chan, prtd->cookie, &state);
+	if (status != DMA_PAUSED)
+		dmaengine_synchronize(prtd->dma_chan);
 
 	return 0;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: pcm_dmaengine: Don't synchronize DMA channel when DMA is paused
  2024-07-17  6:44 [PATCH] ALSA: pcm_dmaengine: Don't synchronize DMA channel when DMA is paused Shengjiu Wang
@ 2024-07-17  8:40 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2024-07-17  8:40 UTC (permalink / raw)
  To: Shengjiu Wang
  Cc: lars, perex, tiwai, broonie, linux-sound, linux-kernel,
	alsa-devel, shengjiu.wang

On Wed, 17 Jul 2024 08:44:53 +0200,
Shengjiu Wang wrote:
> 
> When suspended, the DMA channel may enter PAUSE state if dmaengine_pause()
> is supported by DMA.
> At this state, dmaengine_synchronize() should not be called, otherwise
> the DMA channel can't be resumed successfully.
> 
> Fixes: e8343410ddf0 ("ALSA: dmaengine: Synchronize dma channel after drop()")
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>

Thanks, applied now.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-17  8:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-17  6:44 [PATCH] ALSA: pcm_dmaengine: Don't synchronize DMA channel when DMA is paused Shengjiu Wang
2024-07-17  8:40 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox