From patchwork Wed Jun 26 01:32:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fernandes, Joel A" X-Patchwork-Id: 2782071 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 621A0C0AB1 for ; Wed, 26 Jun 2013 01:35:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 88ABA202A7 for ; Wed, 26 Jun 2013 01:35:11 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8E130202A3 for ; Wed, 26 Jun 2013 01:35:10 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Urebr-0006OU-0R; Wed, 26 Jun 2013 01:33:23 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UrebU-0000yT-IX; Wed, 26 Jun 2013 01:33:00 +0000 Received: from arroyo.ext.ti.com ([192.94.94.40]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Ureb6-0000vp-1N for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2013 01:32:37 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r5Q1W6P9010232; Tue, 25 Jun 2013 20:32:06 -0500 Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r5Q1W6Qt016533; Tue, 25 Jun 2013 20:32:06 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.2.342.3; Tue, 25 Jun 2013 20:32:05 -0500 Received: from localhost.localdomain (h0-133.vpn.ti.com [172.24.0.133]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r5Q1W4p8029185; Tue, 25 Jun 2013 20:32:05 -0500 From: Joel A Fernandes To: Tony Lindgren , Sekhar Nori , Matt Porter , Grant Likely , Rob Herring , Vinod Koul , Mark Brown , Benoit Cousson , Russell King , Balaji TK , Chris Ball Subject: [PATCH 2/2] DMA: EDMA: Add comments for A-sync case calculations Date: Tue, 25 Jun 2013 20:32:04 -0500 Message-ID: <1372210324-7181-1-git-send-email-joelagnel@ti.com> X-Mailer: git-send-email 1.7.0.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130625_213236_229594_BEDD171C X-CRM114-Status: GOOD ( 12.86 ) X-Spam-Score: -8.2 (--------) Cc: Linux DaVinci Kernel List , Arnd Bergmann , Linux Documentation List , Devicetree Discuss , Linux MMC List , Linux Kernel Mailing List , Linux SPI Devel List , Linux OMAP List , Linux ARM Kernel List X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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: Joel A Fernandes A-sync case in EDMA driver is tricky and not so obvious. Document the reasons for the calculations and the scenarious they are used. Signed-off-by: Joel A Fernandes --- drivers/dma/edma.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index e008ed2..a1d9f3785 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -284,8 +284,24 @@ static struct dma_async_tx_descriptor *edma_prep_slave_sg( */ if (burst == 1) { edesc->absync = false; + /* + * For the A-sync case, bcnt and ccnt are the remainder + * and quotient respectively of the division of: + * (sg_dma_len(sg) / acnt) by (SZ_64K -1). This is so + * that in case bcnt over flows, we have ccnt to use. + * Note: In A-sync tranfer only, bcntrld is used, but it + * only applies for sg_dma_len(sg) >= SZ_64K. + * In this case, the best way adopted is- bccnt for the + * first frame will be the remainder below. Then for + * every successive frame, bcnt will be SZ_64K-1. This + * is assured as bcntrld = 0xffff in end of function. + */ ccnt = sg_dma_len(sg) / acnt / (SZ_64K - 1); bcnt = sg_dma_len(sg) / acnt - ccnt * (SZ_64K - 1); + /* + * If bcnt is non-zero, we have a remainder and hence an + * extra frame to transfer, so increment ccnt. + */ if (bcnt) ccnt++; else @@ -343,6 +359,12 @@ static struct dma_async_tx_descriptor *edma_prep_slave_sg( edesc->pset[i].a_b_cnt = bcnt << 16 | acnt; edesc->pset[i].ccnt = ccnt; + /* + * Only time when (bcntrld) auto reload is required is for + * A-sync case, and in this case, a requirement of reload value + * of SZ_64K-1 only is assured. 'link' is initially set to NULL + * and then later will be populated by edma_execute. + */ edesc->pset[i].link_bcntrld = 0xffffffff; }