alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 REPOST] ASoC: dmaengine: support deferred probe for DMA channels
@ 2013-12-10 17:59 Stephen Warren
  2013-12-10 18:06 ` Lars-Peter Clausen
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Warren @ 2013-12-10 17:59 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood, Lars-Peter Clausen; +Cc: alsa-devel, Stephen Warren

From: Stephen Warren <swarren@nvidia.com>

Enhance dmaengine_pcm_request_chan_of() to support deferred probe for
DMA channels, by using the new dma_request_slave_channel_or_err() API.
This prevents snd_dmaengine_pcm_register() from succeeding without
acquiring DMA channels due to the relevant DMA controller not yet being
registered.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
---
Mark, this is the patch which requires the dependency from the DMA tree,
i.e. what I mentioned in the pull request that I sent just a little while
ago. You'd previously ack'd it so I could take it through the Tegra tree,
but it's probably better if instead you put it into ASoC tree first, then
I pull your (topic/dma?) branch into the Tegra tree.

(I've validated that your current topic/dma, plus a merge of the DMA
tree's topic/defer_probe, plus this patch, plus a merge of next-20131210
to pick up the rest of ASoC etc., runs without conflicts and builds at
least for Tegra without issues).

v2:
* Call dmaengine_pcm_release_chan() if dmaengine_pcm_request_chan_of()
  fails, to clean up any partial allocations.

 sound/soc/soc-generic-dmaengine-pcm.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
index 5b70c556fba3..053c0fa9740d 100644
--- a/sound/soc/soc-generic-dmaengine-pcm.c
+++ b/sound/soc/soc-generic-dmaengine-pcm.c
@@ -287,16 +287,17 @@ static const char * const dmaengine_pcm_dma_channel_names[] = {
 	[SNDRV_PCM_STREAM_CAPTURE] = "rx",
 };
 
-static void dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm,
+static int dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm,
 	struct device *dev, const struct snd_dmaengine_pcm_config *config)
 {
 	unsigned int i;
 	const char *name;
+	struct dma_chan *chan;
 
 	if ((pcm->flags & (SND_DMAENGINE_PCM_FLAG_NO_DT |
 			   SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME)) ||
 	    !dev->of_node)
-		return;
+		return 0;
 
 	if (config->dma_dev) {
 		/*
@@ -318,13 +319,21 @@ static void dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm,
 			name = dmaengine_pcm_dma_channel_names[i];
 		if (config->chan_names[i])
 			name = config->chan_names[i];
-		pcm->chan[i] = dma_request_slave_channel(dev, name);
+		chan = dma_request_slave_channel_reason(dev, name);
+		if (IS_ERR(chan)) {
+			if (PTR_ERR(pcm->chan[i]) == -EPROBE_DEFER)
+				return -EPROBE_DEFER;
+			pcm->chan[i] = NULL;
+		} else
+			pcm->chan[i] = chan;
 		if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX)
 			break;
 	}
 
 	if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX)
 		pcm->chan[1] = pcm->chan[0];
+
+	return 0;
 }
 
 static void dmaengine_pcm_release_chan(struct dmaengine_pcm *pcm)
@@ -360,7 +369,9 @@ int snd_dmaengine_pcm_register(struct device *dev,
 	pcm->config = config;
 	pcm->flags = flags;
 
-	dmaengine_pcm_request_chan_of(pcm, dev, config);
+	ret = dmaengine_pcm_request_chan_of(pcm, dev, config);
+	if (ret)
+		goto err_free_dma;
 
 	if (flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE)
 		ret = snd_soc_add_platform(dev, &pcm->platform,
-- 
1.8.1.5

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

* Re: [PATCH V2 REPOST] ASoC: dmaengine: support deferred probe for DMA channels
  2013-12-10 17:59 [PATCH V2 REPOST] ASoC: dmaengine: support deferred probe for DMA channels Stephen Warren
@ 2013-12-10 18:06 ` Lars-Peter Clausen
  2013-12-10 18:11   ` Stephen Warren
  0 siblings, 1 reply; 3+ messages in thread
From: Lars-Peter Clausen @ 2013-12-10 18:06 UTC (permalink / raw)
  To: Stephen Warren; +Cc: alsa-devel, Mark Brown, Stephen Warren, Liam Girdwood

On 12/10/2013 06:59 PM, Stephen Warren wrote:
> From: Stephen Warren <swarren@nvidia.com>
> 
> Enhance dmaengine_pcm_request_chan_of() to support deferred probe for
> DMA channels, by using the new dma_request_slave_channel_or_err() API.
> This prevents snd_dmaengine_pcm_register() from succeeding without
> acquiring DMA channels due to the relevant DMA controller not yet being
> registered.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> Acked-by: Lars-Peter Clausen <lars@metafoo.de>

Still looks good, but one nitpick:

> -		pcm->chan[i] = dma_request_slave_channel(dev, name);
> +		chan = dma_request_slave_channel_reason(dev, name);
> +		if (IS_ERR(chan)) {
> +			if (PTR_ERR(pcm->chan[i]) == -EPROBE_DEFER)
> +				return -EPROBE_DEFER;
> +			pcm->chan[i] = NULL;
> +		} else
> +			pcm->chan[i] = chan;

I think checkpatch will complain about the above. There should be brackets
around the else branch.

>  		if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX)
>  			break;
>  	}
>  
[...]

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

* Re: [PATCH V2 REPOST] ASoC: dmaengine: support deferred probe for DMA channels
  2013-12-10 18:06 ` Lars-Peter Clausen
@ 2013-12-10 18:11   ` Stephen Warren
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen Warren @ 2013-12-10 18:11 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: alsa-devel, Mark Brown, Stephen Warren, Liam Girdwood

On 12/10/2013 11:06 AM, Lars-Peter Clausen wrote:
> On 12/10/2013 06:59 PM, Stephen Warren wrote:
>> From: Stephen Warren <swarren@nvidia.com>
>>
>> Enhance dmaengine_pcm_request_chan_of() to support deferred probe for
>> DMA channels, by using the new dma_request_slave_channel_or_err() API.
>> This prevents snd_dmaengine_pcm_register() from succeeding without
>> acquiring DMA channels due to the relevant DMA controller not yet being
>> registered.
>>
>> Signed-off-by: Stephen Warren <swarren@nvidia.com>
>> Acked-by: Lars-Peter Clausen <lars@metafoo.de>
> 
> Still looks good, but one nitpick:
> 
>> -		pcm->chan[i] = dma_request_slave_channel(dev, name);
>> +		chan = dma_request_slave_channel_reason(dev, name);
>> +		if (IS_ERR(chan)) {
>> +			if (PTR_ERR(pcm->chan[i]) == -EPROBE_DEFER)
>> +				return -EPROBE_DEFER;
>> +			pcm->chan[i] = NULL;
>> +		} else
>> +			pcm->chan[i] = chan;
> 
> I think checkpatch will complain about the above. There should be brackets
> around the else branch.

Hmm. It doesn't complain for some reason, but I'll fix that and repost.

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

end of thread, other threads:[~2013-12-10 18:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-10 17:59 [PATCH V2 REPOST] ASoC: dmaengine: support deferred probe for DMA channels Stephen Warren
2013-12-10 18:06 ` Lars-Peter Clausen
2013-12-10 18:11   ` Stephen Warren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).