From patchwork Thu Jun 27 03:42:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Fernandes X-Patchwork-Id: 2789671 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8CB229F3A0 for ; Thu, 27 Jun 2013 03:44:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A67A8201F6 for ; Thu, 27 Jun 2013 03:44:26 +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 A59D5201F5 for ; Thu, 27 Jun 2013 03:44:25 +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 1Us37K-000641-5N; Thu, 27 Jun 2013 03:43:30 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Us376-00050m-0w; Thu, 27 Jun 2013 03:43:16 +0000 Received: from devils.ext.ti.com ([198.47.26.153]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Us36r-0004xR-Gx for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2013 03:43:02 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id r5R3gU3N012601; Wed, 26 Jun 2013 22:42:30 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r5R3gUH1011481; Wed, 26 Jun 2013 22:42:30 -0500 Received: from dlelxv22.itg.ti.com (172.17.1.197) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.2.342.3; Wed, 26 Jun 2013 22:42:30 -0500 Received: from localhost.localdomain (h112-149.vpn.ti.com [172.24.112.149]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id r5R3gSln021419; Wed, 26 Jun 2013 22:42:29 -0500 From: Joel Fernandes To: Tony Lindgren , Sekhar Nori , Matt Porter , Grant Likely , Rob Herring , Vinod Koul , Mark Brown , Benoit Cousson , Russell King , Rob Landley , Andrew Morton , Arnd Bergmann Subject: [PATCH v2 2/2] DMA: EDMA: Add comments for A-sync case calculations Date: Wed, 26 Jun 2013 22:42:28 -0500 Message-ID: <1372304548-30777-1-git-send-email-joelf@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-20130626_234301_706660_4B5B6BAA X-CRM114-Status: GOOD ( 13.74 ) X-Spam-Score: -8.2 (--------) Cc: Linux DaVinci Kernel List , Linux Documentation List , Joel Fernandes , 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 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 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; }