From patchwork Fri Apr 12 05:29:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 10897271 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 78A0C186E for ; Fri, 12 Apr 2019 05:29:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55B1E28E45 for ; Fri, 12 Apr 2019 05:29:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4957128E21; Fri, 12 Apr 2019 05:29:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD5D328E44 for ; Fri, 12 Apr 2019 05:29:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726720AbfDLF3V (ORCPT ); Fri, 12 Apr 2019 01:29:21 -0400 Received: from de-out1.bosch-org.com ([139.15.230.186]:45928 "EHLO de-out1.bosch-org.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726101AbfDLF3V (ORCPT ); Fri, 12 Apr 2019 01:29:21 -0400 Received: from fe0vm1650.rbesz01.com (unknown [139.15.230.188]) by fe0vms0186.rbdmz01.com (Postfix) with ESMTPS id 44gRKB0FHwz1XLFjb; Fri, 12 Apr 2019 07:29:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=de.bosch.com; s=2015-01-21; t=1555046958; bh=NJEzbVtRLgM7qYE9X5B0j8kwymv1uaTDWBadZxvwBis=; l=10; h=From:From:Reply-To:Sender; b=WE75mUwQ6u+OG10zZWrXbg4eEosvKTPifWdS3h0L8dJKrPwM3ZNiFzbztdNXIpMr+ O+pspRCZA68jq3YCXZSHqOsUUuVDtG0s6dNmINFKPtHPGvMy0WOVoEpaAnHT3aKkIs qB528agiUc5JpcOi3HeWPr4IORTfdY572TgErd+8= Received: from fe0vm02900.rbesz01.com (unknown [10.58.172.176]) by fe0vm1650.rbesz01.com (Postfix) with ESMTPS id 44gRK96ymqz1C8; Fri, 12 Apr 2019 07:29:17 +0200 (CEST) X-AuditID: 0a3aad0c-d19ff700000039d6-b3-5cb0222d7993 Received: from si0vm1950.rbesz01.com ( [10.58.173.29]) (using TLS with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by fe0vm02900.rbesz01.com (SMG Outbound) with SMTP id 7A.C9.14806.D2220BC5; Fri, 12 Apr 2019 07:29:17 +0200 (CEST) Received: from FE-HUB2000.de.bosch.com (unknown [10.4.103.109]) by si0vm1950.rbesz01.com (Postfix) with ESMTPS id 44gRK94S45z52K; Fri, 12 Apr 2019 07:29:17 +0200 (CEST) Received: from HI-Z0EVG.hi.de.bosch.com (10.34.218.219) by FE-HUB2000.de.bosch.com (10.4.103.109) with Microsoft SMTP Server id 15.1.1713.5; Fri, 12 Apr 2019 07:29:17 +0200 From: Dirk Behme To: CC: , , , , , , , , , , , Subject: [PATCH v3 1/2] dmaengine: sh: rcar-dmac: With cyclic DMA residue 0 is valid Date: Fri, 12 Apr 2019 07:29:13 +0200 Message-ID: <20190412052914.16006-1-dirk.behme@de.bosch.com> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Originating-IP: [10.34.218.219] X-Brightmail-Tracker: H4sIAAAAAAAAA22Sf0wbZRjHeXtHOToOj4PBs46y0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Hm28+929KdVpKE2+s4KOuj6Y6N51 fMSWWXSxOGR5VkGNdfqjWTPWK48WFzjfsDW813zyy/3Wj8wvZ87iF6Lc1RN+9+0jdtk8w6Wn lk3POhYPfVVx+QvcWpRbfK+h9SaX0LP+wnW9v/DB3Jvnr732tRLnDXqNCuN4/b9suCy6gwQA AA== Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Having a cyclic DMA, a residue 0 is not an indication of a completed DMA. In case of cyclic DMA make sure that dma_set_residue() is called and with this a residue of 0 is forwarded correctly to the caller. Fixes: 3544d2878817 ("dmaengine: rcar-dmac: use result of updated get_residue in tx_status") Signed-off-by: Dirk Behme Signed-off-by: Achim Dahlhoff Signed-off-by: Hiroyuki Yokoyama Signed-off-by: Yao Lihua Cc: # v4.8+ Reviewed-by: Yoshihiro Shimoda Reviewed-by: Laurent Pinchart --- Note: Patch done against mainline v5.0 Changes in v2: None Changes in v3: Move reading rchan into the spin lock protection. drivers/dma/sh/rcar-dmac.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index 2b4f25698169..54810ffd95e2 100644 --- a/drivers/dma/sh/rcar-dmac.c +++ b/drivers/dma/sh/rcar-dmac.c @@ -1368,6 +1368,7 @@ static enum dma_status rcar_dmac_tx_status(struct dma_chan *chan, enum dma_status status; unsigned long flags; unsigned int residue; + bool cyclic; status = dma_cookie_status(chan, cookie, txstate); if (status == DMA_COMPLETE || !txstate) @@ -1375,10 +1376,11 @@ static enum dma_status rcar_dmac_tx_status(struct dma_chan *chan, spin_lock_irqsave(&rchan->lock, flags); residue = rcar_dmac_chan_get_residue(rchan, cookie); + cyclic = rchan->desc.running ? rchan->desc.running->cyclic : false; spin_unlock_irqrestore(&rchan->lock, flags); /* if there's no residue, the cookie is complete */ - if (!residue) + if (!residue && !cyclic) return DMA_COMPLETE; dma_set_residue(txstate, residue);