From patchwork Thu Feb 9 14:22:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 93713 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp25909qgi; Thu, 9 Feb 2017 06:25:30 -0800 (PST) X-Received: by 10.84.172.193 with SMTP id n59mr4446304plb.87.1486650330461; Thu, 09 Feb 2017 06:25:30 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b21si10178493pfc.225.2017.02.09.06.25.30; Thu, 09 Feb 2017 06:25:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752981AbdBIOZX (ORCPT + 25 others); Thu, 9 Feb 2017 09:25:23 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:53342 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752155AbdBIOY7 (ORCPT ); Thu, 9 Feb 2017 09:24:59 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OL400CDO2MLMM90@mailout2.w1.samsung.com>; Thu, 09 Feb 2017 14:23:10 +0000 (GMT) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170209142309eucas1p1b2c76b4b820d7b8559201ded5ce1006c~hpHiAgg3k1472114721eucas1p1m; Thu, 9 Feb 2017 14:23:09 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2.samsung.com (EUCPMTA) with SMTP id 05.A7.30614.D4B7C985; Thu, 9 Feb 2017 14:23:09 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170209142308eucas1p24d52db3d52e19228e8f423c3dc8b085b~hpHhQeLy21912319123eucas1p2j; Thu, 9 Feb 2017 14:23:08 +0000 (GMT) X-AuditID: cbfec7f1-f793f6d000007796-55-589c7b4d3eb1 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 32.E6.10233.E4B7C985; Thu, 9 Feb 2017 14:23:10 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OL400ADQ2MEJ1A0@eusync4.samsung.com>; Thu, 09 Feb 2017 14:23:08 +0000 (GMT) From: Marek Szyprowski To: linux-samsung-soc@vger.kernel.org, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Vinod Koul , Ulf Hansson , "Rafael J. Wysocki" , Lars-Peter Clausen , Arnd Bergmann , Inki Dae Subject: [PATCH v8 2/3] dmaengine: pl330: remove pdata based initialization Date: Thu, 09 Feb 2017 15:22:50 +0100 Message-id: <1486650171-20598-3-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1486650171-20598-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNIsWRmVeSWpSXmKPExsWy7djPc7q+1XMiDLYc57b4O+kYu8XGGetZ LVZP/ctqMen+BBaL8+c3sFssmTyf1WLT42usFpd3zWGz+Nx7hNFixvl9TBZrj9xltzhz+hKr xf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CKF1Lzk/JTMvHRbpdAQN10LJYW8xNxUW6UIXd+QICWFssScUiDPyAAN ODgHuAcr6dsluGW8XfucseC7dkX/1PPMDYzrVLoYOTkkBEwkzs1dygZhi0lcuLceyObiEBJY wijx5tQrdginiUliW8d7RpAqNgFDia63XWBVIgKLGCVOrPjPDOIwC7xjkrjV8BKohYNDWMBb 4ts8HRCTRUBVYl+zPkgvr4CHxPOJf1ghtslJnDw2GczmFPCU6OqeADZfCKhm6vrVbBMYeRcw MqxiFEktLc5Nzy020itOzC0uzUvXS87P3cQIjJttx35u2cHY9S74EKMAB6MSD+8F69kRQqyJ ZcWVuYcYJTiYlUR4tSrmRAjxpiRWVqUW5ccXleakFh9iNAW6aSKzlGhyPjCm80riDU0MzS0N jYwtLMyNjJTEead+uBIuJJCeWJKanZpakFoE08fEwSnVwNjf9zJr5VKLv7mr/q7nE+s1n/Up mM9LK21np31LfH6HfhKvp/+MFTsW3VRef1yG381bNjh3yZIth76f2xXyyG7t38IDPAFi6n4f 00/XC5ponUv2vJ3WfdWysU6z5qYcn9SmJX6rn6iGKofGLpjHZ5Wilvc51plr5++YTdkfv50W mH2Q2f5ctRJLcUaioRZzUXEiAJTv8EWxAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170209142308eucas1p24d52db3d52e19228e8f423c3dc8b085b X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1B?= =?utf-8?b?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1BSam?= =?utf-8?q?sung_Electronics=1BSenior_Software_Engineer?= X-Sender-Code: =?utf-8?q?C10=1BEHQ=1BC10CD02CD027392?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170209142308eucas1p24d52db3d52e19228e8f423c3dc8b085b X-RootMTR: 20170209142308eucas1p24d52db3d52e19228e8f423c3dc8b085b References: <1486650171-20598-1-git-send-email-m.szyprowski@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This driver is now used only on platforms which support device tree, so it is safe to remove legacy platform data based initialization code. Signed-off-by: Marek Szyprowski Reviewed-by: Ulf Hansson Acked-by: Arnd Bergmann For plat-samsung: Acked-by: Krzysztof Kozlowski --- arch/arm/plat-samsung/devs.c | 1 - drivers/dma/pl330.c | 42 ++++++++---------------------------------- include/linux/amba/pl330.h | 35 ----------------------------------- 3 files changed, 8 insertions(+), 70 deletions(-) delete mode 100644 include/linux/amba/pl330.h -- 1.9.1 diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c index 03fac123676d..dc269d9143bc 100644 --- a/arch/arm/plat-samsung/devs.c +++ b/arch/arm/plat-samsung/devs.c @@ -10,7 +10,6 @@ * published by the Free Software Foundation. */ -#include #include #include #include diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index f37f4978dabb..8b0da7fa520d 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -2077,18 +2076,6 @@ static void pl330_tasklet(unsigned long data) } } -bool pl330_filter(struct dma_chan *chan, void *param) -{ - u8 *peri_id; - - if (chan->device->dev->driver != &pl330_driver.drv) - return false; - - peri_id = chan->private; - return *peri_id == (unsigned long)param; -} -EXPORT_SYMBOL(pl330_filter); - static struct dma_chan *of_dma_pl330_xlate(struct of_phandle_args *dma_spec, struct of_dma *ofdma) { @@ -2833,7 +2820,6 @@ static int __maybe_unused pl330_resume(struct device *dev) static int pl330_probe(struct amba_device *adev, const struct amba_id *id) { - struct dma_pl330_platdata *pdat; struct pl330_config *pcfg; struct pl330_dmac *pl330; struct dma_pl330_chan *pch, *_p; @@ -2843,8 +2829,6 @@ static int __maybe_unused pl330_resume(struct device *dev) int num_chan; struct device_node *np = adev->dev.of_node; - pdat = dev_get_platdata(&adev->dev); - ret = dma_set_mask_and_coherent(&adev->dev, DMA_BIT_MASK(32)); if (ret) return ret; @@ -2857,7 +2841,7 @@ static int __maybe_unused pl330_resume(struct device *dev) pd = &pl330->ddma; pd->dev = &adev->dev; - pl330->mcbufsz = pdat ? pdat->mcbuf_sz : 0; + pl330->mcbufsz = 0; /* get quirk */ for (i = 0; i < ARRAY_SIZE(of_quirks); i++) @@ -2901,10 +2885,7 @@ static int __maybe_unused pl330_resume(struct device *dev) INIT_LIST_HEAD(&pd->channels); /* Initialize channel parameters */ - if (pdat) - num_chan = max_t(int, pdat->nr_valid_peri, pcfg->num_chan); - else - num_chan = max_t(int, pcfg->num_peri, pcfg->num_chan); + num_chan = max_t(int, pcfg->num_peri, pcfg->num_chan); pl330->num_peripherals = num_chan; @@ -2916,11 +2897,8 @@ static int __maybe_unused pl330_resume(struct device *dev) for (i = 0; i < num_chan; i++) { pch = &pl330->peripherals[i]; - if (!adev->dev.of_node) - pch->chan.private = pdat ? &pdat->peri_id[i] : NULL; - else - pch->chan.private = adev->dev.of_node; + pch->chan.private = adev->dev.of_node; INIT_LIST_HEAD(&pch->submitted_list); INIT_LIST_HEAD(&pch->work_list); INIT_LIST_HEAD(&pch->completed_list); @@ -2933,15 +2911,11 @@ static int __maybe_unused pl330_resume(struct device *dev) list_add_tail(&pch->chan.device_node, &pd->channels); } - if (pdat) { - pd->cap_mask = pdat->cap_mask; - } else { - dma_cap_set(DMA_MEMCPY, pd->cap_mask); - if (pcfg->num_peri) { - dma_cap_set(DMA_SLAVE, pd->cap_mask); - dma_cap_set(DMA_CYCLIC, pd->cap_mask); - dma_cap_set(DMA_PRIVATE, pd->cap_mask); - } + dma_cap_set(DMA_MEMCPY, pd->cap_mask); + if (pcfg->num_peri) { + dma_cap_set(DMA_SLAVE, pd->cap_mask); + dma_cap_set(DMA_CYCLIC, pd->cap_mask); + dma_cap_set(DMA_PRIVATE, pd->cap_mask); } pd->device_alloc_chan_resources = pl330_alloc_chan_resources; diff --git a/include/linux/amba/pl330.h b/include/linux/amba/pl330.h deleted file mode 100644 index fe93758e8403..000000000000 --- a/include/linux/amba/pl330.h +++ /dev/null @@ -1,35 +0,0 @@ -/* linux/include/linux/amba/pl330.h - * - * Copyright (C) 2010 Samsung Electronics Co. Ltd. - * Jaswinder Singh - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef __AMBA_PL330_H_ -#define __AMBA_PL330_H_ - -#include - -struct dma_pl330_platdata { - /* - * Number of valid peripherals connected to DMAC. - * This may be different from the value read from - * CR0, as the PL330 implementation might have 'holes' - * in the peri list or the peri could also be reached - * from another DMAC which the platform prefers. - */ - u8 nr_valid_peri; - /* Array of valid peripherals */ - u8 *peri_id; - /* Operational capabilities */ - dma_cap_mask_t cap_mask; - /* Bytes to allocate for MC buffer */ - unsigned mcbuf_sz; -}; - -extern bool pl330_filter(struct dma_chan *chan, void *param); -#endif /* __AMBA_PL330_H_ */ From patchwork Thu Feb 9 14:22:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 93715 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp25923qgi; Thu, 9 Feb 2017 06:25:31 -0800 (PST) X-Received: by 10.84.254.6 with SMTP id b6mr4617968plm.114.1486650331192; Thu, 09 Feb 2017 06:25:31 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b21si10178493pfc.225.2017.02.09.06.25.30; Thu, 09 Feb 2017 06:25:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753047AbdBIOZ3 (ORCPT + 25 others); Thu, 9 Feb 2017 09:25:29 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:53354 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752200AbdBIOY7 (ORCPT ); Thu, 9 Feb 2017 09:24:59 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OL400CDO2MLMM90@mailout2.w1.samsung.com>; Thu, 09 Feb 2017 14:23:10 +0000 (GMT) Received: from eusmges1.samsung.com (unknown [203.254.199.239]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170209142310eucas1p215f2ebb7f81c8ff850392619e6c3c8b3~hpHihuuZ62005220052eucas1p2V; Thu, 9 Feb 2017 14:23:10 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1.samsung.com (EUCPMTA) with SMTP id 72.C3.16908.05B7C985; Thu, 9 Feb 2017 14:23:12 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170209142309eucas1p2b1277d96139eafc0d1dcc14145600476~hpHh4sVRm1912319123eucas1p2k; Thu, 9 Feb 2017 14:23:09 +0000 (GMT) X-AuditID: cbfec7ef-f79d26d00000420c-38-589c7b50aa98 Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 73.E6.10233.F4B7C985; Thu, 9 Feb 2017 14:23:11 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OL400ADQ2MEJ1A0@eusync4.samsung.com>; Thu, 09 Feb 2017 14:23:08 +0000 (GMT) From: Marek Szyprowski To: linux-samsung-soc@vger.kernel.org, dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Vinod Koul , Ulf Hansson , "Rafael J. Wysocki" , Lars-Peter Clausen , Arnd Bergmann , Inki Dae Subject: [PATCH v8 3/3] dmaengine: pl330: Don't require irq-safe runtime PM Date: Thu, 09 Feb 2017 15:22:51 +0100 Message-id: <1486650171-20598-4-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1486650171-20598-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLIsWRmVeSWpSXmKPExsWy7djPc7oB1XMiDBo/SVr8nXSM3WLjjPWs Fqun/mW1mHR/AovF+fMb2C2WTJ7ParHp8TVWi8u75rBZfO49wmgx4/w+Jou1R+6yW5w5fYnV 4vjacIuXfftZHPg8fv+axOixeM9LJo9NqzrZPO5c28PmsXlJvceSN4dYPbZcbWfx6NuyitHj 8ya5AM4oLpuU1JzMstQifbsEroxFa+4wFTwoqNi0az5TA+OF2C5GTg4JAROJzg8bmSBsMYkL 99azdTFycQgJLGOU+DZlDzuE85lR4tK26cwwHZdufmKBq/p3t5MFJCEk0MAkcWKVDYjNJmAo 0fW2C2yUiMAiRolj55eDjWIWeMckMefTerCFwgLeEt/OzGEHsVkEVCUa968Hs3kFPCQaJrey QayTkzh5bDIriM0p4CnR1T2BESJ+iF3ic29oFyMHkC0rsekAM4TpIvHqkzhEhbDEq+Nb2CFs GYnLk7tZIOx+RommVm0IewajxLm3vBC2tcTh4xfBNjEL8ElMAnsYZCSvREebEESJh8SuBYeg xjhKXH26EBpAcxgl1qw4zjyBUWYBI8MqRpHU0uLc9NRiQ73ixNzi0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3d42 6JheOp53bo/5vDOahy2izI+zHBfUUOJsONMj9fXeg06WfXuX2LyQu87xOXIeo8wn5sisDPvj ravO7L69n/+75KSNa2K5Hhof3b/qonD8RAZGfoPAo+fy5soy/NDLLGmYcVuWSeKoT8wKryMe 0zoOFk79+0GJpTgj0VCLuag4EQAQI1HLswIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170209142309eucas1p2b1277d96139eafc0d1dcc14145600476 X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1B?= =?utf-8?b?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1BSam?= =?utf-8?q?sung_Electronics=1BSenior_Software_Engineer?= X-Sender-Code: =?utf-8?q?C10=1BEHQ=1BC10CD02CD027392?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170209142309eucas1p2b1277d96139eafc0d1dcc14145600476 X-RootMTR: 20170209142309eucas1p2b1277d96139eafc0d1dcc14145600476 References: <1486650171-20598-1-git-send-email-m.szyprowski@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch replaces irq-safe runtime PM with non-irq-safe version based on the new approach. Existing, irq-safe runtime PM implementation for PL330 was not bringing much benefits of its own - only clocks were enabled/disabled. Another limitation of irq-safe runtime PM is a fact, that it may prevent the generic PM domain (genpd) from being powered off, particularly in cases when the genpd doesn't have the GENPD_FLAG_IRQ_SAFE set. Till now non-irq-safe runtime PM implementation was only possible by calling pm_runtime_get/put functions from alloc/free_chan_resources. All other DMA engine API functions cannot be called from a context, which permits sleeping. Such implementation, in practice would result in keeping DMA controller's device active almost all the time, because most of the slave device drivers (DMA engine clients) acquire DMA channel in their probe() function and released it during driver removal. This patch provides a new, different approach. It is based on an observation that there can be only one slave device using each DMA channel. PL330 hardware always has dedicated channels for each peripheral device. Using recently introduced device dependencies (links) infrastructure one can ensure proper runtime PM state of PL330 DMA controller basing on the runtime PM state of the slave device. In this approach in pl330_set_slave() function a new dependency is being created between PL330 DMA controller device (as a supplier) and given slave device (as a consumer). This way PL330 DMA controller device runtime active counter is increased when the slave device is resumed and decreased the same time when given slave device is put to suspend. This way it has been ensured to keep PL330 DMA controller runtime active if there is an active used of any of its DMA channels. This is similar to what has been already implemented in Exynos IOMMU driver in commit 2f5f44f205cc95 ("iommu/exynos: Use device dependency links to control runtime pm"). If slave device doesn't implement runtime PM or keeps device runtime active all the time, then PL330 DMA controller will be runtime active all the time when channel is being allocated. If one requests memory-to-memory channel, runtime active counter is increased unconditionally. This might be a drawback of this approach, but PL330 is not really used for memory-to-memory operations due to poor performance in such operations compared to the CPU. Removal of irq-safe runtime PM is based on the revert of the following commits: 1. commit 5c9e6c2b2ba3 "dmaengine: pl330: fix runtime pm support" 2. commit 81cc6edc0870 "dmaengine: pl330: Fix hang on dmaengine_terminate_all on certain boards" 3. commit ae43b3289186 "ARM: 8202/1: dmaengine: pl330: Add runtime Power Management support v12" Introducing non-irq-safe runtime power management finally allows to turn off audio power domain on Exynos5 SoCs. Signed-off-by: Marek Szyprowski --- drivers/dma/pl330.c | 177 +++++++++++++++++++++++----------------------------- 1 file changed, 77 insertions(+), 100 deletions(-) -- 1.9.1 diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 8b0da7fa520d..17efad418faa 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -268,9 +269,6 @@ enum pl330_byteswap { #define NR_DEFAULT_DESC 16 -/* Delay for runtime PM autosuspend, ms */ -#define PL330_AUTOSUSPEND_DELAY 20 - /* Populated by the PL330 core driver for DMA API driver's info */ struct pl330_config { u32 periph_id; @@ -449,7 +447,7 @@ struct dma_pl330_chan { bool cyclic; /* for runtime pm tracking */ - bool active; + struct device_link *slave_link; }; struct pl330_dmac { @@ -463,6 +461,8 @@ struct pl330_dmac { struct list_head desc_pool; /* To protect desc_pool manipulation */ spinlock_t pool_lock; + /* For management of slave PM links */ + struct mutex rpm_lock; /* Size of MicroCode buffers for each channel. */ unsigned mcbufsz; @@ -2008,7 +2008,6 @@ static void pl330_tasklet(unsigned long data) struct dma_pl330_chan *pch = (struct dma_pl330_chan *)data; struct dma_pl330_desc *desc, *_dt; unsigned long flags; - bool power_down = false; spin_lock_irqsave(&pch->lock, flags); @@ -2023,18 +2022,10 @@ static void pl330_tasklet(unsigned long data) /* Try to submit a req imm. next to the last completed cookie */ fill_queue(pch); - if (list_empty(&pch->work_list)) { - spin_lock(&pch->thread->dmac->lock); - _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); - _start(pch->thread); - spin_unlock(&pch->thread->dmac->lock); - } + /* Make sure the PL330 Channel thread is active */ + spin_lock(&pch->thread->dmac->lock); + _start(pch->thread); + spin_unlock(&pch->thread->dmac->lock); while (!list_empty(&pch->completed_list)) { struct dmaengine_desc_callback cb; @@ -2047,13 +2038,6 @@ static void pl330_tasklet(unsigned long data) if (pch->cyclic) { 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); - power_down = false; - } } else { desc->status = FREE; list_move_tail(&desc->node, &pch->dmac->desc_pool); @@ -2068,12 +2052,6 @@ static void pl330_tasklet(unsigned long data) } } spin_unlock_irqrestore(&pch->lock, flags); - - /* If work list empty, power down */ - if (power_down) { - pm_runtime_mark_last_busy(pch->dmac->ddma.dev); - pm_runtime_put_autosuspend(pch->dmac->ddma.dev); - } } static struct dma_chan *of_dma_pl330_xlate(struct of_phandle_args *dma_spec, @@ -2096,11 +2074,68 @@ static struct dma_chan *of_dma_pl330_xlate(struct of_phandle_args *dma_spec, return dma_get_slave_channel(&pl330->peripherals[chan_id].chan); } +static int pl330_set_slave(struct dma_chan *chan, struct device *slave) +{ + struct dma_pl330_chan *pch = to_pchan(chan); + struct pl330_dmac *pl330 = pch->dmac; + int i; + + mutex_lock(&pl330->rpm_lock); + + for (i = 0; i < pl330->num_peripherals; i++) { + if (pl330->peripherals[i].chan.slave == slave && + pl330->peripherals[i].slave_link) { + pch->slave_link = pl330->peripherals[i].slave_link; + goto done; + } + } + + pch->slave_link = device_link_add(slave, pl330->ddma.dev, + DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE); + if (!pch->slave_link) { + mutex_unlock(&pl330->rpm_lock); + return -ENODEV; + } +done: + mutex_unlock(&pl330->rpm_lock); + + pm_runtime_put(pl330->ddma.dev); + + return 0; +} + +static void pl330_release_slave(struct dma_chan *chan) +{ + struct dma_pl330_chan *pch = to_pchan(chan); + struct pl330_dmac *pl330 = pch->dmac; + struct device_link *link = pch->slave_link; + int i, count = 0; + + pm_runtime_get_sync(pl330->ddma.dev); + + mutex_lock(&pl330->rpm_lock); + + for (i = 0; i < pl330->num_peripherals; i++) + if (pl330->peripherals[i].slave_link == link) + count++; + + pch->slave_link = NULL; + if (count == 1) + device_link_del(link); + + mutex_unlock(&pl330->rpm_lock); +} + static int pl330_alloc_chan_resources(struct dma_chan *chan) { struct dma_pl330_chan *pch = to_pchan(chan); struct pl330_dmac *pl330 = pch->dmac; unsigned long flags; + int ret; + + ret = pm_runtime_get_sync(pl330->ddma.dev); + if (ret < 0) + return ret; spin_lock_irqsave(&pl330->lock, flags); @@ -2110,6 +2145,7 @@ static int pl330_alloc_chan_resources(struct dma_chan *chan) pch->thread = pl330_request_channel(pl330); if (!pch->thread) { spin_unlock_irqrestore(&pl330->lock, flags); + pm_runtime_put(pl330->ddma.dev); return -ENOMEM; } @@ -2151,9 +2187,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); spin_lock(&pl330->lock); _stop(pch->thread); @@ -2162,8 +2196,6 @@ 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) { @@ -2180,10 +2212,6 @@ static int pl330_terminate_all(struct dma_chan *chan) list_splice_tail_init(&pch->work_list, &pl330->desc_pool); 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; } @@ -2201,7 +2229,6 @@ static int pl330_pause(struct dma_chan *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); @@ -2209,8 +2236,6 @@ static int pl330_pause(struct dma_chan *chan) 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; } @@ -2223,7 +2248,6 @@ static void pl330_free_chan_resources(struct dma_chan *chan) tasklet_kill(&pch->task); - pm_runtime_get_sync(pch->dmac->ddma.dev); spin_lock_irqsave(&pl330->lock, flags); pl330_release_channel(pch->thread); @@ -2233,19 +2257,17 @@ static void pl330_free_chan_resources(struct dma_chan *chan) list_splice_tail_init(&pch->work_list, &pch->dmac->desc_pool); spin_unlock_irqrestore(&pl330->lock, flags); - pm_runtime_mark_last_busy(pch->dmac->ddma.dev); - pm_runtime_put_autosuspend(pch->dmac->ddma.dev); + + pm_runtime_put(pl330->ddma.dev); } static int pl330_get_current_xferred_count(struct dma_pl330_chan *pch, struct dma_pl330_desc *desc) { struct pl330_thread *thrd = pch->thread; - struct pl330_dmac *pl330 = pch->dmac; void __iomem *regs = thrd->dmac->base; u32 val, addr; - pm_runtime_get_sync(pl330->ddma.dev); val = addr = 0; if (desc->rqcfg.src_inc) { val = readl(regs + SA(thrd->id)); @@ -2254,8 +2276,6 @@ static int pl330_get_current_xferred_count(struct dma_pl330_chan *pch, val = readl(regs + DA(thrd->id)); addr = desc->px.dst_addr; } - pm_runtime_mark_last_busy(pch->dmac->ddma.dev); - pm_runtime_put_autosuspend(pl330->ddma.dev); /* If DMAMOV hasn't finished yet, SAR/DAR can be zero */ if (!val) @@ -2341,16 +2361,6 @@ static void pl330_issue_pending(struct dma_chan *chan) unsigned long flags; spin_lock_irqsave(&pch->lock, flags); - if (list_empty(&pch->work_list)) { - /* - * Warn on nothing pending. Empty submitted_list may - * break our pm_runtime usage counter as it is - * 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); spin_unlock_irqrestore(&pch->lock, flags); @@ -2778,44 +2788,12 @@ static irqreturn_t pl330_irq_handler(int irq, void *data) BIT(DMA_SLAVE_BUSWIDTH_8_BYTES) /* - * Runtime PM callbacks are provided by amba/bus.c driver. - * - * It is assumed here that IRQ safe runtime PM is chosen in probe and amba - * bus driver will only disable/enable the clock in runtime PM callbacks. + * Runtime PM callbacks are provided by amba/bus.c driver, system sleep + * suspend/resume is implemented by generic helpers, which use existing + * runtime PM callbacks. */ -static int __maybe_unused pl330_suspend(struct device *dev) -{ - struct amba_device *pcdev = to_amba_device(dev); - - pm_runtime_disable(dev); - - if (!pm_runtime_status_suspended(dev)) { - /* amba did not disable the clock */ - amba_pclk_disable(pcdev); - } - amba_pclk_unprepare(pcdev); - - return 0; -} - -static int __maybe_unused pl330_resume(struct device *dev) -{ - struct amba_device *pcdev = to_amba_device(dev); - int ret; - - ret = amba_pclk_prepare(pcdev); - if (ret) - return ret; - - if (!pm_runtime_status_suspended(dev)) - ret = amba_pclk_enable(pcdev); - - pm_runtime_enable(dev); - - return ret; -} - -static SIMPLE_DEV_PM_OPS(pl330_pm, pl330_suspend, pl330_resume); +static SIMPLE_DEV_PM_OPS(pl330_pm, pm_runtime_force_suspend, + pm_runtime_force_resume); static int pl330_probe(struct amba_device *adev, const struct amba_id *id) @@ -2877,6 +2855,7 @@ static int __maybe_unused pl330_resume(struct device *dev) INIT_LIST_HEAD(&pl330->desc_pool); spin_lock_init(&pl330->pool_lock); + mutex_init(&pl330->rpm_lock); /* Create a descriptor pool of default size */ if (!add_desc(pl330, GFP_KERNEL, NR_DEFAULT_DESC)) @@ -2920,6 +2899,8 @@ static int __maybe_unused pl330_resume(struct device *dev) pd->device_alloc_chan_resources = pl330_alloc_chan_resources; pd->device_free_chan_resources = pl330_free_chan_resources; + pd->device_set_slave = pl330_set_slave; + pd->device_release_slave = pl330_release_slave; pd->device_prep_dma_memcpy = pl330_prep_dma_memcpy; pd->device_prep_dma_cyclic = pl330_prep_dma_cyclic; pd->device_tx_status = pl330_tx_status; @@ -2968,11 +2949,7 @@ static int __maybe_unused pl330_resume(struct device *dev) pcfg->data_buf_dep, pcfg->data_bus_width / 8, pcfg->num_chan, pcfg->num_peri, pcfg->num_events); - pm_runtime_irq_safe(&adev->dev); - pm_runtime_use_autosuspend(&adev->dev); - pm_runtime_set_autosuspend_delay(&adev->dev, PL330_AUTOSUSPEND_DELAY); - pm_runtime_mark_last_busy(&adev->dev); - pm_runtime_put_autosuspend(&adev->dev); + pm_runtime_put(&adev->dev); return 0; probe_err3: