From patchwork Fri Dec 16 10:39:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 88279 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp1327138qgi; Fri, 16 Dec 2016 02:40:35 -0800 (PST) X-Received: by 10.84.218.207 with SMTP id g15mr5322976plm.78.1481884835282; Fri, 16 Dec 2016 02:40:35 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w190si7223936pfb.30.2016.12.16.02.40.35; Fri, 16 Dec 2016 02:40:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760460AbcLPKkX (ORCPT + 4 others); Fri, 16 Dec 2016 05:40:23 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:40039 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757063AbcLPKjl (ORCPT ); Fri, 16 Dec 2016 05:39:41 -0500 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OI9004IEXLQSKC0@mailout3.samsung.com>; Fri, 16 Dec 2016 19:39:31 +0900 (KST) X-AuditID: cbfee61a-f79916d0000062de-0d-5853c4633df1 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id EA.0F.25310.364C3585; Fri, 16 Dec 2016 19:39:31 +0900 (KST) Received: from AMDC2765.digital.local ([106.116.147.25]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OI9008O6XLNST60@mmp2.samsung.com>; Fri, 16 Dec 2016 19:39:31 +0900 (KST) From: Marek Szyprowski To: linux-samsung-soc@vger.kernel.org, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marek Szyprowski , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Vinod Koul Subject: [PATCH] dmaengine: pl330: Fix runtime PM support for terminated transfers Date: Fri, 16 Dec 2016 11:39:11 +0100 Message-id: <1481884751-21411-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRmVeSWpSXmKPExsVy+t9jQd3kI8ERBqd/WlpsnLGe1WL11L+s FufPb2C32PT4GqvFjPP7mCzWHrnLbvGybz+LA7vH4j0vmTw2repk89i8pN6jb8sqRo/Pm+QC WKPcbDJSE1NSixRS85LzUzLz0m2VQkPcdC2UFPISc1NtlSJ0fUOClBTKEnNKgTwjAzTg4Bzg Hqykb5fglnF61Qb2gmWiFbtX32NuYLwo2MXIySEhYCLx/8VGFghbTOLCvfVsILaQwCxGiWtL lbsYuYDsX4wSl07eAitiEzCU6HrbBVYkIpAh8eFiDxNIEbPAVkaJie/6wBLCAiESH1/dYgWx WQRUJTZOfgQU5+DgFfCQOHHcB2KZnMTJY5NZJzByL2BkWMUokVqQXFCclJ5rmJdarlecmFtc mpeul5yfu4kRHKDPpHYwHtzlfohRgINRiYd3wZagCCHWxLLiytxDjBIczEoivDf2B0cI8aYk VlalFuXHF5XmpBYfYjQF2j+RWUo0OR8YPXkl8YYm5ibmxgYW5paWJkZK4ryNs5+FCwmkJ5ak ZqemFqQWwfQxcXBKNTBafOR4xnVARTss82bm0YLNryXlC2Rz7TKSs81UpxffWrevRb33hMnd ygk6L5o+n3F4OutXWd2Xm+vOMtxKvpP9y+juv7+aTXlmWkmr9lz3vbZrtUnWDuG+d7PmMvmu OvW9quLpHzOzW1XnTykK/WM7co9RovzQ3oNm57cW/+1MajpQK3OgLFhUiaU4I9FQi7moOBEA EHgTXWYCAAA= X-MTR: 20000000000000000@CPGS Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org PL330 DMA engine driver is leaking a runtime reference after any terminated DMA transactions. This patch fixes this issue by tracking runtime PM state of the device and making additional call to pm_runtime_put() in terminate_all callback if needed. Fixes: ae43b3289186 ("ARM: 8202/1: dmaengine: pl330: Add runtime Power Management support v12") Signed-off-by: Marek Szyprowski --- drivers/dma/pl330.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Reviewed-by: Krzysztof Kozlowski diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 030fe05ed43b..9f3dbc8c63d2 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -448,6 +448,9 @@ struct dma_pl330_chan { /* for cyclic capability */ bool cyclic; + + /* for runtime pm tracking */ + bool active; }; struct pl330_dmac { @@ -2031,6 +2034,7 @@ static void pl330_tasklet(unsigned long data) _stop(pch->thread); spin_unlock(&pch->thread->dmac->lock); power_down = true; + pch->active = false; } else { /* Make sure the PL330 Channel thread is active */ spin_lock(&pch->thread->dmac->lock); @@ -2050,6 +2054,7 @@ static void pl330_tasklet(unsigned long data) desc->status = PREP; list_move_tail(&desc->node, &pch->work_list); if (power_down) { + pch->active = true; spin_lock(&pch->thread->dmac->lock); _start(pch->thread); spin_unlock(&pch->thread->dmac->lock); @@ -2164,6 +2169,7 @@ static int pl330_terminate_all(struct dma_chan *chan) unsigned long flags; struct pl330_dmac *pl330 = pch->dmac; LIST_HEAD(list); + bool power_down = false; pm_runtime_get_sync(pl330->ddma.dev); spin_lock_irqsave(&pch->lock, flags); @@ -2174,6 +2180,8 @@ static int pl330_terminate_all(struct dma_chan *chan) pch->thread->req[0].desc = NULL; pch->thread->req[1].desc = NULL; pch->thread->req_running = -1; + power_down = pch->active; + pch->active = false; /* Mark all desc done */ list_for_each_entry(desc, &pch->submitted_list, node) { @@ -2191,6 +2199,8 @@ static int pl330_terminate_all(struct dma_chan *chan) list_splice_tail_init(&pch->completed_list, &pl330->desc_pool); spin_unlock_irqrestore(&pch->lock, flags); pm_runtime_mark_last_busy(pl330->ddma.dev); + if (power_down) + pm_runtime_put_autosuspend(pl330->ddma.dev); pm_runtime_put_autosuspend(pl330->ddma.dev); return 0; @@ -2350,6 +2360,7 @@ static void pl330_issue_pending(struct dma_chan *chan) * updated on work_list emptiness status. */ WARN_ON(list_empty(&pch->submitted_list)); + pch->active = true; pm_runtime_get_sync(pch->dmac->ddma.dev); } list_splice_tail_init(&pch->submitted_list, &pch->work_list);