From patchwork Thu Nov 30 12:14: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: 120158 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp588588qgn; Thu, 30 Nov 2017 04:15:22 -0800 (PST) X-Google-Smtp-Source: AGs4zMZo4QL5q99n2zEL4J4zizXP4Bo0hD52xgefv16Gtc/aVsOmPC86ByVOzK+Orl3qVYkXrrH9 X-Received: by 10.84.244.2 with SMTP id g2mr2408030pll.170.1512044122420; Thu, 30 Nov 2017 04:15:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512044122; cv=none; d=google.com; s=arc-20160816; b=Ro9kwonrYI5qcMDNCZMNHFF9Ly7qkbT2G/7AMV6i4MaT+G/jmfrvoIlxZS7xTlSvQt XCqV8rL696WGr7R10a+MGw7IQHJxQ3w7FpcvbALmIpYIzk8XCF72m8ZuwIQWrhCYAhGI QQKl4YNkkkICXM4ZFpeNjci6ktjbaoEdAo+2SQ/vkz15eOn97wjppyKhjL8iq+GgMhHF 7rFEh4BMI9d857TJ6ETOHxc4dqXH3TRw9qd5Xm0EV3eXWlsbnIspriQnoVdJhslcSMQf AyUI0Jg1hPfA7WsZSx/wxVoqom6ZaTRpyqHf5iLyOEhlKdj8nlrEIGwL6yyLHR+SYV5B UM/Q== 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 :arc-authentication-results; bh=4WbKMDWZrIZPj6qtBoItcwYihVI274D1bIDm00RyMRc=; b=BqB9yBt21iPtqIbjs4Wop2VkXGriASOs1ei4loAk2+7lJ7tSG2sFnd+M4+imxW9lWG scDmyQc8tUeGcEM5krqaSXPHL6xIQ5wLrdhig10+GqV5yB9PyoEFrvBJdaf2lDGB/79k mDE0pwsRu4Ab7fFW6EvUvC1LgiOdlu54wfBJv9wmrw8QhGcKZcnNeA7pd/tErf7Zrj0+ aCGSVEsGEB6b2s22Pj+4OITP30cmrA3sbjhG3+vYGKuU/3RJmXQX/cQLwkgpjD+RwsGW U0luc6Wdj3oRQtgWEoJxcXBnX/+zh/26UnXsJA1zpKCa54I44XYQcMv1vT9Q9hfpi0xE G7Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=aQ5dSpZv; 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; 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 v31si3048982plg.274.2017.11.30.04.15.21; Thu, 30 Nov 2017 04:15:22 -0800 (PST) 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; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=aQ5dSpZv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751701AbdK3MPT (ORCPT + 11 others); Thu, 30 Nov 2017 07:15:19 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:45979 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752423AbdK3MPP (ORCPT ); Thu, 30 Nov 2017 07:15:15 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20171130121513euoutp0182826104e9c08ebe91ffb80782b401ca~73Bwounei0774307743euoutp01D; Thu, 30 Nov 2017 12:15:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20171130121513euoutp0182826104e9c08ebe91ffb80782b401ca~73Bwounei0774307743euoutp01D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1512044113; bh=4WbKMDWZrIZPj6qtBoItcwYihVI274D1bIDm00RyMRc=; h=From:To:Cc:Subject:Date:References:From; b=aQ5dSpZvTEaOGyE88GRuU+qhqxp0QBuBlWqMPclpodhzG1B4sHVkhONJISpFUAEGI REsZDgqsq7CEUtU7W3NLLUAQP+HDWNCbRJTVW3DtxwuPLdYcPj4d1DfobUkosFNELN n7fOGjUCMeoghUBT5Ii/KtfeXIEXGOkFLBMJVAJw= Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171130121512eucas1p18c32237bcb74cc7a611a976c1661b96b~73BwDCwM92873728737eucas1p1m; Thu, 30 Nov 2017 12:15:12 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3.samsung.com (EUCPMTA) with SMTP id 96.23.12867.056FF1A5; Thu, 30 Nov 2017 12:15:12 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171130121511eucas1p1832c1f6e5bc9e263860e40478efca132~73BvPtAYc2798227982eucas1p1K; Thu, 30 Nov 2017 12:15:11 +0000 (GMT) X-AuditID: cbfec7f2-f793b6d000003243-46-5a1ff650523b Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 51.E6.18832.F46FF1A5; Thu, 30 Nov 2017 12:15: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 <0P08001RRCP62Z90@eusync4.samsung.com>; Thu, 30 Nov 2017 12:15:11 +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 , Bartlomiej Zolnierkiewicz Subject: [PATCH] clk: Manage proper runtime PM state in clk_change_rate() Date: Thu, 30 Nov 2017 13:14:51 +0100 Message-id: <20171130121451.6710-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.15.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGIsWRmVeSWpSXmKPExsWy7djPc7oB3+SjDE60yVtsnLGe1eL6l+es FpseX2O1+Nhzj9Xic+8RRosZ5/cxWaw9cpfd4uIpV4vDb9pZLX6c6WaxOL423IHb4/2NVnaP y329TB53ru1h89i8pN6jb8sqRo/Pm+QC2KK4bFJSczLLUov07RK4Mhr3JBV8F63Y9OUuWwPj aaEuRk4OCQETiSXLVjND2GISF+6tZ+ti5OIQEljKKLF+8y1WCOczo8TBaZeYYDq2ztrIDpFY xigxdccNFpCEkEADk8SN26kgNpuAoUTX2y6wUSICTYwSEzesBxvFLLCDSeLMumdACzk4hAU8 JTZe9ANpYBFQlXhzvwFsEK+AjcTUzfdZIbbJSyz+vhNskITADDaJH+t3sEEkXCTerF3BDmEL S7w6vgXKlpHo7DgIdWo/o0RTqzaEPYNR4txbXgjbWuLw8YtgC5gF+CQmbZsOdo+EAK9ERxs0 XDwk3l6dBg0XR4lfl9ewQTwZK/Hk2WLGCYxSCxgZVjGKpJYW56anFhvrFSfmFpfmpesl5+du YgTG7ul/xz/tYPx6wuoQowAHoxIP7w01+Sgh1sSy4srcQ4wSHMxKIrzKJ4BCvCmJlVWpRfnx RaU5qcWHGKU5WJTEeW2j2iKFBNITS1KzU1MLUotgskwcnFINjItjzk5W2ZdZ862jTE7jrS6j m4anprzm3XvrjAtLj/S9L7SJYirclsIcxW3yW2DH25Oftj6tmv6Qd8L3mQcm33rOOkWh9C/H 3eLpIa/m5ntu8uppkEtjn7OY17/Ffltr0nZVzV1eMsrCx4ID5as/zeMrmOW1QeC5ctr/f0Xn bRSX7dJoPG9uqsRSnJFoqMVcVJwIAJAlNVbZAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprILMWRmVeSWpSXmKPExsVy+t/xa7r+3+SjDPZdMrPYOGM9q8X1L89Z LTY9vsZq8bHnHqvF594jjBYzzu9jslh75C67xcVTrhaH37SzWvw4081icXxtuAO3x/sbrewe l/t6mTzuXNvD5rF5Sb1H35ZVjB6fN8kFsEVx2aSk5mSWpRbp2yVwZTTuSSr4Llqx6ctdtgbG 00JdjJwcEgImEltnbWSHsMUkLtxbz9bFyMUhJLCEUWJmax8rhNPEJPFv9j9WkCo2AUOJrrdd YFUiAk2MEk/6prGDOMwCe5gkPq9+y9zFyMEhLOApsfGiH0gDi4CqxJv7DSwgNq+AjcTUzfdZ IdbJSyz+vpNtAiP3AkaGVYwiqaXFuem5xYZ6xYm5xaV56XrJ+bmbGIEBte3Yz807GC9tDD7E KMDBqMTDe0NNPkqINbGsuDL3EKMEB7OSCK/yCaAQb0piZVVqUX58UWlOavEhRmkOFiVx3t49 qyOFBNITS1KzU1MLUotgskwcnFINjBJdPq9jzgb8F1P5U71m0vbKGb/Xmj6oFvC04uCYrdnW J2VbxHPtkrr8tNilLR0zNqqrRJ5/Zl9r3a4upTMj7fL/9rDe5ZHv9m5LyN4ULKtpuz5t14vm r7PapHlfNMjdUdBUXn+n7Gvxa4X9jA0SYtP+c2cFbHVarTjruItFoGyi9brtW4NSlFiKMxIN tZiLihMBFSKctiQCAAA= X-CMS-MailID: 20171130121511eucas1p1832c1f6e5bc9e263860e40478efca132 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20171130121511eucas1p1832c1f6e5bc9e263860e40478efca132 X-RootMTR: 20171130121511eucas1p1832c1f6e5bc9e263860e40478efca132 References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org clk_change_rate() propagates rate change down to all its children. Such operation requires managing proper runtime PM state of each child, what was missing. Add needed calls to clk_pm_runtime*() to ensure that set_rate() clock callback is called on runtime active clock. This fixes following issue found on Exynos5433 TM2 board with devfreq enabled: Synchronous External Abort: synchronous external abort (0x96000210) at 0xffffff80093f5600 Internal error: : 96000210 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 5 Comm: kworker/u16:0 Not tainted 4.15.0-rc1-next-20171129+ #4 Hardware name: Samsung TM2 board (DT) Workqueue: devfreq_wq devfreq_monitor task: ffffffc0ca96b600 task.stack: ffffff80093a8000 pstate: a0000085 (NzCv daIf -PAN -UAO) pc : clk_divider_set_rate+0x54/0x118 lr : clk_divider_set_rate+0x44/0x118 ... Process kworker/u16:0 (pid: 5, stack limit = 0xffffff80093a8000) Call trace: clk_divider_set_rate+0x54/0x118 clk_change_rate+0xfc/0x4e0 clk_change_rate+0x1f0/0x4e0 clk_change_rate+0x1f0/0x4e0 clk_change_rate+0x1f0/0x4e0 clk_core_set_rate_nolock+0x138/0x148 clk_set_rate+0x28/0x50 exynos_bus_passive_target+0x6c/0x11c update_devfreq_passive+0x58/0xb4 devfreq_passive_notifier_call+0x50/0x5c notifier_call_chain+0x4c/0x88 __srcu_notifier_call_chain+0x54/0x80 srcu_notifier_call_chain+0x14/0x1c update_devfreq+0x100/0x1b4 devfreq_monitor+0x2c/0x88 process_one_work+0x148/0x3d8 worker_thread+0x13c/0x3f8 kthread+0x100/0x12c ret_from_fork+0x10/0x18 Reported-by: Chanwoo Choi Fixes: 9a34b45397e5 ("clk: Add support for runtime PM") Signed-off-by: Marek Szyprowski --- For some unknown reason handling of this case was missing in the initial patch, which added runtime PM support for clock core. Even tests in linux-next did not revealed this issue. This patch finaly fixes it, as it is now easy to trigger it with v4.15-rc1. Best regards Marek Szyprowski Samsung R&D Institute Poland --- drivers/clk/clk.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.15.0 Tested-by: Chanwoo Choi Reviewed-by: Chanwoo Choi diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 647d056df88c..8a1860a36c77 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1564,6 +1564,9 @@ static void clk_change_rate(struct clk_core *core) best_parent_rate = core->parent->rate; } + if (clk_pm_runtime_get(core)) + return; + if (core->flags & CLK_SET_RATE_UNGATE) { unsigned long flags; @@ -1634,6 +1637,8 @@ static void clk_change_rate(struct clk_core *core) /* handle the new child who might not be in core->children yet */ if (core->new_child) clk_change_rate(core->new_child); + + clk_pm_runtime_put(core); } static int clk_core_set_rate_nolock(struct clk_core *core,