From patchwork Fri Sep 12 14:56:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 4895881 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 A4D489F430 for ; Fri, 12 Sep 2014 14:52:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C2E3820295 for ; Fri, 12 Sep 2014 14:56:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 489DE2018E for ; Fri, 12 Sep 2014 14:56:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750883AbaILO4g (ORCPT ); Fri, 12 Sep 2014 10:56:36 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:49192 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751283AbaILO4f (ORCPT ); Fri, 12 Sep 2014 10:56:35 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NBS007WWMZ00N40@mailout2.w1.samsung.com>; Fri, 12 Sep 2014 15:59:24 +0100 (BST) X-AuditID: cbfec7f4-b7f156d0000063c7-b1-541309a024f8 Received: from eusync1.samsung.com ( [203.254.199.211]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 55.3F.25543.0A903145; Fri, 12 Sep 2014 15:56:32 +0100 (BST) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync1.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NBS00H3LMU5HH20@eusync1.samsung.com>; Fri, 12 Sep 2014 15:56:32 +0100 (BST) From: Krzysztof Kozlowski To: Russell King , Dan Williams , Vinod Koul , linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, Ulf Hansson , Grant Likely , Lars-Peter Clausen , Michal Simek Cc: Kyungmin Park , Marek Szyprowski , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski Subject: [RFC PATCH v2 1/2] amba: Allow AMBA drivers to use their own runtime PM Date: Fri, 12 Sep 2014 16:56:18 +0200 Message-id: <1410533779-3310-2-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1410533779-3310-1-git-send-email-k.kozlowski@samsung.com> References: <1410533779-3310-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNLMWRmVeSWpSXmKPExsVy+t/xy7oLOIVDDG6s07TYOGM9q8X0qRcY LVZP/ctqceDPDkaL1y8MLc42vWG3WDJ5PqvF5V1z2CxuX+a1WHvkLrvFu5cRFsfXhlu87NvP 4sDr0dLcw+axeM9LJo871/aweSx5c4jVo2/LKkaPz5vkPPZ+/s0SwB7FZZOSmpNZllqkb5fA lfHo4WGWgjm8FQvPLGNvYDzN1cXIySEhYCLR0HadHcIWk7hwbz1bFyMXh5DAUkaJZY8XsUM4 fUwSszfuB6tiEzCW2Lx8CViViMAlJolf916DVTELHGWUmN77lgmkSlggQOLj/DZGEJtFQFVi 9vdJYHFeATeJKVP/QO2Tkzh5bDIriM0p4C6xe+9EoHoOoHVuEh+3WU5g5F3AyLCKUTS1NLmg OCk911CvODG3uDQvXS85P3cTIyRAv+xgXHzM6hCjAAejEg8vxznBECHWxLLiytxDjBIczEoi vDdeCYUI8aYkVlalFuXHF5XmpBYfYmTi4JRqYMx/udVthsrR9UwCXp8X+MQKpnpNiGtZ87Vs Zv6iyUHTu0UVTsm8nSjDc1buYdyGD/37dHemvL4pyHmhNYqx5HLdIn6rm+zmAXOV5t6fw3Xc nWXTXN3/novW+RyaUKlX81b4X3tsvz/Hpmm3pb21JnsnH5h3dxtjb77/SX2F9fd/ztfmMrNj K1diKc5INNRiLipOBAAn9Jn3LgIAAA== Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Spam-Status: No, score=-9.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 The AMBA bus driver defines runtime Power Management functions which disable and unprepare AMBA bus clock. This is problematic for runtime PM because unpreparing a clock might sleep so it is not interrupt safe. However some drivers may want to implement runtime PM functions in interrupt-safe way (see pm_runtime_irq_safe()). If such driver implements its own runtime PM functions then assume it will handle the runtime PM completely and it will replace our clock handling. Signed-off-by: Krzysztof Kozlowski --- drivers/amba/bus.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c index 3cf61a127ee5..38461430b7cf 100644 --- a/drivers/amba/bus.c +++ b/drivers/amba/bus.c @@ -94,9 +94,18 @@ static int amba_pm_runtime_suspend(struct device *dev) struct amba_device *pcdev = to_amba_device(dev); int ret = pm_generic_runtime_suspend(dev); - if (ret == 0 && dev->driver) + if (ret == 0 && dev->driver) { + /* + * If driver handles runtime suspend don't duplicate + * the work here. + */ + if (dev->driver->pm && dev->driver->pm->runtime_suspend) + goto out; + clk_disable_unprepare(pcdev->pclk); + } +out: return ret; } @@ -106,12 +115,16 @@ static int amba_pm_runtime_resume(struct device *dev) int ret; if (dev->driver) { + if (dev->driver->pm && dev->driver->pm->runtime_resume) + goto out; + ret = clk_prepare_enable(pcdev->pclk); /* Failure is probably fatal to the system, but... */ if (ret) return ret; } +out: return pm_generic_runtime_resume(dev); } #endif