From patchwork Wed Mar 22 11:35:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 95713 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp188352qgd; Wed, 22 Mar 2017 04:39:38 -0700 (PDT) X-Received: by 10.84.176.100 with SMTP id u91mr55070517plb.112.1490182777954; Wed, 22 Mar 2017 04:39:37 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 189si1511825pgh.105.2017.03.22.04.39.37; Wed, 22 Mar 2017 04:39:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759115AbdCVLjh (ORCPT + 13 others); Wed, 22 Mar 2017 07:39:37 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:10453 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758999AbdCVLjd (ORCPT ); Wed, 22 Mar 2017 07:39:33 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0ON7001FSS7VFL20@mailout1.w1.samsung.com>; Wed, 22 Mar 2017 11:35:55 +0000 (GMT) Received: from eusmges4.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170322113554eucas1p14798e6ae369530ac877aa5799d9188f4~uMSNXC51N0507805078eucas1p1Y; Wed, 22 Mar 2017 11:35:54 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges4.samsung.com (EUCPMTA) with SMTP id 50.CF.28517.A9162D85; Wed, 22 Mar 2017 11:35:54 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170322113553eucas1p20875eb2da524fd090c6a7cc725c9d944~uMSMpOPVM2619926199eucas1p2r; Wed, 22 Mar 2017 11:35:53 +0000 (GMT) X-AuditID: cbfec7f4-f79716d000006f65-e9-58d2619aa07b Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 30.A2.06687.50262D85; Wed, 22 Mar 2017 11:37:41 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0ON7005SKS7QHC90@eusync1.samsung.com>; Wed, 22 Mar 2017 11:35:53 +0000 (GMT) From: Marek Szyprowski To: linux-clk@vger.kernel.org, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marek Szyprowski , Stephen Boyd , Michael Turquette , Ulf Hansson , Sylwester Nawrocki , Chanwoo Choi , Inki Dae , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH v6 0/4] Add runtime PM support for clocks (on Exynos SoC example) Date: Wed, 22 Mar 2017 12:35:39 +0100 Message-id: <1490182543-28550-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPIsWRmVeSWpSXmKPExsWy7djP87qzEi9FGLxsFrTYOGM9q8X1L89Z LSbdn8Bicf78BnaLTY+vsVp87LnHavG59wijxYzz+5gs1h65y25x8ZSrxeE37awWP850s1gc XxvuwOvx/kYru8flvl4mj02rOtk87lzbw+axeUm9R9+WVYwenzfJBbBHcdmkpOZklqUW6dsl cGV0P/zPX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sQkYSnS97QKrEhFoYpR40jeNHcRhFmhjlvjf8ZURpEpYIFji9cM7TCA2i4CqxL0Py1hAbF4B D4kV868zQuyTkzh5bDLrBEbuBYwMqxhFUkuLc9Nziw31ihNzi0vz0vWS83M3MQJDfduxn5t3 MF7aGHyIUYCDUYmHV0H+YoQQa2JZcWXuIUYJDmYlEd5lEZcihHhTEiurUovy44tKc1KLDzGa Ai2fyCwlmpwPjMO8knhDE0NzS0MjYwsLcyMjJXHekg9XwoUE0hNLUrNTUwtSi2D6mDg4pRoY c8xzhTqfvG8OYT95n/lwj6tyxVT+U+uXxG9K/3Ptg5Rd6P5b3s1ram76/AtikD6TvZxngprc ycLGOu/aHK7j335XO+orFFs5FZWw3o8r5Deefn9B66VrSgLVy07qW2/r/LHsI6vRIYagt9r5 ehyhCwPvnftc7qBzs2QtmxabVMgv8dR3TrFKLMUZiYZazEXFiQDfvNnFiwIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170322113553eucas1p20875eb2da524fd090c6a7cc725c9d944 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 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: 20170322113553eucas1p20875eb2da524fd090c6a7cc725c9d944 X-RootMTR: 20170322113553eucas1p20875eb2da524fd090c6a7cc725c9d944 References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Dear All, This patchset adds runtime PM support to common clock framework. This is an attempt to implement support for clock controllers, which belongs to a power domain. This approach works surprisingly well on Exynos 5433 SoC, what allowed us to solve various freeze/crash issues related to power management. The main idea behind this patchset is to keep clock's controller power domain enabled every time when at least one of its clock is enabled or access to its registers is being made. Clock controller driver (clock provider) can supply a struct device pointer, which is the used by clock core for tracking and managing clock's controller runtime pm state. Each clk_prepare() operation will first call pm_runtime_get_sync() on the supplied device, while clk_unprepare() will do pm_runtime_put() at the end. This runtime PM feature has been tested with Exynos4412 (not included in this patchset) and Exynos5433 clocks drivers. Both have some clocks, which belongs to respective power domains and need special handling during power on/off procedures. Till now it wasn't handled at all, what caused various problems. Patches for clocks drivers change the way the clock provider is initialized. Instead of CLK_OF_DECLARE based initialization, a complete platform device driver infrastructure is being used. This is needed to let driver to use runtime PM feature and integrate with generic power domains. The side-effect of this change is a delay in clock provider registeration during system boot, so early initialized drivers might get EPROBEDEFER error when requesting their clocks. This is an issue for IOMMU drivers, so this patchset will be fully functional once the deferred probe for IOMMU will be merged. v9 of the IOMMU deferred probe support has been posted a few days ago: https://www.spinics.net/lists/arm-kernel/msg567558.html Patches are based on v4.11-rc3. Stephen: this patchset finally got a review from Ulf (from PM point of view). Is also touches only the Exynos5433 and Exynos Audio Subsystem drivers, which both have separate DT nodes for each clock controllers and each clock controller is entirely only in the one power domain, so everything is clean from the current DT bindings perspective. Would it be okay to merge it? Best regards Marek Szyprowski Samsung R&D Institute Poland Changelog: v6: - addressed comments from Ulf Hanson and added his 'Reviewed-by' tags - simplified exynos 5433 clock driver code a bit - fixes issues pointed by kbuild test robot v5: - rebased onto next-20170125 kernel release - added two more calls to runtime PM in clock's core: 1. clk_recalc() should ensure active runtime pm state, because it might read registers (in case of dividers) to calculate the rate 2. clk_register() also needs to ensure active runtime pm state to read initial rate and status of the clocks - more fixes in Exynos5433 clocks drivers: 1. PLL in DISP CMU must be enabled for suspend 2. guard clocks registration with pm_runtime_get_sync/pm_runtime_put to avoid turning the power domain on and off many times for no good reason (registering each clock will call pm_runtime_get_sync(), then pm_runtime_put, what in turn might disable power domain) - still waiting for a review... v4: http://www.spinics.net/lists/arm-kernel/msg550747.html - Removed patch for Exynos4412 clocks from the patchset. DT bindings for power domain for ISP sub-controller needs more discussion. It will be handled separately when the runtime PM for clocks feature gets merged. - Added patch with runtime PM support for Exynos AudioSS clock controller driver (needed to enable audio power domain on Exynos5 series). - Fixes in Exynos5433 driver: 1. added missing clock for Audio CMU 2. added support for FSYS CMU 3. improved support for DISP CMU (thanks to Andrzej Hajda for investigating that). - Rebased onto v4.10-rc1 - Waiting for a review... v3: http://www.spinics.net/lists/arm-kernel/msg538122.html - Removed CLK_RUNTIME_PM flag, core now simply checks if runtime pm is enabled for the provided device during clock registration as suggested by Ulf - Simplified code for exynos4412 isp clock driver registration - Resolved some other minor issues pointed by Ulf clk core code - Rebased onto v4.9-rc1 and new version of IOMMU deferred probe patchset v2: https://www.spinics.net/lists/arm-kernel/msg532798.html - Simplified clk_pm_runtime_get/put functions, removed workaround for devices with disabled runtime pm. Such workaround is no longer needed since commit 4d23a5e84806b202d9231929c9507ef7cf7a0185 ("PM / Domains: Allow runtime PM during system PM phases"). - Added CLK_RUNTIME_PM flag to indicate clocks, for which clock core should call runtime pm functions. This solves problem with clocks, for which struct device is already registered, but no runtime pm is enabled. - Extended commit messages according to Ulf suggestions. - Fixed some style issues pointed by Barlomiej. v1: http://www.spinics.net/lists/arm-kernel/msg528128.html - initial version Patch summary: Marek Szyprowski (4): clk: Add support for runtime PM clk: samsung: Add support for runtime PM clk: samsung: exynos5433: Add runtime PM support clk: samsung: exynos-audss: Use runtime PM .../devicetree/bindings/clock/clk-exynos-audss.txt | 6 + .../devicetree/bindings/clock/exynos5433-clock.txt | 16 + drivers/clk/clk.c | 129 ++++++- drivers/clk/samsung/clk-exynos-audss.c | 68 ++-- drivers/clk/samsung/clk-exynos5433.c | 413 ++++++++++++++++----- drivers/clk/samsung/clk-pll.c | 2 +- drivers/clk/samsung/clk.c | 12 +- drivers/clk/samsung/clk.h | 7 + 8 files changed, 517 insertions(+), 136 deletions(-) -- 1.9.1