From patchwork Mon Sep 14 12:02:34 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: 7174871 Return-Path: X-Original-To: patchwork-dmaengine@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 8F3899F314 for ; Mon, 14 Sep 2015 12:03:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A899820712 for ; Mon, 14 Sep 2015 12:03:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 11BA02070B for ; Mon, 14 Sep 2015 12:02:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753096AbbINMCx (ORCPT ); Mon, 14 Sep 2015 08:02:53 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:35811 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753041AbbINMCw (ORCPT ); Mon, 14 Sep 2015 08:02:52 -0400 Received: by wicge5 with SMTP id ge5so139456741wic.0 for ; Mon, 14 Sep 2015 05:02:51 -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=8XUS3VHtJFY1ZaO4/DeI43VO1XT5myryMvcKAQtFj/g=; b=XTi5EQM+VWxNmbnXVm2kjzPmcVHANVsvlAkhvBS66AUM5eIsZO82I3M66mSDPwkBdO Kcy6u7bSEIRvAnLRH9zepqndaVlMgodO7DlCXd+lADSAGz1AwSNiSoTArZkHrqF33pd9 J5GlPPZdjWycZJVxpOIO88wFEfimowy0O1aMxRYG877nNZifPZoC6gl5xdYBiZdSpFYP UGF1QfJRjYtDEQkbfvzJzCmuAWpN47H2Y7AHIIeGfOyAfdqYS5P90G1iyi9lJ3hc51qU 6lWyMLJdo4us3ZrT/aQc/Nn976Ke4NWKMUkKbUNwgaWrZhAGlmjdBad82ohPN/5z6wsT quDQ== X-Received: by 10.194.48.102 with SMTP id k6mr29063147wjn.124.1442232170559; Mon, 14 Sep 2015 05:02:50 -0700 (PDT) Received: from ubuntu-VirtualBox.fritz.box (p4FDCD8DE.dip0.t-ipconnect.de. [79.220.216.222]) by smtp.googlemail.com with ESMTPSA id lz10sm15166706wjb.48.2015.09.14.05.02.49 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 14 Sep 2015 05:02:49 -0700 (PDT) From: hamzahfrq.sub@gmail.com To: laurent.pinchart+renesas@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, Muhammad Hamza Farooq Subject: [PATCH 1/6] dma: rcar-dma: add wait after stopping dma engine Date: Mon, 14 Sep 2015 14:02:34 +0200 Message-Id: <1442232160-2615-2-git-send-email-hamzahfrq.sub@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@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 | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe dmaengine" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index 7820d07..920f977 100644 --- a/drivers/dma/sh/rcar-dmac.c +++ b/drivers/dma/sh/rcar-dmac.c @@ -716,14 +716,37 @@ static int rcar_dmac_fill_hwdesc(struct rcar_dmac_chan *chan, /* ----------------------------------------------------------------------------- * Stop and reset */ +#define NR_READS_TO_WAIT (5) /* number of reads to perform to check 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; + dev_dbg(chan->chan.device->dev, "DMA transfer 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)