Skip to contentSkip to conversation

clk: disable unused clk if enable_count == 0

PATCH In review Jun Nie 2 participants 4 messages Apr 7, 2016 – Apr 14, 2016 Common clk

lore
Share & tools
lore

Jun Nie

author
#0 lore raw

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
index b4db67a..49c5934 100644
@@ -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
#1 lore raw
Quoted 8 lines · Jun Nie

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.

---

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
author
#2 lore raw

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_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.

---

Why not implement the is_enabled callback 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

#3 lore raw
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_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.

---

Quoted 7 lines
Quoted 1 line

Why not implement the is_enabled callback 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.

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