Skip to content

Commit 6699176

Browse files
Nicolas Frattarolibebarino
authored andcommitted
clk: Respect CLK_OPS_PARENT_ENABLE during recalc
When CLK_OPS_PARENT_ENABLE was introduced, it guarded various clock operations, such as setting the rate or switching parents. However, another operation that can and often does touch actual hardware state is recalc_rate, which may also be affected by such a dependency. Add parent enables/disables where the recalc_rate op is called directly. Fixes: fc8726a ("clk: core: support clocks which requires parents enable (part 2)") Fixes: a4b3518 ("clk: core: support clocks which requires parents enable (part 1)") Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent a2ed1ae commit 6699176

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

drivers/clk/clk.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,14 @@ static unsigned long clk_recalc(struct clk_core *core,
19211921
unsigned long rate = parent_rate;
19221922

19231923
if (core->ops->recalc_rate && !clk_pm_runtime_get(core)) {
1924+
if (core->flags & CLK_OPS_PARENT_ENABLE)
1925+
clk_core_prepare_enable(core->parent);
1926+
19241927
rate = core->ops->recalc_rate(core->hw, parent_rate);
1928+
1929+
if (core->flags & CLK_OPS_PARENT_ENABLE)
1930+
clk_core_disable_unprepare(core->parent);
1931+
19251932
clk_pm_runtime_put(core);
19261933
}
19271934
return rate;
@@ -4031,6 +4038,9 @@ static int __clk_core_init(struct clk_core *core)
40314038
*/
40324039
clk_core_update_duty_cycle_nolock(core);
40334040

4041+
if (core->flags & CLK_OPS_PARENT_ENABLE)
4042+
clk_core_prepare_enable(core->parent);
4043+
40344044
/*
40354045
* Set clk's rate. The preferred method is to use .recalc_rate. For
40364046
* simple clocks and lazy developers the default fallback is to use the
@@ -4046,6 +4056,9 @@ static int __clk_core_init(struct clk_core *core)
40464056
rate = 0;
40474057
core->rate = core->req_rate = rate;
40484058

4059+
if (core->flags & CLK_OPS_PARENT_ENABLE)
4060+
clk_core_disable_unprepare(core->parent);
4061+
40494062
/*
40504063
* Enable CLK_IS_CRITICAL clocks so newly added critical clocks
40514064
* don't get accidentally disabled when walking the orphan tree and

0 commit comments

Comments
 (0)