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: 2789591 Return-Path: X-Original-To: patchwork-linux-mmc@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 9FFACC0AB1 for ; Thu, 27 Jun 2013 03:43:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C4B15201F4 for ; Thu, 27 Jun 2013 03:43:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D3656201F2 for ; Thu, 27 Jun 2013 03:43:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752198Ab3F0DnQ (ORCPT ); Wed, 26 Jun 2013 23:43:16 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:47568 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752193Ab3F0DnO (ORCPT ); Wed, 26 Jun 2013 23:43:14 -0400 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 CC: Devicetree Discuss , Linux OMAP List , Linux ARM Kernel List , Linux DaVinci Kernel List , Linux Kernel Mailing List , Linux Documentation List , Linux MMC List , Linux SPI Devel List , Joel Fernandes 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 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-8.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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; }