public inbox for dmaengine@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dmaengine: xilinx: Handle IRQ mapping errors
@ 2021-12-08 11:42 Lars-Peter Clausen
  2021-12-08 12:29 ` Radhey Shyam Pandey
  2021-12-13  5:53 ` Vinod Koul
  0 siblings, 2 replies; 3+ messages in thread
From: Lars-Peter Clausen @ 2021-12-08 11:42 UTC (permalink / raw)
  To: Vinod Koul
  Cc: Michal Simek, Radhey Shyam Pandey, dmaengine, Lars-Peter Clausen

Handle errors when trying to map the IRQ for the DMA channels.

The main motivation here is to be able to handle probe deferral. E.g. when
using DT overlays it is possible that the DMA controller is probed before
interrupt controller, depending on the order in the DT.

In order to support this switch from irq_of_parse_and_map() to
of_irq_get(), which internally does the same, but it will return
EPROBE_DEFER when the interrupt controller is not yet available.

As a result other errors, such as an invalid IRQ specification, or missing
IRQ are also properly handled.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/dma/xilinx/xilinx_dma.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
index 61618148f9d4..cd62bbb50e8b 100644
--- a/drivers/dma/xilinx/xilinx_dma.c
+++ b/drivers/dma/xilinx/xilinx_dma.c
@@ -2980,7 +2980,9 @@ static int xilinx_dma_chan_probe(struct xilinx_dma_device *xdev,
 	}
 
 	/* Request the interrupt */
-	chan->irq = irq_of_parse_and_map(node, chan->tdest);
+	chan->irq = of_irq_get(node, chan->tdest);
+	if (chan->irq < 0)
+		return dev_err_probe(xdev->dev, chan->irq, "failed to get irq\n");
 	err = request_irq(chan->irq, xdev->dma_config->irq_handler,
 			  IRQF_SHARED, "xilinx-dma-controller", chan);
 	if (err) {
@@ -3054,8 +3056,11 @@ static int xilinx_dma_child_probe(struct xilinx_dma_device *xdev,
 	if (xdev->dma_config->dmatype == XDMA_TYPE_AXIMCDMA && ret < 0)
 		dev_warn(xdev->dev, "missing dma-channels property\n");
 
-	for (i = 0; i < nr_channels; i++)
-		xilinx_dma_chan_probe(xdev, node);
+	for (i = 0; i < nr_channels; i++) {
+		ret = xilinx_dma_chan_probe(xdev, node);
+		if (ret)
+			return ret;
+	}
 
 	return 0;
 }
-- 
2.30.2


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

* RE: [PATCH] dmaengine: xilinx: Handle IRQ mapping errors
  2021-12-08 11:42 [PATCH] dmaengine: xilinx: Handle IRQ mapping errors Lars-Peter Clausen
@ 2021-12-08 12:29 ` Radhey Shyam Pandey
  2021-12-13  5:53 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Radhey Shyam Pandey @ 2021-12-08 12:29 UTC (permalink / raw)
  To: Lars-Peter Clausen, Vinod Koul; +Cc: Michal Simek, dmaengine@vger.kernel.org

> -----Original Message-----
> From: Lars-Peter Clausen <lars@metafoo.de>
> Sent: Wednesday, December 8, 2021 5:12 PM
> To: Vinod Koul <vkoul@kernel.org>
> Cc: Michal Simek <michals@xilinx.com>; Radhey Shyam Pandey
> <radheys@xilinx.com>; dmaengine@vger.kernel.org; Lars-Peter Clausen
> <lars@metafoo.de>
> Subject: [PATCH] dmaengine: xilinx: Handle IRQ mapping errors
> 
> Handle errors when trying to map the IRQ for the DMA channels.
> 
> The main motivation here is to be able to handle probe deferral. E.g. when
> using DT overlays it is possible that the DMA controller is probed before
> interrupt controller, depending on the order in the DT.
> 
> In order to support this switch from irq_of_parse_and_map() to of_irq_get(),
> which internally does the same, but it will return EPROBE_DEFER when the
> interrupt controller is not yet available.
> 
> As a result other errors, such as an invalid IRQ specification, or missing IRQ are
> also properly handled.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>

Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
Thanks!
> ---
>  drivers/dma/xilinx/xilinx_dma.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
> index 61618148f9d4..cd62bbb50e8b 100644
> --- a/drivers/dma/xilinx/xilinx_dma.c
> +++ b/drivers/dma/xilinx/xilinx_dma.c
> @@ -2980,7 +2980,9 @@ static int xilinx_dma_chan_probe(struct
> xilinx_dma_device *xdev,
>  	}
> 
>  	/* Request the interrupt */
> -	chan->irq = irq_of_parse_and_map(node, chan->tdest);
> +	chan->irq = of_irq_get(node, chan->tdest);
> +	if (chan->irq < 0)
> +		return dev_err_probe(xdev->dev, chan->irq, "failed to get
> irq\n");
>  	err = request_irq(chan->irq, xdev->dma_config->irq_handler,
>  			  IRQF_SHARED, "xilinx-dma-controller", chan);
>  	if (err) {
> @@ -3054,8 +3056,11 @@ static int xilinx_dma_child_probe(struct
> xilinx_dma_device *xdev,
>  	if (xdev->dma_config->dmatype == XDMA_TYPE_AXIMCDMA && ret <
> 0)
>  		dev_warn(xdev->dev, "missing dma-channels property\n");
> 
> -	for (i = 0; i < nr_channels; i++)
> -		xilinx_dma_chan_probe(xdev, node);
> +	for (i = 0; i < nr_channels; i++) {
> +		ret = xilinx_dma_chan_probe(xdev, node);
> +		if (ret)
> +			return ret;
> +	}
> 
>  	return 0;
>  }
> --
> 2.30.2


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

* Re: [PATCH] dmaengine: xilinx: Handle IRQ mapping errors
  2021-12-08 11:42 [PATCH] dmaengine: xilinx: Handle IRQ mapping errors Lars-Peter Clausen
  2021-12-08 12:29 ` Radhey Shyam Pandey
@ 2021-12-13  5:53 ` Vinod Koul
  1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2021-12-13  5:53 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Michal Simek, Radhey Shyam Pandey, dmaengine

On 08-12-21, 12:42, Lars-Peter Clausen wrote:
> Handle errors when trying to map the IRQ for the DMA channels.
> 
> The main motivation here is to be able to handle probe deferral. E.g. when
> using DT overlays it is possible that the DMA controller is probed before
> interrupt controller, depending on the order in the DT.
> 
> In order to support this switch from irq_of_parse_and_map() to
> of_irq_get(), which internally does the same, but it will return
> EPROBE_DEFER when the interrupt controller is not yet available.
> 
> As a result other errors, such as an invalid IRQ specification, or missing
> IRQ are also properly handled.

Applied, thanks

-- 
~Vinod

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

end of thread, other threads:[~2021-12-13  5:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-08 11:42 [PATCH] dmaengine: xilinx: Handle IRQ mapping errors Lars-Peter Clausen
2021-12-08 12:29 ` Radhey Shyam Pandey
2021-12-13  5:53 ` Vinod Koul

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