From mboxrd@z Thu Jan 1 00:00:00 1970 From: sboyd@codeaurora.org (Stephen Boyd) Date: Thu, 25 Jan 2018 14:19:26 -0800 Subject: [PATCH] clk: Properly update prepare/enable count on orphan clock reparent In-Reply-To: <20180115115214.10303-1-m.szyprowski@samsung.com> References: <20180115115214.10303-1-m.szyprowski@samsung.com> Message-ID: <20180125221926.GA28313@codeaurora.org> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 01/15, Marek Szyprowski wrote: > 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 > --- > 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(); This is the spinlock? > + if (orphan->prepare_count) > + clk_core_prepare(parent); And this is prepare mutex? Doesn't sound like it will work. > + if (orphan->enable_count) > + clk_core_enable(parent); This would be OK, but then we might touch the hardware again? -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project