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: 2789681 Return-Path: X-Original-To: patchwork-davinci@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 7AC9E9F3A0 for ; Thu, 27 Jun 2013 03:45:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 908E5201F6 for ; Thu, 27 Jun 2013 03:45:10 +0000 (UTC) Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A10B4201F5 for ; Thu, 27 Jun 2013 03:45:09 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id r5R3h3Vm022926; Wed, 26 Jun 2013 22:43:03 -0500 Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id r5R3h3gs012871; Wed, 26 Jun 2013 22:43:03 -0500 Received: from dlelxv24.itg.ti.com (172.17.1.199) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.2.342.3; Wed, 26 Jun 2013 22:43:02 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv24.itg.ti.com (8.13.8/8.13.8) with ESMTP id r5R3h2gl001207; Wed, 26 Jun 2013 22:43:02 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 63FCE80626; Wed, 26 Jun 2013 22:43:02 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dlelxv90.itg.ti.com (dlelxv90.itg.ti.com [172.17.2.17]) by linux.omap.com (Postfix) with ESMTP id C02768062A for ; Wed, 26 Jun 2013 22:42:30 -0500 (CDT) 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 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: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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; }