Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dmaengine: of-dma: router_xlate to return -EPROBE_DEFER if controller is not yet available

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>
Link: https://lore.kernel.org/r/20210717190021.21897-1-peter.ujfalusi@gmail.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Peter Ujfalusi and committed by
Vinod Koul
eda97cb0 baa16371

+7 -2
+7 -2
drivers/dma/of-dma.c
··· 67 67 return NULL; 68 68 69 69 ofdma_target = of_dma_find_controller(&dma_spec_target); 70 - if (!ofdma_target) 71 - return NULL; 70 + if (!ofdma_target) { 71 + ofdma->dma_router->route_free(ofdma->dma_router->dev, 72 + route_data); 73 + chan = ERR_PTR(-EPROBE_DEFER); 74 + goto err; 75 + } 72 76 73 77 chan = ofdma_target->of_dma_xlate(&dma_spec_target, ofdma_target); 74 78 if (IS_ERR_OR_NULL(chan)) { ··· 93 89 } 94 90 } 95 91 92 + err: 96 93 /* 97 94 * Need to put the node back since the ofdma->of_dma_route_allocate 98 95 * has taken it for generating the new, translated dma_spec