clk: disable unused clk if enable_count == 0
PATCH 1/1 clk: disable unused clk if enable_count == 0
If .is_enabled callback is not implemented, clk_core_is_enabled will take software enable_count as enable status. If enable_count is zero, .disable will not be called as software assume clock is not enabled though clock may be booted with free running state. Disable the clock in this situation.
--- drivers/clk/clk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk.c +1 -1
@@ -220,7 +220,7 @@ static void clk_disable_unused_subtree(struct clk_core *core)* sequence. call .disable_unused if available, otherwise fall * back to .disable */ -if (clk_core_is_enabled (core)) { +if (clk_core_is_enabled (core) || !clk->enable_count) {trace_clk_disable (core);if (core->ops->disable_unused) core->ops->disable_unused (core->hw);
Signature · 1 line
1.9.1
Quoted 8 lines · Jun Nie
If .is_enabled callback is not implemented,
clk_core_is_enabledwill take softwareenable_countas enable status. Ifenable_countis zero, .disable will not be called as software assume clock is not enabled though clock may be booted with free running state. Disable the clock in this situation.Signed-off-by Jun Nie <[email protected]>---
Why not implement the is_enabled callback then?
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
2016-04-08 8:14 GMT+08:00 Stephen Boyd <[email protected]>:
Quoted 11 lines · Jun Nie
Quoted 8 lines
If .is_enabled callback is not implemented,
clk_core_is_enabledwill take softwareenable_countas enable status. Ifenable_countis zero, .disable will not be called as software assume clock is not enabled though clock may be booted with free running state. Disable the clock in this situation.Signed-off-by Jun Nie <[email protected]>---
Why not implement the
is_enabledcallback then?
The is_enabled callback is not mandatory according to sanity check code, so there is risk that some clock is not gated even we have called clk_disable_unused_subtree. If is_enabled callback is mandatory when CLK_IGNORE_UNUSED is not set, Adding a sanity check will fill this gap.
Jun
Quoted 5 lines
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 11 lines · Jun Nie
2016-04-08 8:14 GMT+08:00 Stephen Boyd <[email protected]>:
Quoted 10 lines · Jun Nie
Quoted 8 lines
If .is_enabled callback is not implemented,
clk_core_is_enabledwill take softwareenable_countas enable status. Ifenable_countis zero, .disable will not be called as software assume clock is not enabled though clock may be booted with free running state. Disable the clock in this situation.Signed-off-by Jun Nie <[email protected]>---
Quoted 7 lines
Quoted 1 line
Why not implement the
is_enabledcallback then?The
is_enabledcallback is not mandatory according to sanity check code, so there is risk that some clock is not gated even we have calledclk_disable_unused_subtree. Ifis_enabledcallback is mandatory whenCLK_IGNORE_UNUSEDis not set, Adding a sanity check will fill this gap.
The is_enabled op is technically mandatory if enable/disable ops are implemented. We could add a sanity check, but I would guess it will warn quite a bit because not everyone is following the documentation.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project