All of lore.kernel.org
 help / color / mirror / Atom feed
From: viresh kumar <viresh.kumar@linaro.org>
To: "Bjørn Mork" <bjorn@mork.no>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	"cpufreq@vger.kernel.org" <cpufreq@vger.kernel.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH Resend] cpufreq: remove sysfs files for CPU which failed to come back after resume
Date: Mon, 23 Dec 2013 13:25:45 +0530	[thread overview]
Message-ID: <52B7EC81.6060202@linaro.org> (raw)
In-Reply-To: <87d2kokqdl.fsf@nemi.mork.no>

On Monday 23 December 2013 12:25 PM, Bjørn Mork wrote:
> That's correct.  The immediate result of the failure is exactly the
> same.

Okay..

> The difference is that a subsequent resume would restore the cpufreq
> device whether it existed or not.  That made a complete suspend/resume
> fix up any missing cpufreq device, e.g. one that was removed by a
> previous error.

I see.. Please see if below patch fixes it for you, it should :)


From: Viresh Kumar <viresh.kumar@linaro.org>
Date: Mon, 23 Dec 2013 13:19:47 +0530
Subject: [PATCH] cpufreq: try to resume policies which failed on last resume
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

__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-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 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 fab042e..7523d35 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1010,16 +1010,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
@@ -1112,8 +1120,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:


  reply	other threads:[~2013-12-23  7:55 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-20 15:56 [PATCH Resend] cpufreq: remove sysfs files for CPU which failed to come back after resume Viresh Kumar
2013-12-20 15:56 ` Viresh Kumar
2013-12-22  1:00 ` Rafael J. Wysocki
2013-12-22  1:00   ` Rafael J. Wysocki
2013-12-23  5:55   ` Bjørn Mork
2013-12-23  5:55     ` Bjørn Mork
2013-12-23  6:02     ` Viresh Kumar
2013-12-23  6:55       ` Bjørn Mork
2013-12-23  6:55         ` Bjørn Mork
2013-12-23  7:55         ` viresh kumar [this message]
2013-12-23  9:23           ` Bjørn Mork
2013-12-23  9:23             ` Bjørn Mork
2013-12-23 10:45             ` Viresh Kumar
2013-12-23 10:57               ` Bjørn Mork
2013-12-23 10:57                 ` Bjørn Mork
2013-12-23 11:13                 ` Viresh Kumar
2013-12-23 11:42                   ` Bjørn Mork
2013-12-23 11:42                     ` Bjørn Mork
2013-12-23 15:45                     ` viresh kumar
2013-12-23 15:45                       ` viresh kumar
2013-12-24  0:35                       ` Rafael J. Wysocki
2013-12-24  0:35                         ` Rafael J. Wysocki
2013-12-24  0:27                         ` Viresh Kumar
2013-12-24  0:43                           ` Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52B7EC81.6060202@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=bjorn@mork.no \
    --cc=cpufreq@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.