mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ALSA: dmaengine: Check DMA submission errors
@ 2026-11-19  7:10 Sreeraj S Kurup
  2026-11-19  7:36 ` [PATCH v2] " Sreeraj S Kurup
  0 siblings, 1 reply; 2+ messages in thread
From: Sreeraj S Kurup @ 2026-11-19  7:10 UTC (permalink / raw)
  To: lars, perex, tiwai; +Cc: linux-kernel, linux-sound, Sreeraj S Kurup

The dmaengine_pcm_prepare_and_submit() function does not check
the return value of dmaengine_submit().

dmaengine_submit() can return a negative DMA cookie if the
submission fails. However, the function currently returns
success unconditionally.

This makes the PCM trigger path believe that DMA has been
successfully submitted, even when the submission has failed.

Use dma_submit_error() to check the returned DMA cookie and
propagate the error to the caller.

This ensures that DMA submission failures are properly
reported instead of allowing the PCM stream to continue
as if the DMA transfer had started successfully.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
 sound/core/pcm_dmaengine.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c
index 1306b04be171..5b9fdad4d9a4 100644
--- a/sound/core/pcm_dmaengine.c
+++ b/sound/core/pcm_dmaengine.c
@@ -154,6 +154,7 @@ static int dmaengine_pcm_prepare_and_submit(struct snd_pcm_substream *substream)
 	struct dma_async_tx_descriptor *desc;
 	enum dma_transfer_direction direction;
 	unsigned long flags = DMA_CTRL_ACK;
+	int ret;
 
 	direction = snd_pcm_substream_to_dma_direction(substream);
 
@@ -172,6 +173,9 @@ static int dmaengine_pcm_prepare_and_submit(struct snd_pcm_substream *substream)
 	desc->callback = dmaengine_pcm_dma_complete;
 	desc->callback_param = substream;
 	prtd->cookie = dmaengine_submit(desc);
+	ret = dma_submit_error(prtd->cookie);
+	if (ret)
+		return ret;
 
 	return 0;
 }
-- 
2.55.0


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

* [PATCH v2] ALSA: dmaengine: Check DMA submission errors
  2026-11-19  7:10 [PATCH] ALSA: dmaengine: Check DMA submission errors Sreeraj S Kurup
@ 2026-11-19  7:36 ` Sreeraj S Kurup
  0 siblings, 0 replies; 2+ messages in thread
From: Sreeraj S Kurup @ 2026-11-19  7:36 UTC (permalink / raw)
  To: sreekuttan2156239, lars, perex, tiwai; +Cc: linux-kernel, linux-sound

The dmaengine_pcm_prepare_and_submit() function does not check
the return value of dmaengine_submit().

dmaengine_submit() can return a negative DMA cookie if the
submission fails. However, the function currently returns
success unconditionally.

This makes the PCM trigger path believe that DMA has been
successfully submitted, even when the submission has failed.

Use dma_submit_error() to check the returned DMA cookie and
propagate the error to the caller.

This ensures that DMA submission failures are properly
reported instead of allowing the PCM stream to continue
as if the DMA transfer had started successfully.

Fixes: e7f73a161356 ("ASoC: Add dmaengine PCM helper functions")
Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
v2:
 - Add Fixes trailer.

 sound/core/pcm_dmaengine.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c
index 1306b04be171..5b9fdad4d9a4 100644
--- a/sound/core/pcm_dmaengine.c
+++ b/sound/core/pcm_dmaengine.c
@@ -154,6 +154,7 @@ static int dmaengine_pcm_prepare_and_submit(struct snd_pcm_substream *substream)
 	struct dma_async_tx_descriptor *desc;
 	enum dma_transfer_direction direction;
 	unsigned long flags = DMA_CTRL_ACK;
+	int ret;
 
 	direction = snd_pcm_substream_to_dma_direction(substream);
 
@@ -172,6 +173,9 @@ static int dmaengine_pcm_prepare_and_submit(struct snd_pcm_substream *substream)
 	desc->callback = dmaengine_pcm_dma_complete;
 	desc->callback_param = substream;
 	prtd->cookie = dmaengine_submit(desc);
+	ret = dma_submit_error(prtd->cookie);
+	if (ret)
+		return ret;
 
 	return 0;
 }
-- 
2.55.0


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

end of thread, other threads:[~2026-11-19  7:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19  7:10 [PATCH] ALSA: dmaengine: Check DMA submission errors Sreeraj S Kurup
2026-11-19  7:36 ` [PATCH v2] " Sreeraj S Kurup

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

all inboxes | Powered by JetHome®