linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] cpufreq: try to resume policies which failed on last resume
@ 2013-12-24  1:41 Viresh Kumar
  2013-12-24  1:41 ` [PATCH 2/2] cpufreq: preserve user_policy across suspend/resume Viresh Kumar
  2013-12-26  1:05 ` [PATCH 1/2] cpufreq: try to resume policies which failed on last resume Rafael J. Wysocki
  0 siblings, 2 replies; 21+ messages in thread
From: Viresh Kumar @ 2013-12-24  1:41 UTC (permalink / raw)
  To: rjw
  Cc: linaro-kernel, patches, cpufreq, linux-pm, linux-kernel, bjorn,
	Viresh Kumar

__cpufreq_add_dev() can fail sometimes while we are resuming our system.
Currently we are clearing all sysfs nodes for cpufreq's failed policy as that
could make userspace unstable. But if we suspend/resume again, we should atleast
try to bring back those policies.

This patch fixes this issue by clearing fallback data on failure and trying to
allocate a new struct cpufreq_policy on second resume.

Reported-and-tested-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
These are sent again (earlier sent as reply to emails), so that people can
give inputs if they have any.

Tested on my thinkpad T420.

 drivers/cpufreq/cpufreq.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 16d7b4a..0a48e71 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1016,16 +1016,24 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
 	read_unlock_irqrestore(&cpufreq_driver_lock, flags);
 #endif
 
-	if (frozen)
+	if (frozen) {
 		/* Restore the saved policy when doing light-weight init */
 		policy = cpufreq_policy_restore(cpu);
-	else
+
+		/*
+		 * As we failed to resume cpufreq core last time, lets try to
+		 * create a new policy.
+		 */
+		if (!policy)
+			frozen = false;
+	}
+
+	if (!frozen)
 		policy = cpufreq_policy_alloc();
 
 	if (!policy)
 		goto nomem_out;
 
-
 	/*
 	 * In the resume path, since we restore a saved policy, the assignment
 	 * to policy->cpu is like an update of the existing policy, rather than
@@ -1118,8 +1126,14 @@ err_get_freq:
 	if (cpufreq_driver->exit)
 		cpufreq_driver->exit(policy);
 err_set_policy_cpu:
-	if (frozen)
+	if (frozen) {
+		/*
+		 * Clear fallback data as we should try to make things work on
+		 * next suspend/resume
+		 */
+		per_cpu(cpufreq_cpu_data_fallback, cpu) = NULL;
 		cpufreq_policy_put_kobj(policy);
+	}
 	cpufreq_policy_free(policy);
 
 nomem_out:
-- 
1.7.12.rc2.18.g61b472e


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

end of thread, other threads:[~2014-01-08  5:51 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-24  1:41 [PATCH 1/2] cpufreq: try to resume policies which failed on last resume Viresh Kumar
2013-12-24  1:41 ` [PATCH 2/2] cpufreq: preserve user_policy across suspend/resume Viresh Kumar
2013-12-26  1:05 ` [PATCH 1/2] cpufreq: try to resume policies which failed on last resume Rafael J. Wysocki
2013-12-26  2:47   ` Viresh Kumar
2013-12-27  9:57     ` Viresh Kumar
2013-12-27  9:58       ` Viresh Kumar
2013-12-30 16:40         ` Bjørn Mork
2014-01-02 12:15   ` Bjørn Mork
2014-01-03  0:40     ` Rafael J. Wysocki
2014-01-03  9:24       ` Bjørn Mork
2014-01-03  9:53         ` Bjørn Mork
2014-01-03 11:19           ` Viresh Kumar
2014-01-03 11:55             ` Bjørn Mork
2014-01-06  6:27               ` Viresh Kumar
2014-01-06  9:01                 ` Bjørn Mork
2014-01-06  9:57                   ` Viresh Kumar
2014-01-06 10:49                     ` Bjørn Mork
2014-01-06 10:54                       ` Viresh Kumar
2014-01-06 11:33                         ` Rafael J. Wysocki
     [not found]                         ` <8738l15pht.fsf@nemi.mork.no>
2014-01-08  5:51                           ` Viresh Kumar
2014-01-06 11:14                       ` Rafael J. Wysocki

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