dmaengine.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dmaengine: of-dma: router_xlate to return -EPROBE_DEFER if controller is not yet available
@ 2021-07-17 19:00 Peter Ujfalusi
  2021-07-28  7:12 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Ujfalusi @ 2021-07-17 19:00 UTC (permalink / raw)
  To: vkoul; +Cc: dmaengine, linux-kernel, linux-omap, tony, nm

If the router_xlate can not find the controller in the available DMA
devices then it should return with -EPORBE_DEFER in a same way as the
of_dma_request_slave_channel() does.

The issue can be reproduced if the event router is registered before the
DMA controller itself and a driver would request for a channel before the
controller is registered.
In of_dma_request_slave_channel():
1. of_dma_find_controller() would find the dma_router
2. ofdma->of_dma_xlate() would fail and returned NULL
3. -ENODEV is returned as error code

with this patch we would return in this case the correct -EPROBE_DEFER and
the client can try to request the channel later.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@gmail.com>
---
Hi,

I have noticed the descibed failure sequence on Beagle-x15 board (McASP fails to
probe). It must have been broken for some time, I have not booted the board for
about a year or so...

Regards,
Peter

 drivers/dma/of-dma.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c
index ec00b20ae8e4..ac61ecda2926 100644
--- a/drivers/dma/of-dma.c
+++ b/drivers/dma/of-dma.c
@@ -67,8 +67,12 @@ static struct dma_chan *of_dma_router_xlate(struct of_phandle_args *dma_spec,
 		return NULL;
 
 	ofdma_target = of_dma_find_controller(&dma_spec_target);
-	if (!ofdma_target)
-		return NULL;
+	if (!ofdma_target) {
+		ofdma->dma_router->route_free(ofdma->dma_router->dev,
+					      route_data);
+		chan = ERR_PTR(-EPROBE_DEFER);
+		goto err;
+	}
 
 	chan = ofdma_target->of_dma_xlate(&dma_spec_target, ofdma_target);
 	if (IS_ERR_OR_NULL(chan)) {
@@ -89,6 +93,7 @@ static struct dma_chan *of_dma_router_xlate(struct of_phandle_args *dma_spec,
 		}
 	}
 
+err:
 	/*
 	 * Need to put the node back since the ofdma->of_dma_route_allocate
 	 * has taken it for generating the new, translated dma_spec
-- 
2.32.0


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

* Re: [PATCH] dmaengine: of-dma: router_xlate to return -EPROBE_DEFER if controller is not yet available
  2021-07-17 19:00 [PATCH] dmaengine: of-dma: router_xlate to return -EPROBE_DEFER if controller is not yet available Peter Ujfalusi
@ 2021-07-28  7:12 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2021-07-28  7:12 UTC (permalink / raw)
  To: Peter Ujfalusi; +Cc: dmaengine, linux-kernel, linux-omap, tony, nm

On 17-07-21, 22:00, Peter Ujfalusi wrote:
> If the router_xlate can not find the controller in the available DMA
> devices then it should return with -EPORBE_DEFER in a same way as the
> of_dma_request_slave_channel() does.
> 
> The issue can be reproduced if the event router is registered before the
> DMA controller itself and a driver would request for a channel before the
> controller is registered.
> In of_dma_request_slave_channel():
> 1. of_dma_find_controller() would find the dma_router
> 2. ofdma->of_dma_xlate() would fail and returned NULL
> 3. -ENODEV is returned as error code
> 
> with this patch we would return in this case the correct -EPROBE_DEFER and
> the client can try to request the channel later.

Applied, thanks

-- 
~Vinod

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

end of thread, other threads:[~2021-07-28  7:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-17 19:00 [PATCH] dmaengine: of-dma: router_xlate to return -EPROBE_DEFER if controller is not yet available Peter Ujfalusi
2021-07-28  7:12 ` Vinod Koul

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