Skip to content

Commit 35b0fac

Browse files
wensbebarino
authored andcommitted
clk: core: Honor CLK_OPS_PARENT_ENABLE for clk gate ops
In the previous commits that added CLK_OPS_PARENT_ENABLE, support for this flag was only added to rate change operations (rate setting and reparent) and disabling unused subtree. It was not added to the clock gate related operations. Any hardware driver that needs it for these operations will either see bogus results, or worse, hang. This has been seen on MT8192 and MT8195, where the imp_ii2_* clk drivers set this, but dumping debugfs clk_summary would cause it to hang. Fixes: fc8726a ("clk: core: support clocks which requires parents enable (part 2)") Fixes: a4b3518 ("clk: core: support clocks which requires parents enable (part 1)") Signed-off-by: Chen-Yu Tsai <wenst@chromium.org> Reviewed-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Tested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Link: https://lore.kernel.org/r/20220822081424.1310926-2-wenst@chromium.org Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 26f2da0 commit 35b0fac

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

drivers/clk/clk.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ static bool clk_core_rate_is_protected(struct clk_core *core)
196196
return core->protect_count;
197197
}
198198

199+
static int clk_core_prepare_enable(struct clk_core *core);
200+
static void clk_core_disable_unprepare(struct clk_core *core);
201+
199202
static bool clk_core_is_prepared(struct clk_core *core)
200203
{
201204
bool ret = false;
@@ -208,7 +211,11 @@ static bool clk_core_is_prepared(struct clk_core *core)
208211
return core->prepare_count;
209212

210213
if (!clk_pm_runtime_get(core)) {
214+
if (core->flags & CLK_OPS_PARENT_ENABLE)
215+
clk_core_prepare_enable(core->parent);
211216
ret = core->ops->is_prepared(core->hw);
217+
if (core->flags & CLK_OPS_PARENT_ENABLE)
218+
clk_core_disable_unprepare(core->parent);
212219
clk_pm_runtime_put(core);
213220
}
214221

@@ -244,7 +251,13 @@ static bool clk_core_is_enabled(struct clk_core *core)
244251
}
245252
}
246253

254+
if (core->flags & CLK_OPS_PARENT_ENABLE)
255+
clk_core_prepare_enable(core->parent);
256+
247257
ret = core->ops->is_enabled(core->hw);
258+
259+
if (core->flags & CLK_OPS_PARENT_ENABLE)
260+
clk_core_disable_unprepare(core->parent);
248261
done:
249262
if (core->rpm_enabled)
250263
pm_runtime_put(core->dev);
@@ -812,6 +825,9 @@ int clk_rate_exclusive_get(struct clk *clk)
812825
}
813826
EXPORT_SYMBOL_GPL(clk_rate_exclusive_get);
814827

828+
static int clk_core_enable_lock(struct clk_core *core);
829+
static void clk_core_disable_lock(struct clk_core *core);
830+
815831
static void clk_core_unprepare(struct clk_core *core)
816832
{
817833
lockdep_assert_held(&prepare_lock);
@@ -835,6 +851,9 @@ static void clk_core_unprepare(struct clk_core *core)
835851

836852
WARN(core->enable_count > 0, "Unpreparing enabled %s\n", core->name);
837853

854+
if (core->flags & CLK_OPS_PARENT_ENABLE)
855+
clk_core_enable_lock(core->parent);
856+
838857
trace_clk_unprepare(core);
839858

840859
if (core->ops->unprepare)
@@ -843,6 +862,9 @@ static void clk_core_unprepare(struct clk_core *core)
843862
clk_pm_runtime_put(core);
844863

845864
trace_clk_unprepare_complete(core);
865+
866+
if (core->flags & CLK_OPS_PARENT_ENABLE)
867+
clk_core_disable_lock(core->parent);
846868
clk_core_unprepare(core->parent);
847869
}
848870

@@ -891,13 +913,19 @@ static int clk_core_prepare(struct clk_core *core)
891913
if (ret)
892914
goto runtime_put;
893915

916+
if (core->flags & CLK_OPS_PARENT_ENABLE)
917+
clk_core_enable_lock(core->parent);
918+
894919
trace_clk_prepare(core);
895920

896921
if (core->ops->prepare)
897922
ret = core->ops->prepare(core->hw);
898923

899924
trace_clk_prepare_complete(core);
900925

926+
if (core->flags & CLK_OPS_PARENT_ENABLE)
927+
clk_core_disable_lock(core->parent);
928+
901929
if (ret)
902930
goto unprepare;
903931
}

0 commit comments

Comments
 (0)