From patchwork Tue Nov 25 12:25:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Baldyga X-Patchwork-Id: 5378211 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 65F3BC11AC for ; Tue, 25 Nov 2014 12:26:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 645422012D for ; Tue, 25 Nov 2014 12:26:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9332201BB for ; Tue, 25 Nov 2014 12:26:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754597AbaKYM0J (ORCPT ); Tue, 25 Nov 2014 07:26:09 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:61198 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754430AbaKYM0H (ORCPT ); Tue, 25 Nov 2014 07:26:07 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NFL00BM6H7HMYA0@mailout3.samsung.com>; Tue, 25 Nov 2014 21:26:05 +0900 (KST) X-AuditID: cbfee61a-f79c06d000004e71-dc-5474755d61a0 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id D8.FC.20081.D5574745; Tue, 25 Nov 2014 21:26:05 +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 <0NFL009V2H70VT20@mmp2.samsung.com>; Tue, 25 Nov 2014 21:26:05 +0900 (KST) From: Robert Baldyga To: vinod.koul@intel.com Cc: dan.j.williams@intel.com, ars@metafoo.de, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, m.szyprowski@samsung.com, l.czerwinski@samsung.com, Robert Baldyga Subject: [PATCH 2/2] dma: pl330: add DMA_PAUSE feature Date: Tue, 25 Nov 2014 13:25:46 +0100 Message-id: <1416918346-2442-3-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1416918346-2442-1-git-send-email-r.baldyga@samsung.com> References: <1416918346-2442-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprCLMWRmVeSWpSXmKPExsVy+t9jQd3Y0pIQg56lRhYXDnQyWkyfeoHR YvXUv6wWv6ZNYrO4vGsOm8XaI3fZLR4c3slu8bJvP4sDh8fiPS+ZPJa8OcTq0bdlFaPH501y ASxRXDYpqTmZZalF+nYJXBlzdxxjLbjNWzG/+S9jA+My7i5GTg4JAROJS9OPskLYYhIX7q1n A7GFBKYzSkzcWN3FyAVktzNJ7Pp1iBEkwSagI7Hl+wQwW0RAQmL7sz52kCJmgaOMEtPnXgDr FhYwk/j8YA8ziM0ioCqx9O5JsDivgIvExq2zoLbJSZw8NhnM5hRwlehd9JARYrOLxLQjR5km MPIuYGRYxSiaWpBcUJyUnmuoV5yYW1yal66XnJ+7iREcVs+kdjCubLA4xCjAwajEw9txtjhE iDWxrLgy9xCjBAezkgjvk+SSECHelMTKqtSi/Pii0pzU4kOM0hwsSuK8N27mhggJpCeWpGan phakFsFkmTg4pRoYZ2V3xW3kPeEixVvwV2gpy4NaP7fEsgeTLH5yyiRMEX8tx1NepfPMzfrd 744c/R384pNFNe4dfhcrdC/f2eO57gtJs9TiNdxBlb5Jq3WMti0svK7x/7F06fcZtbKdO9/y 7L9jeezm9VOqC/2zhT4kh30RPKhz4WrKxOwrK/pdeIS2l9gLOn9WYinOSDTUYi4qTgQAruAb MCcCAAA= 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 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index c32806d..9c64421 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2115,6 +2115,26 @@ static int pl330_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, unsigned list_splice_tail_init(&pch->completed_list, &pl330->desc_pool); spin_unlock_irqrestore(&pch->lock, flags); break; + case DMA_PAUSE: + /* + * 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. + */ + spin_lock_irqsave(&pch->lock, flags); + + spin_lock(&pl330->lock); + _stop(pch->thread); + spin_unlock(&pl330->lock); + + pch->thread->req[0].desc = NULL; + pch->thread->req[1].desc = NULL; + pch->thread->req_running = -1; + + spin_unlock_irqrestore(&pch->lock, flags); + break; case DMA_SLAVE_CONFIG: slave_config = (struct dma_slave_config *)arg;