[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231208134929.49523-6-jankul@alatek.krakow.pl>
Date: Fri, 8 Dec 2023 14:49:26 +0100
From: Jan Kuliga <jankul@...tek.krakow.pl>
To: lizhi.hou@....com, brian.xu@....com, raj.kumar.rampelli@....com,
vkoul@...nel.org, michal.simek@....com, dmaengine@...r.kernel.org,
linux-kernel@...r.kernel.org, miquel.raynal@...tlin.com
Cc: jankul@...tek.krakow.pl
Subject: [PATCH v4 5/8] dmaengine: xilinx: xdma: Add error checking in xdma_channel_isr()
Check and clear the status register value before proceeding any
further in xdma_channel_isr(). It is necessary to do it since the
interrupt may occur on any error condition enabled at the start of a
transfer.
Signed-off-by: Jan Kuliga <jankul@...tek.krakow.pl>
---
drivers/dma/xilinx/xdma.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/dma/xilinx/xdma.c b/drivers/dma/xilinx/xdma.c
index 521ba2a653b6..d1bc36133a45 100644
--- a/drivers/dma/xilinx/xdma.c
+++ b/drivers/dma/xilinx/xdma.c
@@ -812,21 +812,25 @@ static irqreturn_t xdma_channel_isr(int irq, void *dev_id)
desc = to_xdma_desc(vd);
xdev = xchan->xdev_hdl;
+ /* Clear-on-read the status register */
+ ret = regmap_read(xdev->rmap, xchan->base + XDMA_CHAN_STATUS_RC, &st);
+ if (ret)
+ goto out;
+
+ st &= XDMA_CHAN_STATUS_MASK;
+ if ((st & XDMA_CHAN_ERROR_MASK) ||
+ !(st & (CHAN_CTRL_IE_DESC_COMPLETED | CHAN_CTRL_IE_DESC_STOPPED))) {
+ xdma_err(xdev, "channel error, status register value: 0x%x", st);
+ goto out;
+ }
+
ret = regmap_read(xdev->rmap, xchan->base + XDMA_CHAN_COMPLETED_DESC,
- &complete_desc_num);
+ &complete_desc_num);
if (ret)
goto out;
if (desc->cyclic) {
desc->completed_desc_num = complete_desc_num;
-
- ret = regmap_read(xdev->rmap, xchan->base + XDMA_CHAN_STATUS,
- &st);
- if (ret)
- goto out;
-
- regmap_write(xdev->rmap, xchan->base + XDMA_CHAN_STATUS, st);
-
vchan_cyclic_callback(vd);
} else {
xchan->busy = false;
--
2.34.1
Powered by blists - more mailing lists