Skip to contentSkip to conversation

ALSA: dmaengine: Check DMA submission errors

PATCH Superseded Sreeraj S Kurup 3 participants 5 messages Nov 19

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: dmaengine: Check DMA submission errors

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.

---
 sound/core/pcm_dmaengine.c | 4 ++++
 1 file changed, 4 insertions(+)
sound/core/pcm_dmaengine.c +4 -0
index 1306b04be171..5b9fdad4d9a4 100644
@@ -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;
 }
Signature · 1 line
2.55.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] ALSA: dmaengine: missing Fixes trailer for dmaengine_submit() error check --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] ALSA: dmaengine: missing Fixes trailer for dmaengine_submit() error check
--

commit 66f30a85918defe781d5eb22843181f804a52ee1
Author: Sreeraj S Kurup <[email protected]>

Quoted 12 lines

ALSA: dmaengine: Check DMA submission errors

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.

Quoted 8 lines

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.

[Severity: Low]
Since this fixes the unchecked dmaengine_submit() return value in dmaengine_pcm_prepare_and_submit(), should it include:

Fixes e7f73a161356 ("ASoC: Add dmaengine PCM helper functions")
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw

PATCH v2 1/1 ALSA: dmaengine: Check DMA submission errors

In reply to 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.

Fixes e7f73a161356 ("ASoC: Add dmaengine PCM helper functions")

---
v2:
- Add Fixes trailer.

 sound/core/pcm_dmaengine.c | 4 ++++
 1 file changed, 4 insertions(+)
sound/core/pcm_dmaengine.c +4 -0
index 1306b04be171..5b9fdad4d9a4 100644
@@ -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;
 }
Signature · 1 line
2.55.0
#3 lore raw
Quoted 14 lines · 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.

Quoted 6 lines

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")

Applied now. Thanks.

Takashi