linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: invoke clk_disable_unused() after resume
@ 2014-12-18 22:18 Jim Quinlan
  2014-12-18 22:48 ` Stephen Boyd
  0 siblings, 1 reply; 2+ messages in thread
From: Jim Quinlan @ 2014-12-18 22:18 UTC (permalink / raw)
  To: linux-arm-kernel

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

Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
---
 drivers/clk/clk.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 4896ae9..d54d414 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -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   ***/
 
-- 
1.9.0.138.g2de3478

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] clk: invoke clk_disable_unused() after resume
  2014-12-18 22:18 [PATCH] clk: invoke clk_disable_unused() after resume Jim Quinlan
@ 2014-12-18 22:48 ` Stephen Boyd
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Boyd @ 2014-12-18 22:48 UTC (permalink / raw)
  To: linux-arm-kernel

On 12/18/2014 02:18 PM, Jim Quinlan wrote:
> 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
>
> Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
>

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.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-18 22:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-18 22:18 [PATCH] clk: invoke clk_disable_unused() after resume Jim Quinlan
2014-12-18 22:48 ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).