From patchwork Wed Dec 10 10:55:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Baldyga X-Patchwork-Id: 5468001 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7A5729F2E8 for ; Wed, 10 Dec 2014 10:56:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A7F7E20125 for ; Wed, 10 Dec 2014 10:56:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B227E2012B for ; Wed, 10 Dec 2014 10:56:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755600AbaLJK4R (ORCPT ); Wed, 10 Dec 2014 05:56:17 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:38447 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755588AbaLJK4P (ORCPT ); Wed, 10 Dec 2014 05:56:15 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NGD00JBX51Q6XA0@mailout1.samsung.com>; Wed, 10 Dec 2014 19:56:14 +0900 (KST) X-AuditID: cbfee61a-f79c06d000004e71-c9-548826cee90f Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 6F.42.20081.EC628845; Wed, 10 Dec 2014 19:56:14 +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 <0NGD00FRN50CYLB0@mmp2.samsung.com>; Wed, 10 Dec 2014 19:56:14 +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, kyungmin.park@samsung.com, l.czerwinski@samsung.com, padma.kvr@gmail.com, Robert Baldyga Subject: [PATCH v3 2/2] dma: pl330: add DMA_PAUSE feature Date: Wed, 10 Dec 2014 11:55:18 +0100 Message-id: <1418208918-28127-3-git-send-email-r.baldyga@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1418208918-28127-1-git-send-email-r.baldyga@samsung.com> References: <1418208918-28127-1-git-send-email-r.baldyga@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOLMWRmVeSWpSXmKPExsVy+t9jQd1zah0hBqcPaFhMn3qB0WL11L+s Fq9fGFqcbXrDbvFr2iQ2iyWT57NaXN41h81i7ZG77Bbty+awWjw4vJPd4mXffhYHbo+ds+6y eyze85LJY8mbQ6wefVtWMXp83iQXwBrFZZOSmpNZllqkb5fAlfGhq5ex4DFvxcaLX9kaGHdw dzFyckgImEg8autnhrDFJC7cW88GYgsJTGeU+Dkpt4uRC8huZ5Jou/4UrIhNQEdiy/cJjCC2 iICExPZnfewgRcwCE5kk+vdfAusWFrCUWHbzPFgDi4CqxPRLM8BsXgFXidWX30Ntk5M4eWwy K4jNKeAmcfL+CXaIza4SjTuuMU5g5F3AyLCKUTS1ILmgOCk911CvODG3uDQvXS85P3cTIzj4 nkntYFzZYHGIUYCDUYmHN+Bye4gQa2JZcWXuIUYJDmYlEd43kh0hQrwpiZVVqUX58UWlOanF hxilOViUxHmV7NtChATSE0tSs1NTC1KLYLJMHJxSDYzKsXn3g3xMIsRrMjn91p5e7htVtMll XkX8Ho0Hj3/t2nlfuWav4w6urj0X1UomWLSGmq9ax/XuscOPJt5vfMc1ZH9W2z186237fl/1 k0krEvsfPD8c/k/1YPQsh56T/k1qJz6zcgsuCvp7wZCLOejXu0cT3giVHG+5ekFK974C0zaF hJKeBGElluKMREMt5qLiRADzWybGOgIAAA== 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 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 2f4d561..ead4369 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -2137,6 +2137,25 @@ static int pl330_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, unsigned pm_runtime_mark_last_busy(pl330->ddma.dev); pm_runtime_put_autosuspend(pl330->ddma.dev); 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. + */ + 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); + break; case DMA_SLAVE_CONFIG: slave_config = (struct dma_slave_config *)arg;