From: Viresh Kumar <viresh.kumar@linaro.org>
To: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Cc: Rafael Wysocki <rjw@rjwysocki.net>,
ke.wang@spreadtrum.com, linaro-kernel@lists.linaro.org,
linux-pm@vger.kernel.org, ego@linux.vnet.ibm.com,
paulus@samba.org, shilpa.bhat@linux.vnet.ibm.com,
prarit@redhat.com, robert.schoene@tu-dresden.de,
skannan@codeaurora.org
Subject: Re: [PATCH V2 10/10] cpufreq: propagate errors returned from __cpufreq_governor()
Date: Sat, 20 Jun 2015 08:42:07 +0530 [thread overview]
Message-ID: <20150620031207.GE1955@linux> (raw)
In-Reply-To: <55845930.7020503@linux.vnet.ibm.com>
On 19-06-15, 23:32, Preeti U Murthy wrote:
> If INIT itself fails, we need to set policy->governor to NULL. I
> included this in the testing of the patchset.
Diff from earlier patch:
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index da672b910760..59fa0c1b7922 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2284,14 +2284,23 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
old_gov = policy->governor;
/* end old governor */
if (old_gov) {
- if(!(ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP))) {
+ ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
+ if (ret) {
+ /* This can happen due to race with other operations */
+ pr_debug("%s: Failed to Stop Governor: %s (%d)\n",
+ __func__, old_gov->name, ret);
+ return ret;
+ } else {
up_write(&policy->rwsem);
ret = __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT);
down_write(&policy->rwsem);
- }
- if (ret)
- return ret;
+ if (ret) {
+ pr_err("%s: Failed to Exit Governor: %s (%d)\n",
+ __func__, old_gov->name, ret);
+ return ret;
+ }
+ }
}
/* start new governor */
@@ -2309,7 +2318,9 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
pr_debug("starting governor %s failed\n", policy->governor->name);
if (old_gov) {
policy->governor = old_gov;
- if (!__cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT))
+ if (__cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT))
+ policy->governor = NULL;
+ else
__cpufreq_governor(policy, CPUFREQ_GOV_START);
}
New-patch:
--------------8<-------------------
From: Viresh Kumar <viresh.kumar@linaro.org>
Date: Thu, 11 Sep 2014 10:50:48 +0530
Subject: [PATCH] cpufreq: propagate errors returned from __cpufreq_governor()
Return codes aren't honored properly in cpufreq_set_policy(). This can
lead to two problems:
- wrong errors propagated to sysfs
- we try to do next state-change even if the previous one failed
cpufreq_governor_dbs() now returns proper errors on all invalid
state-transition requests and this code should honor that.
Reviewed-and-Tested-by: Preeti U Murthy <preeti@linux.vnet.ibm.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
drivers/cpufreq/cpufreq.c | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index b612411655f9..59fa0c1b7922 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2284,16 +2284,29 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
old_gov = policy->governor;
/* end old governor */
if (old_gov) {
- __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
- up_write(&policy->rwsem);
- __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT);
- down_write(&policy->rwsem);
+ ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
+ if (ret) {
+ /* This can happen due to race with other operations */
+ pr_debug("%s: Failed to Stop Governor: %s (%d)\n",
+ __func__, old_gov->name, ret);
+ return ret;
+ } else {
+ up_write(&policy->rwsem);
+ ret = __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT);
+ down_write(&policy->rwsem);
+
+ if (ret) {
+ pr_err("%s: Failed to Exit Governor: %s (%d)\n",
+ __func__, old_gov->name, ret);
+ return ret;
+ }
+ }
}
/* start new governor */
policy->governor = new_policy->governor;
- if (!__cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT)) {
- if (!__cpufreq_governor(policy, CPUFREQ_GOV_START))
+ if (!(ret = __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT))) {
+ if (!(ret = __cpufreq_governor(policy, CPUFREQ_GOV_START)))
goto out;
up_write(&policy->rwsem);
@@ -2305,11 +2318,13 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
pr_debug("starting governor %s failed\n", policy->governor->name);
if (old_gov) {
policy->governor = old_gov;
- __cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT);
- __cpufreq_governor(policy, CPUFREQ_GOV_START);
+ if (__cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT))
+ policy->governor = NULL;
+ else
+ __cpufreq_governor(policy, CPUFREQ_GOV_START);
}
- return -EINVAL;
+ return ret;
out:
pr_debug("governor: change or update limits\n");
--
viresh
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
next prev parent reply other threads:[~2015-06-20 3:12 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-19 11:48 [PATCH V2 00/10] cpufreq: governor: Avoid invalid state-transitions Viresh Kumar
2015-06-19 11:48 ` [PATCH V2 01/10] cpufreq: governor: Name delayed-work as dwork Viresh Kumar
2015-06-19 11:48 ` [PATCH V2 02/10] cpufreq: governor: Drop unused field 'cpu' Viresh Kumar
2015-06-19 11:48 ` [PATCH V2 03/10] cpufreq: governor: Rename 'cpu_dbs_common_info' to 'cpu_dbs_info' Viresh Kumar
2015-06-19 11:48 ` [PATCH V2 04/10] cpufreq: governor: name pointer to cpu_dbs_info as 'cdbs' Viresh Kumar
2015-06-19 11:48 ` [PATCH V2 05/10] cpufreq: governor: rename cur_policy as policy Viresh Kumar
2015-06-19 11:48 ` [PATCH V2 06/10] cpufreq: governor: Keep single copy of information common to policy->cpus Viresh Kumar
2015-07-17 22:11 ` Rafael J. Wysocki
2015-11-27 11:56 ` Lucas Stach
2015-11-30 5:19 ` Viresh Kumar
2015-11-30 10:34 ` Lucas Stach
2015-11-30 11:03 ` Viresh Kumar
2015-12-02 21:43 ` Saravana Kannan
2015-12-03 4:54 ` Viresh Kumar
2015-12-03 6:53 ` Robert Schöne
2015-12-03 22:00 ` Saravana Kannan
2015-06-19 11:48 ` [PATCH V2 07/10] cpufreq: governor: split out common part of {cs|od}_dbs_timer() Viresh Kumar
2015-06-19 11:48 ` [PATCH V2 08/10] cpufreq: governor: Avoid invalid states with additional checks Viresh Kumar
2015-06-19 18:04 ` Preeti U Murthy
2015-06-19 11:48 ` [PATCH V2 09/10] cpufreq: governor: Don't WARN on invalid states Viresh Kumar
2015-06-19 11:48 ` [PATCH V2 10/10] cpufreq: propagate errors returned from __cpufreq_governor() Viresh Kumar
2015-06-19 18:02 ` Preeti U Murthy
2015-06-20 3:12 ` Viresh Kumar [this message]
2015-06-22 4:41 ` Preeti U Murthy
2015-06-22 5:21 ` Viresh Kumar
2015-06-19 18:09 ` Preeti U Murthy
2015-06-19 18:08 ` [PATCH V2 00/10] cpufreq: governor: Avoid invalid state-transitions Preeti U Murthy
2015-06-19 23:16 ` Rafael J. Wysocki
2015-06-20 2:36 ` Viresh Kumar
2015-07-17 22:15 ` Rafael J. Wysocki
2015-07-18 6:00 ` [PATCH V3 0/5] " Viresh Kumar
2015-07-18 6:00 ` [PATCH V3 1/5] cpufreq: governor: Keep single copy of information common to policy->cpus Viresh Kumar
2015-07-18 6:01 ` [PATCH V3 2/5] cpufreq: governor: split out common part of {cs|od}_dbs_timer() Viresh Kumar
2015-07-18 6:01 ` [PATCH V3 3/5] cpufreq: governor: Avoid invalid states with additional checks Viresh Kumar
2015-07-18 6:01 ` [PATCH V3 4/5] cpufreq: governor: Don't WARN on invalid states Viresh Kumar
2015-07-18 6:01 ` [PATCH V3 5/5] cpufreq: propagate errors returned from __cpufreq_governor() Viresh Kumar
2015-07-23 21:00 ` [PATCH V3 0/5] cpufreq: governor: Avoid invalid state-transitions 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=20150620031207.GE1955@linux \
--to=viresh.kumar@linaro.org \
--cc=ego@linux.vnet.ibm.com \
--cc=ke.wang@spreadtrum.com \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-pm@vger.kernel.org \
--cc=paulus@samba.org \
--cc=prarit@redhat.com \
--cc=preeti@linux.vnet.ibm.com \
--cc=rjw@rjwysocki.net \
--cc=robert.schoene@tu-dresden.de \
--cc=shilpa.bhat@linux.vnet.ibm.com \
--cc=skannan@codeaurora.org \
/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 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).