From patchwork Wed Aug 29 21:32:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Cercueil X-Patchwork-Id: 10580961 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 D8B03139B for ; Wed, 29 Aug 2018 21:34:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8ACC2BB6D for ; Wed, 29 Aug 2018 21:34:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCF922BB73; Wed, 29 Aug 2018 21:34:06 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 6F0902BB6D for ; Wed, 29 Aug 2018 21:34:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727639AbeH3Bcv (ORCPT ); Wed, 29 Aug 2018 21:32:51 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:53184 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727179AbeH3BcH (ORCPT ); Wed, 29 Aug 2018 21:32:07 -0400 From: Paul Cercueil To: Vinod Koul , Ralf Baechle , Paul Burton Cc: od@zcrc.me, dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@linux-mips.org, Daniel Silsby , Paul Cercueil Subject: [PATCH v5 13/18] dmaengine: dma-jz4780: Set DTCn register explicitly Date: Wed, 29 Aug 2018 23:32:55 +0200 Message-Id: <20180829213300.22829-14-paul@crapouillou.net> In-Reply-To: <20180829213300.22829-1-paul@crapouillou.net> References: <20180829213300.22829-1-paul@crapouillou.net> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1535578398; bh=wBcNmBnqQKtkU2S10+UH6pynUHfBfHNfnHqd15R9rdE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=IFjCsUND0a/KpR7tyUMvaBCgNP+uQuP3tPHZWzS0jX13yTUTf74+GdWlfRW7/s9Psz7oBp6jNhDtfh9wGhTcASHysqr76x3qaCgPz4Z6sZVEtWAj8+oAA5fbJGoKeNu9JRJXjKHintOcqmSg2pcrYlDXVuCBedm2GMr5GR6TbaU= Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Silsby Normally, we wouldn't set the channel transfer count register directly when using descriptor-driven transfers. However, there is no harm in doing so, and it allows jz4780_dma_desc_residue() to report the correct residue of an ongoing transfer, no matter when it is called. Signed-off-by: Daniel Silsby Signed-off-by: Paul Cercueil Tested-by: Mathieu Malaterre --- Notes: v2: No change v3: No change v4: Add my Signed-off-by v5: No change drivers/dma/dma-jz4780.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c index d055602a92ca..d3b915ec8a09 100644 --- a/drivers/dma/dma-jz4780.c +++ b/drivers/dma/dma-jz4780.c @@ -532,6 +532,15 @@ static void jz4780_dma_begin(struct jz4780_dma_chan *jzchan) jz4780_dma_chn_writel(jzdma, jzchan->id, JZ_DMA_REG_DRT, jzchan->transfer_type); + /* + * Set the transfer count. This is redundant for a descriptor-driven + * transfer. However, there can be a delay between the transfer start + * time and when DTCn reg contains the new transfer count. Setting + * it explicitly ensures residue is computed correctly at all times. + */ + jz4780_dma_chn_writel(jzdma, jzchan->id, JZ_DMA_REG_DTC, + jzchan->desc->desc[jzchan->curr_hwdesc].dtc); + /* Write descriptor address and initiate descriptor fetch. */ desc_phys = jzchan->desc->desc_phys + (jzchan->curr_hwdesc * sizeof(*jzchan->desc->desc));