From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: Pierre Ossman <pierre-list@ossman.eu>
Cc: Viresh Kumar <viresh.kumar@linaro.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Linux PM mailing list <linux-pm@vger.kernel.org>
Subject: Re: [PATCH] cpufreq: fix current freq check on policy update
Date: Fri, 14 Feb 2014 17:14:34 +0530 [thread overview]
Message-ID: <52FE01A2.9030905@linux.vnet.ibm.com> (raw)
In-Reply-To: <20140214072623.3dd67851@mjolnir.ossman.eu>
On 02/14/2014 11:56 AM, Pierre Ossman wrote:
> From de497de3fcd81e8340498cd0b34b3388fe75cc19 Mon Sep 17 00:00:00 2001
> From: Pierre Ossman <pierre@ossman.eu>
> Date: Fri, 14 Feb 2014 07:17:02 +0100
> Subject: [PATCH] cpufreq: fix current freq check on policy update
>
> There was some variable confusion in cpufreq_update_policy()
> when we tried to get a current reading of the CPU frequency.
> If it failed to get the frequency, a current frequency of
> 0 kHz would be stored which in turn screwed up other parts
> of the kernel.
>
You know what's interesting? I went through the powernow-k8 cpufreq
driver code (based on your system data in the bugzilla), and found
that (if I read it correctly), ->get() can simply never return 0 !
.get is mapped to powernowk8_get
powernowk8_get() in turn calls smp_call_function_single() on that cpu
and fetches the data into data->currfid.
Then we have this statement:
khz = find_khz_freq_from_fid(data->currfid);
which is:
66 /* Return a frequency in MHz, given an input fid */
67 static u32 find_freq_from_fid(u32 fid)
68 {
69 return 800 + (fid * 100);
70 }
71
72 /* Return a frequency in KHz, given an input fid */
73 static u32 find_khz_freq_from_fid(u32 fid)
74 {
75 return 1000 * find_freq_from_fid(fid);
76 }
So with that, I don't see how the KHz value can turn out to be zero!
Regards,
Srivatsa S. Bhat
> In particular it somehow disoriented the r8169 driver and
> this entire issue was handled on this bug:
>
> https://bugzilla.kernel.org/show_bug.cgi?id=70311
>
> Signed-off-by: Pierre Ossman <pierre@ossman.eu>
> ---
> drivers/cpufreq/cpufreq.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 08ca8c9..1b61310 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2151,9 +2151,9 @@ int cpufreq_update_policy(unsigned int cpu)
> */
> if (cpufreq_driver->get) {
> new_policy.cur = cpufreq_driver->get(cpu);
> - if (!policy->cur) {
> + if (!new_policy.cur) {
> pr_debug("Driver did not initialize current freq");
> - policy->cur = new_policy.cur;
> + new_policy.cur = policy->cur;
> } else {
> if (policy->cur != new_policy.cur && has_target())
> cpufreq_out_of_sync(cpu, policy->cur,
> -- 1.8.5.3
next prev parent reply other threads:[~2014-02-14 11:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-14 6:26 [PATCH] cpufreq: fix current freq check on policy update Pierre Ossman
2014-02-14 11:44 ` Srivatsa S. Bhat [this message]
2014-02-14 13:58 ` Rafael J. Wysocki
2014-02-14 14:34 ` Pierre Ossman
2014-02-17 5:06 ` Viresh Kumar
2014-02-17 8:08 ` Srivatsa S. Bhat
2014-02-17 8:23 ` Viresh Kumar
2014-02-17 8:21 ` Srivatsa S. Bhat
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=52FE01A2.9030905@linux.vnet.ibm.com \
--to=srivatsa.bhat@linux.vnet.ibm.com \
--cc=linux-pm@vger.kernel.org \
--cc=pierre-list@ossman.eu \
--cc=rjw@rjwysocki.net \
--cc=viresh.kumar@linaro.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).