From patchwork Mon Jan 15 11:52:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 10163595 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 7FAA9601C0 for ; Mon, 15 Jan 2018 11:52:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FED220408 for ; Mon, 15 Jan 2018 11:52:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 648DE28884; Mon, 15 Jan 2018 11:52:38 +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 3672520408 for ; Mon, 15 Jan 2018 11:52:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753745AbeAOLwg (ORCPT ); Mon, 15 Jan 2018 06:52:36 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:58915 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751317AbeAOLwf (ORCPT ); Mon, 15 Jan 2018 06:52:35 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180115115233euoutp021f942278414d8b55f50e1c4e5b569c39~J_ZGlFgwG1187811878euoutp02_; Mon, 15 Jan 2018 11:52:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180115115233euoutp021f942278414d8b55f50e1c4e5b569c39~J_ZGlFgwG1187811878euoutp02_ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1516017153; bh=ZSt5fDqjTJmhbXlNfb4TpO9JemsUabbq0AlG07g7FMY=; h=From:To:Cc:Subject:Date:References:From; b=IzErAK/xRaA1N9/varwAxuspMtJskYKn+aA/gtdPVTyumX0k6zYQM/mfcR5iGc0JD asyBP9avk/PcerjtKf8zTjZ9YVMh08Jf98Nw1Kfa8/1IWxz2976h9VGbQEZKd+SW8e 0olMdQVbxrFWmye168MnuwuypPfnN5x+Rz6QCHIY= Received: from eusmges3.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180115115232eucas1p25bc7be1132715ba3c808cff87469dffa~J_ZFv6IfE2367023670eucas1p2t; Mon, 15 Jan 2018 11:52:32 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3.samsung.com (EUCPMTA) with SMTP id 12.08.12867.0069C5A5; Mon, 15 Jan 2018 11:52:32 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180115115231eucas1p1499f46ca64b65598d03a182ed5670f28~J_ZE1aw8a2027420274eucas1p1F; Mon, 15 Jan 2018 11:52:31 +0000 (GMT) X-AuditID: cbfec7f2-f793b6d000003243-02-5a5c960089b8 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id E3.BB.20118.FF59C5A5; Mon, 15 Jan 2018 11:52:31 +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 <0P2L00FGAIBG8OD0@eusync1.samsung.com>; Mon, 15 Jan 2018 11:52:31 +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 Subject: [PATCH] clk: Properly update prepare/enable count on orphan clock reparent Date: Mon, 15 Jan 2018 12:52:14 +0100 Message-id: <20180115115214.10303-1-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.15.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBIsWRmVeSWpSXmKPExsWy7djP87oM02KiDB4eFbD4MnUXs8XGGetZ LTY9vsZq8bHnHqvF2iN32S0unnK1+HGmm8XixRZxBw6P9zda2T0u9/UyeWxa1cnmsXlJvcfG dzuYPPq2rGL0+LxJLoA9issmJTUnsyy1SN8ugStjUfdJ9oJpahWrVlY2MC5X7GJk55AQMJHY X9vFyAlkiUlcuLeerYuRi0NIYCmjxLZXM5lAEkICnxklNq416mLkACv/cFsSIryMUWL+n0yI +gYmiSdX5jKDJNgEDCW63naxgdgiAs4Sj9v+MYMUMQs0M0kcXj2LESQhLBAqceDHPXYQm0VA VWLdO4g4r4CtxIMFC9khLpKXWPx9J9hFEgI9bBJ/p+xjgUi4SGz6OY0RwhaWeHV8C1SDjMTl yd1QNf2MEk2t2hD2DEaJc295IWxricPHL7KC2MwCfBKTtk1nhviMV6KjTQiixEPi1LTnTBC2 o8S8tjuMEB/HSqy894xpAqPUAkaGVYwiqaXFuempxcZ6xYm5xaV56XrJ+bmbGIHxefrf8U87 GL+esDrEKMDBqMTDG7EsOkqINbGsuDL3EKMEB7OSCG9jcEyUEG9KYmVValF+fFFpTmrxIUZp DhYlcV7bqLZIIYH0xJLU7NTUgtQimCwTB6dUA6OjeeuGGrGf+jFap/6ZHbH9XevpWsrqd859 w5Wb8UvV3+U63tSIMtT6cfOfRX/W2mMtsm4RbdrlOREKdnn1D5zTAn1yLvub8JdpGL2X3X9k WW7dde5yiVsmJyadWiBuZn3KukVALiHmY+v2lt9xv4+oLPBVLQp63379Db+t3tZux1sfmRYf VmIpzkg01GIuKk4EABiFA0HLAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjluLIzCtJLcpLzFFi42I5/e/4Zd3/U2OiDPZMVbP4MnUXs8XGGetZ LTY9vsZq8bHnHqvF2iN32S0unnK1+HGmm8XixRZxBw6P9zda2T0u9/UyeWxa1cnmsXlJvcfG dzuYPPq2rGL0+LxJLoA9issmJTUnsyy1SN8ugStjUfdJ9oJpahWrVlY2MC5X7GLk4JAQMJH4 cFuyi5ETyBSTuHBvPVsXIxeHkMASRomfq44zQjhNTBIXJ35lBKliEzCU6HrbxQZiiwg4Szxu +8cMUsQs0MoksXZeI1iRsECoxIEf99hBbBYBVYl172aBxXkFbCUeLFjIDrFOXmLx951sExi5 FzAyrGIUSS0tzk3PLTbSK07MLS7NS9dLzs/dxAgMnW3Hfm7Zwdj1LvgQowAHoxIPb8Sy6Cgh 1sSy4srcQ4wSHMxKIryNwTFRQrwpiZVVqUX58UWlOanFhxilOViUxHl796yOFBJITyxJzU5N LUgtgskycXBKNTCufmU79U32guCvHy4o102/2XT4ENcTd5Za5+1n5xqX1Vkd9sq23V70/dFr LYNPyf8Xdp4UOG20I33js5ivS8yKTy7xMyz7frBJQXNW/pFXTZNT4z4WTVlsFzvbcb3r1nyl 7U5r376b0T9J6cPH0zI7c5zOeAge/La+Ppbr9/Yi5n5xjgv79kvuVmIpzkg01GIuKk4EAM5U tCcZAgAA X-CMS-MailID: 20180115115231eucas1p1499f46ca64b65598d03a182ed5670f28 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180115115231eucas1p1499f46ca64b65598d03a182ed5670f28 X-RootMTR: 20180115115231eucas1p1499f46ca64b65598d03a182ed5670f28 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 Tested-by: Krzysztof Kozlowski --- drivers/clk/clk.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 0f686a9dac3e..d33c087d7868 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2982,6 +2982,10 @@ static int __clk_core_init(struct clk_core *core) if (parent) { /* update the clk tree topology */ flags = clk_enable_lock(); + if (orphan->prepare_count) + clk_core_prepare(parent); + if (orphan->enable_count) + clk_core_enable(parent); clk_reparent(orphan, parent); clk_enable_unlock(flags); __clk_recalc_accuracies(orphan);