Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3824721imm; Sat, 21 Jul 2018 04:09:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe7HLZMldwhvpN5x3j8I0pwePBvR65T34p7FQf+mZ4OHD5dTcuOK7tjwpBv6agNo1SpYE2P X-Received: by 2002:a62:d544:: with SMTP id d65-v6mr5615021pfg.107.1532171388928; Sat, 21 Jul 2018 04:09:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532171388; cv=none; d=google.com; s=arc-20160816; b=N/rfivYyY/54WiGlyVxsc1A5JmAkzF6M/x9p5D6+fL2ulrNWe2j5v0CblDtQazKf3O O7GEAf2x9b5FyhgioNvzOUnWc6vADX8KfjN90eO0Dk5+eIXSIwoRz4Apa25nyp19CAQK d8LrvpNNBvQ78vS5z6RlFMr6V7/6HNnQjIaaQnn6F8b3pAiu8cKPUP+W/Y/45iAiyZue yfBFaRvKZuQBv7kbVnTG4THgH2QBAs7OwxzYhgGCQnbgnXjVNxdkREL4YPQOghmLxZ9Q Wqm2werPKsra1RPyr2kq1+7Nvb/dfNiZFek0T2caz7QXO/6qYbaF2u1+1CTEBZqI36Mk CqoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=8ftYYp1frXhXBmkO9JC4kJe9dM5suOEf2IjY9MSwWiU=; b=y8E4RbrY9yyYpoh6CNlvDY6ZZjMNaKKvXTyGgOk1uLaEfcpYPLMO8KOmOu+saiV1vt W7giBZy/00hEsVhWtg3pbjGLfPr78NqwNO04neyzCvLb6+UhRsTYqVICZABnn9OeC7cV mUGroi+Nlg6NPDj+UYiNyxkFqQa9AkDnTK9jkpuNAG2OFw5hQXDHzjB1iPSXn0cjl5lH Nxe0ac6sgFzp5Qvcc9OdOs83G6Avbbm/Wa1lPr5FACYO0fJr8/UlAl+n/YbFJ+pY86oA kTrQoUNGh8TgUeBMahahXucuZxx74Aj3t7NFtEwVvFDP1FfwV8Z12THy3Upx+9tR3MQ9 eenw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=ozg5mPjp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10-v6si3494859pgo.630.2018.07.21.04.09.34; Sat, 21 Jul 2018 04:09:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@crapouillou.net header.s=mail header.b=ozg5mPjp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=crapouillou.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728544AbeGUMAS (ORCPT + 99 others); Sat, 21 Jul 2018 08:00:18 -0400 Received: from outils.crapouillou.net ([89.234.176.41]:44658 "EHLO crapouillou.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728170AbeGUMAR (ORCPT ); Sat, 21 Jul 2018 08:00:17 -0400 From: Paul Cercueil To: Vinod Koul , Rob Herring , Mark Rutland , Ralf Baechle , Paul Burton , James Hogan , Zubair Lutfullah Kakakhel Cc: Mathieu Malaterre , Daniel Silsby , Paul Cercueil , dmaengine@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@linux-mips.org Subject: [PATCH v3 13/18] dmaengine: dma-jz4780: Set DTCn register explicitly Date: Sat, 21 Jul 2018 13:06:38 +0200 Message-Id: <20180721110643.19624-14-paul@crapouillou.net> In-Reply-To: <20180721110643.19624-1-paul@crapouillou.net> References: <20180721110643.19624-1-paul@crapouillou.net> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1532171275; bh=8ftYYp1frXhXBmkO9JC4kJe9dM5suOEf2IjY9MSwWiU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=ozg5mPjpR8KJNeH7WbYEPeMjxuo7KV2bdVlmJ2R03aSgSrwvpsGNgufOrTdU9YQDdguLVhyk2MxJyn3iUlsztiqqqrjUG7MwLixNk99pZGQY1aQK/1jFCu/P3w2BhPIqIW6n+7q8D86jSDihNNwU37Ivw8dSTIcAJQjVHfMIOXY= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Tested-by: Mathieu Malaterre --- drivers/dma/dma-jz4780.c | 9 +++++++++ 1 file changed, 9 insertions(+) v2: No change v3: No change diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c index cc2a86844db4..78849131c81d 100644 --- a/drivers/dma/dma-jz4780.c +++ b/drivers/dma/dma-jz4780.c @@ -530,6 +530,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)); -- 2.11.0