From patchwork Tue May 17 03:48:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wang, Jiada" X-Patchwork-Id: 9108561 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CF716BF29F for ; Tue, 17 May 2016 03:49:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 051C6201B9 for ; Tue, 17 May 2016 03:49:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0EE7720120 for ; Tue, 17 May 2016 03:49:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755023AbcEQDtk (ORCPT ); Mon, 16 May 2016 23:49:40 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:38267 "EHLO relay1.mentorg.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754967AbcEQDtM (ORCPT ); Mon, 16 May 2016 23:49:12 -0400 Received: from svr-orw-fem-05.mgc.mentorg.com ([147.34.97.43]) by relay1.mentorg.com with esmtp id 1b2W0N-0004zq-2X from Jiada_Wang@mentor.com ; Mon, 16 May 2016 20:49:11 -0700 Received: from jiwang-OptiPlex-980.tokyo.mentorg.com (147.34.91.1) by svr-orw-fem-05.mgc.mentorg.com (147.34.97.43) with Microsoft SMTP Server id 14.3.224.2; Mon, 16 May 2016 20:49:10 -0700 From: Jiada Wang To: , CC: , , , , , Subject: [PATCH 09/10] dma: imx-sdma: disable channel 0 when it timeouts Date: Tue, 17 May 2016 12:48:55 +0900 Message-ID: <1463456936-10634-10-git-send-email-jiada_wang@mentor.com> X-Mailer: git-send-email 2.4.5 In-Reply-To: <1463456936-10634-1-git-send-email-jiada_wang@mentor.com> References: <1463456936-10634-1-git-send-email-jiada_wang@mentor.com> MIME-Version: 1.0 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;