Skip to contentSkip to conversation

ASoC: soc-generic-dmaengine: report DMA channel request failures more clearly

PATCH Superseded [email protected] 2 participants 3 messages Jul 16 – Jul 30

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: soc-generic-dmaengine: report DMA channel request failures more clearly

From: bui duc phuc <[email protected]>

Currently any dma_request_chan() failure other than -EPROBE_DEFER is silently ignored, since a missing channel is expected for devices that only support one DMA direction. This makes two real problems indistinguishable from that normal case:

1. If the channel name is actually present in "dma-names" but the request still fails, that is a genuine error, not a missing direction warn about it instead of staying silent.

2. If neither direction ends up with a channel, the PCM device is entirely unusable. Unlike missing just one direction, this is never expected, so fail probe with a clear error instead of registering a non-functional PCM device.

No change for the still-silent, still-supported case of a device that legitimately onlysupports one direction.

---
 sound/soc/soc-generic-dmaengine-pcm.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
sound/soc/soc-generic-dmaengine-pcm.c +11 -0
index 467426d2b5e4..c15c2d8248fa 100644
@@ -395,6 +395,11 @@ static int dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm,
 			 */
 			if (PTR_ERR(chan) == -EPROBE_DEFER)
 				return -EPROBE_DEFER;
+
+			if (device_property_match_string(dev, "dma-names", name) >= 0)
+				dev_warn(dev, "dma-names has '%s' but request failed (%ld)\n",
+					 name, PTR_ERR(chan));
+
 			pcm->chan[i] = NULL;
 		} else {
 			pcm->chan[i] = chan;
@@ -406,6 +411,12 @@ static int dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm,
 	if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX)
 		pcm->chan[1] = pcm->chan[0];
 
+	if (!pcm->chan[SNDRV_PCM_STREAM_PLAYBACK] &&
+	    !pcm->chan[SNDRV_PCM_STREAM_CAPTURE]) {
+		dev_err(dev, "no DMA chanel found for either playback or capture\n");
+		return -ENODEV;
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.43.0
maintainer
#1 lore raw

sound/soc/soc-generic-dmaengine-pcm.c static int dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm, · line 402

Quoted 4 lines · On Thu, Jul 16, 2026 at 03:04:28PM +0700, [email protected] wrote:
sound/soc/soc-generic-dmaengine-pcm.c +4 -0
+			if (device_property_match_string(dev, "dma-names", name) >= 0)
+				dev_warn(dev, "dma-names has '%s' but request failed (%ld)\n",
+					 name, PTR_ERR(chan));
+

This is going to generate warnings for unidirectional PCMs, if we don't pass a name for a direction then a default will be provided and we'll try to look it up even if it shouldn't exist.

#2 lore raw

Hi Mark,

Thank you for you review.

Quoted 8 lines

sound/soc/soc-generic-dmaengine-pcm.c static int dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm, · line 402

Quoted 4 lines
sound/soc/soc-generic-dmaengine-pcm.c +4 -0
+                     if (device_property_match_string(dev, "dma-names", name) >= 0)
+                             dev_warn(dev, "dma-names has '%s' but request failed (%ld)\n",
+                                      name, PTR_ERR(chan));
+

This is going to generate warnings for unidirectional PCMs, if we don't pass a name for a direction then a default will be provided and we'll try to look it up even if it shouldn't exist.

In my understanding device_property_match_string() will return a negative error code
if the missing direction's default name isn't listed in "dma-names". Since dev_warn() only triggers on >=0, it shouldn't produce false warnings for unidirectional PCMs.
I may be missing something here. Could you help clarify if there's a specific case
where this would still trigger?

I had already sent v3 before seeing your review.
https://lore.kernel.org/all/[email protected]/
If my understanding is incorrect, I'll address this in the next revision.

Best regards,
Phuc