From patchwork Wed Sep 11 06:08:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Padmavathi Venna X-Patchwork-Id: 2870931 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 44DC6BF43F for ; Wed, 11 Sep 2013 06:10:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6D89120381 for ; Wed, 11 Sep 2013 06:10:38 +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 7906C20378 for ; Wed, 11 Sep 2013 06:10:37 +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 1VJdcW-0000cH-7N; Wed, 11 Sep 2013 06:09:44 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VJdcH-0003dc-4o; Wed, 11 Sep 2013 06:09:29 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VJdbs-0003Yw-9g for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2013 06:09:07 +0000 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MSY0091Y6E8DHJ0@mailout3.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2013 15:08:34 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.123]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id CD.9D.22755.2E800325; Wed, 11 Sep 2013 15:08:34 +0900 (KST) X-AuditID: cbfee68f-b7f656d0000058e3-df-523008e275ed Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id AE.A5.05832.2E800325; Wed, 11 Sep 2013 15:08:34 +0900 (KST) Received: from padma-linuxpc.sisodomain.com ([107.108.83.35]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MSY00EHK6E1FP70@mmp2.samsung.com>; Wed, 11 Sep 2013 15:08:34 +0900 (KST) From: Padmavathi Venna To: linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, padma.v@samsung.com, padma.kvr@gmail.com Subject: [PATCH 1/3] dmaengine: pl330: Set residue in tx_status callback. Date: Wed, 11 Sep 2013 11:38:03 +0530 Message-id: <1378879685-5352-2-git-send-email-padma.v@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1378879685-5352-1-git-send-email-padma.v@samsung.com> References: <1378879685-5352-1-git-send-email-padma.v@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprGIsWRmVeSWpSXmKPExsWyRsSkWvcRh0GQwc0WHYu/k46xW0x9+ITN Yv6JW2wWvQuusllsenyN1WLG+X1MFl+37Ga0aF82h9Xi983vbBYXV3xhsnjZt5/Fgdvj969J jB6zGy6yeOycdZfdY/Gel0wem1Z1snlsXlLv0bdlFaPH501yARxRXDYpqTmZZalF+nYJXBmf +88wF7wQqeg8EdLAuFKwi5GTQ0LAROJGwxQ2CFtM4sK99UA2F4eQwFJGiYbjK9hgitbf/QiV mM4ocfjbKWYIp4dJ4vu5aUxdjBwcbAI6Ei1nXUAaRATKJe4/fMAKUsMsMIlR4vKthawgCWEB T4kXU0+ygNgsAqoSP15/ZQbp5R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vCmJlVWpRfnxRaU5qcWHGJOBbprILCWanA9M EHkl8YbGJuamxqaWJhYmZpakCSuJ8x5stQ4UEkhPLEnNTk0tSC2C2cLEwSnVwGgsOfF6tOWV ZxV8lds8Un+JMlezPOvsqtQ/cvCbt+W5rTen3/52qHFq9b4VsUzZEbPZNkk7yn8VqdDIv7jb RW3JUfeNTLeKDtos+/td+zHL1K/zk77VWeSWL+jQ3rB/V3lnoXRh5bcvM35KCxhXTxV4arl9 U/9vXQfnk88CX7jm/bqcMOnbe2clluKMREMt5qLiRAA0JcAfBgMAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130911_020904_666926_B3AFA163 X-CRM114-Status: GOOD ( 10.50 ) X-Spam-Score: -7.6 (-------) Cc: kgene.kim@samsung.com, arnd@arndb.de, sbkim73@samsung.com, vinod.koul@intel.com, broonie@kernel.org, dgreid@chromium.org, olofj@chromium.org 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: , MIME-Version: 1.0 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.0 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: Dylan Reid Fill txstate.residue with the amount of bytes remaining in the current transfer if the transfer is not complete. This will be of particular use to i2s DMA transfers, providing more accurate hw_ptr values to ASoC. Signed-off-by: Dylan Reid Reviewed-by: Olof Johansson Signed-off-by: Padmavathi Venna --- drivers/dma/pl330.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 54 insertions(+), 1 deletions(-) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 593827b..7ab9136 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2476,11 +2476,64 @@ static void pl330_free_chan_resources(struct dma_chan *chan) spin_unlock_irqrestore(&pch->lock, flags); } +static inline int +pl330_src_addr_in_desc(struct dma_pl330_desc *desc, unsigned int sar) +{ + return ((desc->px.src_addr <= sar) && + (sar <= (desc->px.src_addr + desc->px.bytes))); +} + +static inline int +pl330_dst_addr_in_desc(struct dma_pl330_desc *desc, unsigned int dar) +{ + return ((desc->px.dst_addr <= dar) && + (dar <= (desc->px.dst_addr + desc->px.bytes))); +} + +static unsigned int pl330_tx_residue(struct dma_chan *chan) +{ + struct dma_pl330_chan *pch = to_pchan(chan); + void __iomem *regs = pch->dmac->pif.base; + struct pl330_thread *thrd = pch->pl330_chid; + struct dma_pl330_desc *desc; + unsigned int sar, dar; + unsigned int residue = 0; + unsigned long flags; + + sar = readl(regs + SA(thrd->id)); + dar = readl(regs + DA(thrd->id)); + + spin_lock_irqsave(&pch->lock, flags); + + /* Find the desc related to the current buffer. */ + list_for_each_entry(desc, &pch->work_list, node) { + if (desc->rqcfg.src_inc && pl330_src_addr_in_desc(desc, sar)) { + residue = desc->px.bytes - (sar - desc->px.src_addr); + goto found_unlock; + } + if (desc->rqcfg.dst_inc && pl330_dst_addr_in_desc(desc, dar)) { + residue = desc->px.bytes - (dar - desc->px.dst_addr); + goto found_unlock; + } + } + +found_unlock: + spin_unlock_irqrestore(&pch->lock, flags); + + return residue; +} + static enum dma_status pl330_tx_status(struct dma_chan *chan, dma_cookie_t cookie, struct dma_tx_state *txstate) { - return dma_cookie_status(chan, cookie, txstate); + enum dma_status ret; + + ret = dma_cookie_status(chan, cookie, txstate); + if (ret != DMA_SUCCESS) /* Not complete, check amount left. */ + dma_set_residue(txstate, pl330_tx_residue(chan)); + + return ret; } static void pl330_issue_pending(struct dma_chan *chan)