From patchwork Wed Feb 11 12:23:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Baldyga X-Patchwork-Id: 5812481 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EC381BF440 for ; Wed, 11 Feb 2015 12:24:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 180F820218 for ; Wed, 11 Feb 2015 12:24:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 32FD720212 for ; Wed, 11 Feb 2015 12:24:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752927AbbBKMYJ (ORCPT ); Wed, 11 Feb 2015 07:24:09 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:41340 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752922AbbBKMYI (ORCPT ); Wed, 11 Feb 2015 07:24:08 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NJL009R5X46TU40@mailout4.samsung.com>; Wed, 11 Feb 2015 21:24:06 +0900 (KST) X-AuditID: cbfee61a-f79c06d000004e71-74-54db49e63661 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 0C.07.20081.6E94BD45; Wed, 11 Feb 2015 21:24:06 +0900 (KST) Received: from AMDC2122.DIGITAL.local ([106.120.53.17]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NJL00ARIX2W0A70@mmp2.samsung.com>; Wed, 11 Feb 2015 21:24:06 +0900 (KST) From: Robert Baldyga To: vinod.koul@intel.com Cc: dan.j.williams@intel.com, lars@metafoo.de, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, m.szyprowski@samsung.com, k.kozlowski@samsung.com, Robert Baldyga Subject: [PATCH v4 2/2] dma: pl330: add DMA_PAUSE feature Date: Wed, 11 Feb 2015 13:23:18 +0100 Message-id: <1423657398-13876-3-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1423657398-13876-1-git-send-email-r.baldyga@samsung.com> References: <1423657398-13876-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprCLMWRmVeSWpSXmKPExsVy+t9jQd1nnrdDDBZvMbeYPvUCo8XqqX9Z LV6/MLRYMnk+q8XlXXPYLNYeuctu8eDwTnaLl337WRw4PBbvecnkseTNIVaPvi2rGD0+b5IL YInisklJzcksSy3St0vgyvj19wJ7wSbBiv9ntzA1MF7k62Lk5JAQMJH43XOECcIWk7hwbz1b FyMXh5DAdEaJqdPuMEM47UwSDx7PYwepYhPQkdjyfQIjiC0iICGx/VkfO0gRs8BRRonTc96z gCSEBSwlvi9ZxwpiswioSvx8dwNsBa+Aq8TFuycYIdbJSZw8NhmshlPATWLKpJtgNUJANZcW v2SewMi7gJFhFaNoakFyQXFSeq6hXnFibnFpXrpecn7uJkZwWD2T2sG4ssHiEKMAB6MSD++H TbdChFgTy4orcw8xSnAwK4nwXnO9HSLEm5JYWZValB9fVJqTWnyIUZqDRUmcV8m+LURIID2x JDU7NbUgtQgmy8TBKdXAuDPR/1uiDBNfjeShDWunuzWdrX+l6sv8TMTa/UCOVNznzQZNzm/e bi8zz117RWQq6/Tpa77fcDrKKHlTTLsmqkli2uvdyXPq5p654mjN8ZSJOeTshOfF74Mtbp94 fdv3VvSOGRFmi1e/yS4tTxLO7eS82Heh4aHpz+V7nB+/2Fv9b/HOA39SGJVYijMSDbWYi4oT Ad6sTwgnAgAA Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 DMA_PAUSE command is used for halting DMA transfer on chosen channel. It can be useful when we want to safely read residue before terminating all requests on channel. Otherwise there can be situation when some data is transferred before channel termination but after reading residue, which obviously results with data loss. To avoid this situation we can pause channel, read residue and then terminate all requests. This scenario is common, for example, in serial port drivers. Signed-off-by: Robert Baldyga --- drivers/dma/pl330.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 517abd6..3c2fcd6 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2149,6 +2149,33 @@ static int pl330_terminate_all(struct dma_chan *chan) return 0; } +/* + * We don't support DMA_RESUME command because of hardware + * limitations, so after pausing the channel we cannot restore + * it to active state. We have to terminate channel and setup + * DMA transfer again. This pause feature was implemented to + * allow safely read residue before channel termination. + */ +int pl330_pause(struct dma_chan *chan) +{ + struct dma_pl330_chan *pch = to_pchan(chan); + struct pl330_dmac *pl330 = pch->dmac; + unsigned long flags; + + pm_runtime_get_sync(pl330->ddma.dev); + spin_lock_irqsave(&pch->lock, flags); + + spin_lock(&pl330->lock); + _stop(pch->thread); + spin_unlock(&pl330->lock); + + spin_unlock_irqrestore(&pch->lock, flags); + pm_runtime_mark_last_busy(pl330->ddma.dev); + pm_runtime_put_autosuspend(pl330->ddma.dev); + + return 0; +} + static void pl330_free_chan_resources(struct dma_chan *chan) { struct dma_pl330_chan *pch = to_pchan(chan); @@ -2836,6 +2863,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) pd->device_tx_status = pl330_tx_status; pd->device_prep_slave_sg = pl330_prep_slave_sg; pd->device_config = pl330_config; + pd->device_pause = pl330_pause; pd->device_terminate_all = pl330_terminate_all; pd->device_issue_pending = pl330_issue_pending; pd->src_addr_widths = PL330_DMA_BUSWIDTHS;