[PATCH 09/10] dma: imx-sdma: disable channel 0 when it timeouts

From: Jiada Wang
Date: Mon May 16 2016 - 23:49:43 EST


Previously when channel0 timeouts to finish its task,
sdma_run_channel0() just returns without disable channel0,
this will cause continuous interrupt later when channel0
finishs its task and set channel0 interrupt bit.

Signed-off-by: Jiada Wang <jiada_wang@xxxxxxxxxx>
---
drivers/dma/imx-sdma.c | 43 ++++++++++++++++++++++---------------------
1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index bc867e5..8b20bf4 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -572,6 +572,27 @@ static void sdma_enable_channel(struct sdma_engine *sdma, int channel)
spin_unlock_irqrestore(&sdmac->lock, flags);
}

+static struct sdma_channel *to_sdma_chan(struct dma_chan *chan)
+{
+ return container_of(chan, struct sdma_channel, chan);
+}
+
+static int sdma_disable_channel(struct dma_chan *chan)
+{
+ struct sdma_channel *sdmac = to_sdma_chan(chan);
+ struct sdma_engine *sdma = sdmac->sdma;
+ int channel = sdmac->channel;
+ unsigned long flags;
+
+ spin_lock_irqsave(&sdmac->lock, flags);
+ sdmac->enabled = false;
+ writel_relaxed(BIT(channel), sdma->regs + SDMA_H_STATSTOP);
+ sdmac->status = DMA_ERROR;
+ spin_unlock_irqrestore(&sdmac->lock, flags);
+
+ return 0;
+}
+
/*
* sdma_run_channel0 - run a channel and wait till it's done
*/
@@ -592,6 +613,7 @@ static int sdma_run_channel0(struct sdma_engine *sdma)
/* Clear the interrupt status */
writel_relaxed(ret, sdma->regs + SDMA_H_INTR);
} else {
+ sdma_disable_channel(&sdma->channel[0].chan);
dev_err(sdma->dev, "Timeout waiting for CH0 ready\n");
}

@@ -916,27 +938,6 @@ static int sdma_load_context(struct sdma_channel *sdmac)
return ret;
}

-static struct sdma_channel *to_sdma_chan(struct dma_chan *chan)
-{
- return container_of(chan, struct sdma_channel, chan);
-}
-
-static int sdma_disable_channel(struct dma_chan *chan)
-{
- struct sdma_channel *sdmac = to_sdma_chan(chan);
- struct sdma_engine *sdma = sdmac->sdma;
- int channel = sdmac->channel;
- unsigned long flags;
-
- spin_lock_irqsave(&sdmac->lock, flags);
- sdmac->enabled = false;
- writel_relaxed(BIT(channel), sdma->regs + SDMA_H_STATSTOP);
- sdmac->status = DMA_ERROR;
- spin_unlock_irqrestore(&sdmac->lock, flags);
-
- return 0;
-}
-
static void sdma_set_watermarklevel_for_p2p(struct sdma_channel *sdmac)
{
struct sdma_engine *sdma = sdmac->sdma;
--
2.4.5