Skip to contentSkip to conversation

clk: invoke clk_disable_unused() after resume

PATCH New Jim Quinlan 2 participants 2 messages Dec 18, 2014 Common clk

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: invoke clk_disable_unused() after resume

In a discussion[1], mturquette made the suggestion that

"It might be a good idea to call clk_disable_unused()
from the clk core after resuming from suspend."

This commit does exactly that. For Broadcom STB chips, clocks may come up after resume in an "on" state, so calling clk_disable_unused() again will turn off clocks that should be off.

[1] https://lkml.org/lkml/2014/11/17/666

---
 drivers/clk/clk.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/clk/clk.c +13 -3
index 4896ae9..d54d414 100644
@@ -21,6 +21,7 @@
 #include <linux/device.h>
 #include <linux/init.h>
 #include <linux/sched.h>
+#include <linux/syscore_ops.h>
 
 #include "clk.h"
 
@@ -500,13 +501,13 @@ static int __init clk_ignore_unused_setup(char *__unused)
 }
 __setup("clk_ignore_unused", clk_ignore_unused_setup);
 
-static int clk_disable_unused(void)
+static void clk_disable_unused(void)
 {
 	struct clk *clk;
 
 	if (clk_ignore_unused) {
 		pr_warn("clk: Not disabling unused clocks\n");
-		return 0;
+		return;
 	}
 
 	clk_prepare_lock();
@@ -524,10 +525,19 @@ static int clk_disable_unused(void)
 		clk_unprepare_unused_subtree(clk);
 
 	clk_prepare_unlock();
+}
 
+static struct syscore_ops disable_unused_ops = {
+	.resume = clk_disable_unused,
+};
+
+static int clk_init_disable_unused(void)
+{
+	clk_disable_unused();
+	register_syscore_ops(&disable_unused_ops);
 	return 0;
 }
-late_initcall_sync(clk_disable_unused);
+late_initcall_sync(clk_init_disable_unused);
 
 /***    helper functions   ***/
 
Signature · 1 line
1.9.0.138.g2de3478
#1 lore raw

PATCH 1/1 clk: invoke clk_disable_unused() after resume

Quoted 5 lines · Jim Quinlan

In a discussion[1], mturquette made the suggestion that

"It might be a good idea to call clk_disable_unused()
from the clk core after resuming from suspend."

Quoted 9 lines

This commit does exactly that. For Broadcom STB chips, clocks may come up after resume in an "on" state, so calling clk_disable_unused() again will turn off clocks that should be off.

[1] https://lkml.org/lkml/2014/11/17/666

It would be better to use the driver core or syscore suspend/resume hooks to restore the state of the clocks as they were when the system was suspended. Plus it would make more sense to do this on a case-by-case basis instead of assuming that all platforms have clocks that are left on out of resume. It could still be generic by exporting the clk_disable_unused() function to drivers so they can call it if they need to but I don't see why we want to force this on every platform for every suspend/resume cycle.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project