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: 147029 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp646511ljw; Wed, 19 Sep 2018 05:14:02 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZUXHbYFT8zEPkxEAToRg2Uq+sMwJS6QcyiDzfvUTyslUTAR1QDPNX7/BvkzSB+bgMDN3V/ X-Received: by 2002:a63:d34f:: with SMTP id u15-v6mr2720718pgi.325.1537359242158; Wed, 19 Sep 2018 05:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537359242; cv=none; d=google.com; s=arc-20160816; b=p6Ym4qjTH2h2UCmFueDfKcPFn5o8k1JLKCP2WRhZS4tTIgI1f/JqMT/FT90GvNsBRw vvfd+La8PEH8SRe/FEBeEeSXQNPh0Z7SxUufogwSxd1xCIT2MZUH9CT/zUOev+6lQgK0 KeO5IbPK7CGITdPYImKKwqjBHXbGiV1et+9Ik7McJIBJD0cTyg69exzJAI7NUDuq0S0a IjUIG6uNbNfxEzcMy5hJiV7U5lrDryCTppjde/cf6trODtKrOPoUWF5BLjhGI0u3N8a7 8e6Q3RyaTeqmvSrhiw/GTxW59i4K7UEUMiOyimF8ECkMRMdpvIuHNeceIXh+BEXTy3Pr V7Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=2mxFypTx0AhLNZ3/8AHvtRbpWrQlpvofC1WzOlIpb7E=; b=Ne+NcwuiWv8sXqM1PUJHjJB+MHA6jYjUiiFTNEDTQU1gIwzlqSEg+p99GHyUuysul9 fiRBqHQ6SFRjj4+PvbLFfLqBNcS58rgwSUqsjZLYYXkPOfht9zKhsuMpnZBDwKROmG/h Uj1T5p11lWIBP0yzZ0aozX9ShIfxYKBtVMzV4SJ3dnsN6hKsplIkYwNDHK4EoWukz9xg o9C33Dz6safFO9QnBLBgM4cWuRyXv9F2zzgpNlGm22OLJsmCoTRQFcnGIZNKjHgQS2pi 60VRfWbxbJhMewln1sq8xfjsU/n5GKB65IdezTOPnBq22OIJMlCaQnHEI5RcaXadWWWr B08w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=GV1AVSPH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2-v6si20534905pgk.33.2018.09.19.05.14.01; Wed, 19 Sep 2018 05:14:02 -0700 (PDT) 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; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=GV1AVSPH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731070AbeISRvk (ORCPT + 3 others); 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-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org 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(+) -- 2.17.1 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) };