From patchwork Wed Sep 19 12:13:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 10605763 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D38B6CB for ; Wed, 19 Sep 2018 12:14:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3619C2B9D4 for ; Wed, 19 Sep 2018 12:14:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 299BC2BAEE; Wed, 19 Sep 2018 12:14:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F1D82BA4F for ; Wed, 19 Sep 2018 12:14:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731179AbeISRvk (ORCPT ); Wed, 19 Sep 2018 13:51:40 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:34189 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727772AbeISRvk (ORCPT ); Wed, 19 Sep 2018 13:51:40 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180919121359euoutp02b2ddc9266c03741cc85b5482324eb4a0~VzBUyR9d70821808218euoutp02L; Wed, 19 Sep 2018 12:13:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180919121359euoutp02b2ddc9266c03741cc85b5482324eb4a0~VzBUyR9d70821808218euoutp02L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1537359239; bh=2mxFypTx0AhLNZ3/8AHvtRbpWrQlpvofC1WzOlIpb7E=; h=From:To:Cc:Subject:Date:References:From; b=GV1AVSPHcDFTBQNTOVybUTBdWdZsn2ToIRlfcav+BjgwXpyYMImpYG53gjaM7hLUX NL5ZkuDBvm7aQY/MEWmlmkujMOxEsYUjy75xz8zXFibKHWKbC098+t+qmTv75K38Zq YQLbOgGrGyvb/vcZ9r8dQNRTiwpZTc0bAZwj6lS0= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180919121358eucas1p2e308fc850778091aeec641a6427c1852~VzBUD8ETr2065820658eucas1p2-; Wed, 19 Sep 2018 12:13:58 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 56.39.04806.68D32AB5; Wed, 19 Sep 2018 13:13:58 +0100 (BST) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180919121357eucas1p19717351c40697483d3bf467c55e46f51~VzBTP8kTX2823528235eucas1p18; Wed, 19 Sep 2018 12:13:57 +0000 (GMT) X-AuditID: cbfec7f5-367ff700000012c6-f4-5ba23d8627ad Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 00.90.04284.58D32AB5; Wed, 19 Sep 2018 13:13:57 +0100 (BST) 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 <0PFA006KEXZ6L760@eusync4.samsung.com>; Wed, 19 Sep 2018 13:13:57 +0100 (BST) From: Marek Szyprowski To: linux-clk@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org Cc: Marek Szyprowski , "Rafael J . Wysocki" , Ulf Hansson , Sylwester Nawrocki , Chanwoo Choi , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [RFC/PATCH] clk: samsung: exynos5433: Fix NOIRQ suspend/resume support Date: Wed, 19 Sep 2018 14:13:42 +0200 Message-id: <20180919121342.18288-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNIsWRmVeSWpSXmKPExsWy7djPc7pttouiDfqeclhsnLGe1eL6l+es FufPb2C3+Nhzj9Xic+8RRosZ5/cxWaw9cpfd4szpS6wW7U9fMlscXxvuwOWxaVUnm8eda3vY PLZcbWfx6NuyitHj8ya5ANYoLpuU1JzMstQifbsEroxNE36wFTyUq+h+8IWlgfGhZBcjJ4eE gInE5WvXWUBsIYEVjBK3X6R2MXIB2Z8ZJX7M288EU/S3cSYbRGIZo8SE78cYIZwGJom7H08w glSxCRhKdL3tYgOxRQRiJE5uu8EOUsQssJVJ4uHGTewgCWGBQIlNBzrBbBYBVYkHjx6zdjFy cPAK2Er82RoMsU1eYvWGA8wgvRICf1klFvdeZIZIuEh0/uyHsoUlXh3fwg5hy0h0dhxkgmho ZpRonzGLHcLpYZTYOmcHG0SVtcTh4xdZQWxmAT6JSdumM4NslhDglehoE4Io8ZB4cPISMyQw YiWm7nzMNIFRYgEjwypG8dTS4tz01GLjvNRyveLE3OLSvHS95PzcTYzAKDz97/jXHYz7/iQd YhTgYFTi4b3wbUG0EGtiWXFl7iFGCQ5mJRFezhygEG9KYmVValF+fFFpTmrxIUZpDhYlcV4+ rbRoIYH0xJLU7NTUgtQimCwTB6dUA+MF4a+WWp8aRL/e+182ZZlyJv/7+BQhk4orvmstzp/0 r11z+BnnwRbz3ROShHLP1F970rarX9rSz27Jk+/zWHzSXb+s3i3ys4N/XaLQTH+1w0knz7tP D9pvIXSB40q8iF3Uq6M/Gs/pb7ys/KP88k3Bg89z/MMrXggXh3kxHCnf23i9686k+51KLMUZ iYZazEXFiQC/Bjp+vgIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLJMWRmVeSWpSXmKPExsVy+t/xa7qttouiDa6+V7DYOGM9q8X1L89Z Lc6f38Bu8bHnHqvF594jjBYzzu9jslh75C67xZnTl1gt2p++ZLY4vjbcgctj06pONo871/aw eWy52s7i0bdlFaPH501yAaxRXDYpqTmZZalF+nYJXBmbJvxgK3goV9H94AtLA+NDyS5GTg4J AROJv40z2boYuTiEBJYwSjz6tg/KaWKSOPdhCyNIFZuAoUTX2y42EFtEIEbix4EF7CBFzALb mSSmPP4GViQs4C9x8/FsVhCbRUBV4sGjx0A2BwevgK3En63BENvkJVZvOMA8gZFrASPDKkaR 1NLi3PTcYkO94sTc4tK8dL3k/NxNjMBA2Xbs5+YdjJc2Bh9iFOBgVOLhvfBtQbQQa2JZcWXu IUYJDmYlEV7OHKAQb0piZVVqUX58UWlOavEhRmkOFiVx3vMGlVFCAumJJanZqakFqUUwWSYO TqkGxmQZTb4nVpxOWy8cexS8sT2/ZHaaCJ9oQbHP3JzVU+RDc7iSl/740q6zy2ru0UdBwtl5 5bmZp+WcVnxgVDq1iKX5wK5PGk+WlMelbXnzbOn0peWqHUYyP2c/u/BSWWNXWHZ2hkPZiu2f TravjZ56wS45Z7OMuWF9+tlT3w3n7Z0hP6FPo2LxIiWW4oxEQy3mouJEAB+UMPkQAgAA X-CMS-MailID: 20180919121357eucas1p19717351c40697483d3bf467c55e46f51 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180919121357eucas1p19717351c40697483d3bf467c55e46f51 References: Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP My recent commit af68ec14f112 'clk: samsung: Use NOIRQ stage for Exynos5433 clocks suspend/resume' moved Exynos5433 CMU suspend/resume callbacks to NOIRQ stage. It turned out that in some cases this is not enough to ensure that clocks provided by the given CMU will be available for other drivers during their NOIRQ system suspend/resume phase. Device core calls pm_runtime_disable and pm_runtime_enable unconditionally on every device during LATE system suspend/resume phase. This means that during noirq_resume, CMU device cannot be runtime resumed, because its power.disable_depth is higher than zero (runtime PM for it will be enabled later in device_resume_early function). To let other devices properly use clocks and keep runtime PM enabled also during NOIRQ system sleep phase, add calls to pm_runtime_enable/disable to balance the actions done by device core. The CMU device will be suspended in its noirq_suspend callback and finally resumed in noirq_resume. Signed-off-by: Marek Szyprowski --- Hi! The unconditional calls to pm_runtime_enable and pm_runtime_enable in device_suspend_late and device_resume_early core functions were a bit surprising for me, because they make NOIRQ phase a special case from the perspective of runtime PM handling. Using LATE system sleep phase to call pm_runtime_enable/disable looks like a workaround for me, but right now I have no other idea how to ensure proper behavior of the Exynos5433 CMU driver. The most strange thing is that I didn't observe this initially after switching to NOIRQ phase. The CMU device (FSYS_CMU) which is not under any power domain behaved correctly and was properly available for DWMMC device, which needs to enable clocks in its noirq_resume callback. However, in case of AUD_CMU and its clients (for example serial_3 device, which is a part of audio-subsytem), the pm_runtime_get_sync() called from clk_prepare() failed, because AUD_CMU device had still disabled runtime PM support. The only difference between FSYS_CMU and AUD_CMU, is the fact that AUD_CMU is under AUD power domain, while FSYS_CMU device has no power domain assigned (for completely other reasons FSYS power domains is not yet instantiated in exynos5433.dtsi). Ulf/Rafael: could You comment a bit on this issue? How it should be solved properly? Best regards Marek Szyprowski Samsung R&D Institute Poland --- drivers/clk/samsung/clk-exynos5433.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/clk/samsung/clk-exynos5433.c b/drivers/clk/samsung/clk-exynos5433.c index 4a0f8ff87ca0..7e6c0c9397a9 100644 --- a/drivers/clk/samsung/clk-exynos5433.c +++ b/drivers/clk/samsung/clk-exynos5433.c @@ -5623,6 +5623,24 @@ static int __maybe_unused exynos5433_cmu_resume(struct device *dev) return 0; } +/* + * late_suspend and early_resume callbacks are required to balance + * pm_runtime_disable and pm_runtime_enable calls in device_suspend_late + * and device_resume_early core functions to keep runtime enabled for + * CMU device during noirq sleep phase. + */ +static int __maybe_unused exynos5433_late_suspend(struct device *dev) +{ + pm_runtime_enable(dev); + return 0; +} + +static int __maybe_unused exynos5433_early_resume(struct device *dev) +{ + pm_runtime_disable(dev); + return 0; +} + static int __init exynos5433_cmu_probe(struct platform_device *pdev) { const struct samsung_cmu_info *info; @@ -5760,6 +5778,8 @@ static const struct of_device_id exynos5433_cmu_of_match[] = { static const struct dev_pm_ops exynos5433_cmu_pm_ops = { SET_RUNTIME_PM_OPS(exynos5433_cmu_suspend, exynos5433_cmu_resume, NULL) + SET_LATE_SYSTEM_SLEEP_PM_OPS(exynos5433_late_suspend, + exynos5433_early_resume) SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) };