From patchwork Sun Sep 20 19:10:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hamzahfrq.sub@gmail.com X-Patchwork-Id: 7226501 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0A0249F40A for ; Sun, 20 Sep 2015 19:11:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 21AE220660 for ; Sun, 20 Sep 2015 19:11:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B27C20697 for ; Sun, 20 Sep 2015 19:11:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755456AbbITTLM (ORCPT ); Sun, 20 Sep 2015 15:11:12 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:34420 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755394AbbITTLM (ORCPT ); Sun, 20 Sep 2015 15:11:12 -0400 Received: by wicfx3 with SMTP id fx3so119960472wic.1; Sun, 20 Sep 2015 12:11:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=CrZ3OUT5r1yEOCP57on7OCtTzO7I8izSi1ACVsEZ6xc=; b=uzNDLLhm5bN1reAJxmivg1xYCHbc4kqOoDoAC7RYhYE2ufVAPBa8LLwLf6VRhTBA/0 YASEK256Mcxl4tqQOE2J6kddAGWUwRVaHzRuSSN3dTU+S3BoAQBtnxuC8AqLSpNaA4sr XOLytOtf8JQIXCZ+BdVL/UmFpufEY5fTPrhX5JdCJhKwMuYAQetlVNYRlRDzh0JHdFWq eM+THoZOpN6Dd41lJyOV4UKFy8iTsHfol70zobgD2tJvhvzY0V0Xts4Q6f55g6XoYS+O PeEBH+Q+uHQvcYvt2xU4+EW4GMjY+9fZjAoPYnTsfSo1cUOxeb15gazuXdxnsMCR00GN y8wA== X-Received: by 10.180.20.166 with SMTP id o6mr8871972wie.48.1442776270721; Sun, 20 Sep 2015 12:11:10 -0700 (PDT) Received: from ubuntu-VirtualBox.fritz.box (p4FDCDB66.dip0.t-ipconnect.de. [79.220.219.102]) by smtp.googlemail.com with ESMTPSA id fz1sm9644738wic.8.2015.09.20.12.11.09 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 20 Sep 2015 12:11:10 -0700 (PDT) From: hamzahfrq.sub@gmail.com To: laurent.pinchart@ideasonboard.com Cc: dmaengine@vger.kernel.org, j@bitron.ch, joe@perches.com, kuninori.morimoto.gx@renesas.com, broonie@kernel.org, geert+renesas@glider.be, vinod.koul@intel.com, linux-sh@vger.kernel.org, Muhammad Hamza Farooq Subject: [RESEND PATCH 1/6] dma: rcar-dma: add wait after stopping dma engine Date: Sun, 20 Sep 2015 21:10:57 +0200 Message-Id: <1442776262-2503-2-git-send-email-hamzahfrq.sub@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 From: Muhammad Hamza Farooq DMA engine does not stop instantaneously when transaction is going on (see datasheet). Wait has been added Signed-off-by: Muhammad Hamza Farooq --- drivers/dma/sh/rcar-dmac.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index 7820d07..b5b5e89 100644 --- a/drivers/dma/sh/rcar-dmac.c +++ b/drivers/dma/sh/rcar-dmac.c @@ -716,14 +716,38 @@ static int rcar_dmac_fill_hwdesc(struct rcar_dmac_chan *chan, /* ----------------------------------------------------------------------------- * Stop and reset */ +#define NR_READS_TO_WAIT (5) /* number of times to check if DE = 0 */ +static inline int rcar_dmac_wait_stop(struct rcar_dmac_chan *chan) +{ + unsigned int i = 0; + + do { + u32 chcr = rcar_dmac_chan_read(chan, RCAR_DMACHCR); + + if (!(chcr & RCAR_DMACHCR_DE)) + return 0; + cpu_relax(); + dev_dbg(chan->chan.device->dev, "DMA xfer couldn't be stopped"); + } while (++i < NR_READS_TO_WAIT); -static void rcar_dmac_chan_halt(struct rcar_dmac_chan *chan) + return -EBUSY; +} + +/* Called with chan lock held */ +static int rcar_dmac_chan_halt(struct rcar_dmac_chan *chan) { - u32 chcr = rcar_dmac_chan_read(chan, RCAR_DMACHCR); + u32 chcr; + int ret; + chcr = rcar_dmac_chan_read(chan, RCAR_DMACHCR); chcr &= ~(RCAR_DMACHCR_DSE | RCAR_DMACHCR_DSIE | RCAR_DMACHCR_IE | - RCAR_DMACHCR_TE | RCAR_DMACHCR_DE); + RCAR_DMACHCR_TE | RCAR_DMACHCR_DE); rcar_dmac_chan_write(chan, RCAR_DMACHCR, chcr); + ret = rcar_dmac_wait_stop(chan); + + WARN_ON(ret < 0); + + return ret; } static void rcar_dmac_chan_reinit(struct rcar_dmac_chan *chan)