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: 10163597 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 C8B68601C0 for ; Mon, 15 Jan 2018 11:53:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6BE520408 for ; Mon, 15 Jan 2018 11:53:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABB6528884; Mon, 15 Jan 2018 11:53:00 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 419BF20408 for ; Mon, 15 Jan 2018 11:53:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: Message-id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:List-Owner; bh=qC6k1vJF9XW9WbB2TBzjtM0zjyHPNw180hD9a8gUgew=; b=oE k+zJXwHMOXKJbf2w0Rau+9nxbMo3D1vYaVrNJgbOyAFsjiBLvO3LuIkebLBax4YtLwykPPcKzZL2s 9WMlEk4WF7jTgeoCsrWsX1nqeRkNlZCoFPUoWldEpeqhpk/yZHOea6q5ilUG0+Wu53FGX6kZLb4wG POdCLZa/GyHV9NI9F9jgwK6LaQoG7XvFPnqAS/js+coQlPszFjbeWCvDAk4ZKVCLiND0ubqra1o4r lb9CAZWSaYeJTu4sri2YdKtfOPjjsqabEHSzXNKYJmWzKTB45WA2sl9uaOYLr2G3hduJK6AvUEmXA tyo6JJ9pAuqTOXGtDj/bDZ6+33eysc8A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eb3Jy-00084q-Ec; Mon, 15 Jan 2018 11:52:58 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eb3Jt-0007p3-Di for linux-arm-kernel@lists.infradead.org; Mon, 15 Jan 2018 11:52:56 +0000 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 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+LxJLoA9issmJTUns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XmLx951sExi5 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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180115_035253_769426_2226704C X-CRM114-Status: GOOD ( 15.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dong Aisheng , Bartlomiej Zolnierkiewicz , Michael Turquette , Stephen Boyd , Shawn Guo , Marek Szyprowski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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);