From patchwork Fri Sep 7 10:00:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Song, Elen" X-Patchwork-Id: 1421091 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 0FD0D3FC85 for ; Fri, 7 Sep 2012 10:19:49 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T9vcZ-0000Ou-1H; Fri, 07 Sep 2012 10:17:07 +0000 Received: from nasmtp01.atmel.com ([192.199.1.245] helo=DVREDG01.corp.atmel.com) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T9vcU-0000OK-Sx for linux-arm-kernel@lists.infradead.org; Fri, 07 Sep 2012 10:17:03 +0000 Received: from apsmtp01.atmel.com (10.168.254.31) by DVREDG01.corp.atmel.com (10.42.103.30) with Microsoft SMTP Server (TLS) id 14.2.318.1; Fri, 7 Sep 2012 04:17:38 -0600 Received: from PENCHT01.corp.atmel.com (10.168.5.161) by apsmtp02.atmel.com (10.168.254.31) with Microsoft SMTP Server (TLS) id 14.2.318.1; Fri, 7 Sep 2012 18:05:01 +0800 Received: from penmbx02.corp.atmel.com ([10.168.5.211]) by PENCHT01.corp.atmel.com ([fe80::95df:d3d0:4452:28e3%12]) with mapi id 14.02.0318.001; Fri, 7 Sep 2012 18:00:45 +0800 From: "Song, Elen" To: Russell King - ARM Linux , "djbw@fb.com" Subject: [PATCH] DMA: get current descriptor data transfer count Thread-Topic: [PATCH] DMA: get current descriptor data transfer count Thread-Index: AQHNjN4RMlCGwulpE0ChwPO/UeK+NZd+pTuA Date: Fri, 7 Sep 2012 10:00:44 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.168.5.13] MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: "Wu, Josh" , "Lin, JM" , "Ferre, Nicolas" , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org when data transfer by dma, we could know how many data transfered in one descriptor read DMAC_CTRLAx's btsize bit to get dma transfer size in this case, we could know how many data have been transfered even transaction timeout Signed-off-by: Elen Song --- drivers/dma/at_hdmac.c | 18 ++++++++++++++++++ include/linux/dmaengine.h | 2 ++ 2 files changed, 20 insertions(+) dma_cookie_t (*tx_submit)(struct dma_async_tx_descriptor *tx); dma_async_tx_callback callback; void *callback_param; + int (*get_count)(struct dma_async_tx_descriptor *tx); #ifdef CONFIG_ASYNC_TX_ENABLE_CHANNEL_SWITCH struct dma_async_tx_descriptor *next; struct dma_async_tx_descriptor *parent; -- 1.7.10 diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c index 3934fcc..2099613 100644 --- a/drivers/dma/at_hdmac.c +++ b/drivers/dma/at_hdmac.c @@ -53,6 +53,7 @@ MODULE_PARM_DESC(init_nr_desc_per_channel, /* prototypes */ static dma_cookie_t atc_tx_submit(struct dma_async_tx_descriptor *tx); +static int atc_get_count(struct dma_async_tx_descriptor *tx); /*----------------------------------------------------------------------*/ @@ -95,6 +96,7 @@ static struct at_desc *atc_alloc_descriptor(struct dma_chan *chan, desc->txd.flags = DMA_CTRL_ACK; desc->txd.tx_submit = atc_tx_submit; desc->txd.phys = phys; + desc->txd.get_count = atc_get_count; } return desc; @@ -229,6 +231,22 @@ static void atc_dostart(struct at_dma_chan *atchan, struct at_desc *first) vdbg_dump_regs(atchan); } +/* + * atc_get_count - get current descriptor transfer data count + * @tx: current descriptor + */ +static int atc_get_count(struct dma_async_tx_descriptor *tx) { + struct at_dma_chan *atchan = to_at_dma_chan(tx->chan); + int ctrla, btsize; + + ctrla = channel_readl(atchan, CTRLA); + /* btsize is incremental until data transfer complete*/ + btsize = ctrla & ATC_BTSIZE_MAX; + + return btsize; +} + /** * atc_chain_complete - finish work for one transaction chain * @atchan: channel we work on diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 9c02a45..c719fff 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -404,6 +404,7 @@ typedef void (*dma_async_tx_callback)(void *dma_async_param); * @tx_submit: set the prepared descriptor(s) to be executed by the engine * @callback: routine to call after this operation is complete * @callback_param: general parameter to pass to the callback routine + * @get_count: get current descriptor data transfer count * ---async_tx api specific fields--- * @next: at completion submit this descriptor * @parent: pointer to the next level up in the dependency chain @@ -417,6 +418,7 @@ struct dma_async_tx_descriptor {