From patchwork Fri Jan 26 09:18:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 10185355 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6D7AE60383 for ; Fri, 26 Jan 2018 09:19:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66AC32914A for ; Fri, 26 Jan 2018 09:19:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B2202914C; Fri, 26 Jan 2018 09:19:14 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham 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 C1E362914A for ; Fri, 26 Jan 2018 09:19:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752698AbeAZJTL (ORCPT ); Fri, 26 Jan 2018 04:19:11 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:58751 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752521AbeAZJTG (ORCPT ); Fri, 26 Jan 2018 04:19:06 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180126091903euoutp02177ac5f0b01a1adcdf77b777f025536c~NUZOalZK41100311003euoutp02d; Fri, 26 Jan 2018 09:19:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180126091903euoutp02177ac5f0b01a1adcdf77b777f025536c~NUZOalZK41100311003euoutp02d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1516958343; bh=Icaf2vtkap3poBECF0MRfj1ymhp8HB28VBZekoF7JfM=; h=From:To:Cc:Subject:Date:References:From; b=Sh1DuW41ygnPmHzWEHlE9qz7vGxfKV2WmNVuQ55jy7oPPIGszMhsrVBEiJizm2W7+ ZJzKmtD0MKzSohjfUqJocJhnxIOu2bRoisHsEWXV0WHT4LbGmOgivaGdFohFpSAEai dAmuX94Z6tsTZ+iiQS44EaMkPsaIZ8cl9Jki0sik= Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180126091903eucas1p1c26ef3e00e6938a2e2e617c6907696d7~NUZNp8iTD1561315613eucas1p1Z; Fri, 26 Jan 2018 09:19:03 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2.samsung.com (EUCPMTA) with SMTP id BE.1B.12907.682FA6A5; Fri, 26 Jan 2018 09:19:02 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180126091902eucas1p2b3ad9978e3ab09bd7a2bd9123c9eecaa~NUZM-MaIV1569315693eucas1p2K; Fri, 26 Jan 2018 09:19:02 +0000 (GMT) X-AuditID: cbfec7f1-f793a6d00000326b-f3-5a6af286d12a Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id DF.A0.20118.682FA6A5; Fri, 26 Jan 2018 09:19:02 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P35009YOOJJF5A0@eusync3.samsung.com>; Fri, 26 Jan 2018 09:19:02 +0000 (GMT) From: Marek Szyprowski To: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Marek Szyprowski , Stephen Boyd , Michael Turquette , Shawn Guo , Dong Aisheng , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski Subject: [PATCH v2] clk: Properly update prepare/enable count on orphan clock reparent Date: Fri, 26 Jan 2018 10:18:45 +0100 Message-id: <20180126091845.11902-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.15.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHIsWRmVeSWpSXmKPExsWy7djPc7ptn7KiDJ69NrT4MnUXs8XGGetZ Lc6f38BusenxNVaLjz33WC3WHrnLbnHxlKvFjzPdLBYvtog7cHq8v9HK7nG5r5fJY9OqTjaP zUvqPTa+28Hk0bdlFaPH501yAexRXDYpqTmZZalF+nYJXBm7PvxhL+hWr2g4/oWtgbFJqYuR k0NCwETi2aNuZghbTOLCvfVsXYxcHEICSxkl+o+vZoZwPjNKfDu0mQ2mY0vLHFYQW0hgGaNE 6wYhiKIGJokTW4+zgCTYBAwlut52gTWICDhLPG77BzaJWWANk8TLf6vBEsICERIdV24ygdgs AqoSW4//A7I5OHgFbCW23XOGWCYvsfj7TqjFE9gkGtd7QNguEq1LN0LFhSVeHd/CDmHLSFye 3M0CYfczSjS1akPYMxglzr3lhbCtJQ4fvwj2ALMAn8SkbdOZQdZKCPBKdLQJQZgeEi1HsyBM R4nV/80hvo2V2PZwAvMERqkFjAyrGEVSS4tz01OLjfSKE3OLS/PS9ZLzczcxAmP19L/jH3cw vj9hdYhRgINRiYf3xu3MKCHWxLLiytxDjBIczEoivIK6WVFCvCmJlVWpRfnxRaU5qcWHGKU5 WJTEeW2j2iKFBNITS1KzU1MLUotgskwcnFINjIUmuTU+9wWPrWQxkn9mOelvXdTf8P8CGiUl /113tDQZTdry4PLjx0Kz527YfztxauPKguvly7XkRIqYPCZYM9ho8zsJvn+b2iqh+W3NuYSe D38F1Lhv7/NQOnjTwa05TLFn44mYqsrLTww9bJ290sLmhYZ/3tJ4NuIAB+NSpagNYdFLJKaL K7EUZyQaajEXFScCAB9T88nRAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmluLIzCtJLcpLzFFi42I5/e/4Vd22T1lRBqsniVh8mbqL2WLjjPWs FufPb2C32PT4GqvFx557rBZrj9xlt7h4ytXix5luFosXW8QdOD3e32hl97jc18vksWlVJ5vH 5iX1Hhvf7WDy6NuyitHj8ya5APYoLpuU1JzMstQifbsEroxdH/6wF3SrVzQc/8LWwNik1MXI ySEhYCKxpWUOK4QtJnHh3nq2LkYuDiGBJYwSDy42MEE4TUwSn993s4FUsQkYSnS97QKzRQSc JR63/WMGKWIWWMck0bx5J1CCg0NYIELi9gFlkBoWAVWJrcf/MYGEeQVsJbbdc4ZYJi+x+PtO tgmM3AsYGVYxiqSWFuem5xYb6RUn5haX5qXrJefnbmIEBtG2Yz+37GDsehd8iFGAg1GJh/fG 7cwoIdbEsuLK3EOMEhzMSiK8grpZUUK8KYmVValF+fFFpTmpxYcYpTlYlMR5e/esjhQSSE8s Sc1OTS1ILYLJMnFwSjUwSn33OPzvDDcv14mOWTPY4+w/iLUzrjU3K7M63mg356MXv//JB3ZP 2O7MlMgzq0qx2P/wGPu++Y+flWUs5bo+xfHnUr/jKp03JGwfHq4P5Zrq8WI2W13RBc2Nnm/b nG5t0VgYYGUYwDnlx7mYKX1sWsK6bZes3hhm/Xk2O3jzpMPaU7ODJCULlViKMxINtZiLihMB LDEc+B4CAAA= X-CMS-MailID: 20180126091902eucas1p2b3ad9978e3ab09bd7a2bd9123c9eecaa X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180126091902eucas1p2b3ad9978e3ab09bd7a2bd9123c9eecaa X-RootMTR: 20180126091902eucas1p2b3ad9978e3ab09bd7a2bd9123c9eecaa 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 If orphaned clock has been already prepared/enabled (for example if it or one of its children has CLK_IS_CRITICAL flag), then the prepare/enable counters of the newly assigned parent are not updated correctly. This might later cause warnings during changing clock parents. This patch fixes following warning on Exynos5422-based boards: ------------[ cut here ]------------ WARNING: CPU: 0 PID: 59 at drivers/clk/clk.c:811 clk_core_disable_lock+0x18/0x24 Modules linked in: CPU: 0 PID: 59 Comm: kworker/0:1 Not tainted 4.15.0-rc7-next-20180115 #106 Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) Workqueue: pm genpd_power_off_work_fn [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0x90/0xc8) [] (dump_stack) from [] (__warn+0xe4/0x110) [] (__warn) from [] (warn_slowpath_null+0x40/0x48) [] (warn_slowpath_null) from [] (clk_core_disable_lock+0x18/0x24) [] (clk_core_disable_lock) from [] (clk_core_disable_unprepare+0xc/0x20) [] (clk_core_disable_unprepare) from [] (__clk_set_parent_after+0x48/0x4c) [] (__clk_set_parent_after) from [] (clk_core_set_parent_nolock+0x224/0x5b4) [] (clk_core_set_parent_nolock) from [] (clk_set_parent+0x38/0x6c) [] (clk_set_parent) from [] (exynos_pd_power+0x74/0x1cc) [] (exynos_pd_power) from [] (genpd_power_off+0x164/0x264) [] (genpd_power_off) from [] (genpd_power_off_work_fn+0x2c/0x40) [] (genpd_power_off_work_fn) from [] (process_one_work+0x1d0/0x7bc) [] (process_one_work) from [] (worker_thread+0x34/0x4dc) [] (worker_thread) from [] (kthread+0x128/0x164) [] (kthread) from [] (ret_from_fork+0x14/0x20) Exception stack(0xeeb01fb0 to 0xeeb01ff8) 1fa0: 00000000 00000000 00000000 00000000 1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 1fe0: 00000000 00000000 00000000 00000000 00000013 00000000 ---[ end trace 503c239fb760f17a ]--- ------------[ cut here ]------------ WARNING: CPU: 0 PID: 59 at drivers/clk/clk.c:684 clk_core_disable_unprepare+0x18/0x20 Modules linked in: CPU: 0 PID: 59 Comm: kworker/0:1 Tainted: G W 4.15.0-rc7-next-20180115 #106 Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) Workqueue: pm genpd_power_off_work_fn [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (dump_stack+0x90/0xc8) [] (dump_stack) from [] (__warn+0xe4/0x110) [] (__warn) from [] (warn_slowpath_null+0x40/0x48) [] (warn_slowpath_null) from [] (clk_core_disable_unprepare+0x18/0x20) [] (clk_core_disable_unprepare) from [] (__clk_set_parent_after+0x48/0x4c) [] (__clk_set_parent_after) from [] (clk_core_set_parent_nolock+0x224/0x5b4) [] (clk_core_set_parent_nolock) from [] (clk_set_parent+0x38/0x6c) [] (clk_set_parent) from [] (exynos_pd_power+0x74/0x1cc) [] (exynos_pd_power) from [] (genpd_power_off+0x164/0x264) [] (genpd_power_off) from [] (genpd_power_off_work_fn+0x2c/0x40) [] (genpd_power_off_work_fn) from [] (process_one_work+0x1d0/0x7bc) [] (process_one_work) from [] (worker_thread+0x34/0x4dc) [] (worker_thread) from [] (kthread+0x128/0x164) [] (kthread) from [] (ret_from_fork+0x14/0x20) Exception stack(0xeeb01fb0 to 0xeeb01ff8) 1fa0: 00000000 00000000 00000000 00000000 1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 1fe0: 00000000 00000000 00000000 00000000 00000013 00000000 ---[ end trace 503c239fb760f17b ]--- ------------[ cut here ]------------ Fixes: f8f8f1d04494 ("clk: Don't touch hardware when reparenting during registration") Signed-off-by: Marek Szyprowski --- v2: - moved clk_core_prepare(parent) before clk_enable_lock() to avoid calling it under a spinlock --- drivers/clk/clk.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 0f686a9dac3e..a14d64fa6a28 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2981,7 +2981,11 @@ static int __clk_core_init(struct clk_core *core) */ if (parent) { /* update the clk tree topology */ + if (orphan->prepare_count) + clk_core_prepare(parent); flags = clk_enable_lock(); + if (orphan->enable_count) + clk_core_enable(parent); clk_reparent(orphan, parent); clk_enable_unlock(flags); __clk_recalc_accuracies(orphan);