All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Wahren <stefan.wahren@i2se.com>
To: Viresh Kumar <viresh.kumar@linaro.org>,
	Lucas Stach <l.stach@pengutronix.de>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Fabio Estevam <festevam@gmail.com>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>
Subject: Re: cpufreq: Unable to set cpufreq to maximum
Date: Mon, 06 Oct 2014 08:41:20 +0200	[thread overview]
Message-ID: <54323990.6000401@i2se.com> (raw)
In-Reply-To: <CAKohpom_kJadzUiPAT9GBJjvcu=38L9fO1atoi24xGwrq9XDFg@mail.gmail.com>

Am 06.10.2014 um 06:21 schrieb Viresh Kumar:
> On 2 October 2014 20:52, Lucas Stach <l.stach@pengutronix.de> wrote:
>> It's harmless in your case. But to get rid of it you might try the
>> attached patch which may be an acceptable solution.
>>
>> ------------------------------>8-----------------------------------
>> From db9e708edf6451b619ee73f68c3fcde2eccd7b0c Mon Sep 17 00:00:00 2001
>> From: Lucas Stach <l.stach@pengutronix.de>
>> Date: Thu, 2 Oct 2014 17:20:09 +0200
>> Subject: [PATCH] cpufreq: generic: try preserve some accuracy while
>> converting
>>  from Hz to kHz
>>
>> ---
>>  drivers/cpufreq/cpufreq.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>> index d9fdeddcef96..459830c6576f 100644
>> --- a/drivers/cpufreq/cpufreq.c
>> +++ b/drivers/cpufreq/cpufreq.c
>> @@ -187,7 +187,7 @@ unsigned int cpufreq_generic_get(unsigned int cpu)
>>                 return 0;
>>         }
>>
>> -       return clk_get_rate(policy->clk) / 1000;
>> +       return DIV_ROUND_CLOSEST(clk_get_rate(policy->clk), 1000);
>>  }
>>  EXPORT_SYMBOL_GPL(cpufreq_generic_get);
> Absolutely NOT..
>
> This can't be an acceptable solution to the problem you have in your DT.
> This routine is used for getting the current frequency of a CPU and we
> can't play with that..

I thought about it and agree with you.

> The problem that Stefan is getting is: The boot loader has programmed
> cpu to a frequency which isn't present in your DT table. And so kernel
> tries to adjust CPU frequency to one of the listed frequencies.

Here comes the real problem, i'm not able to specify the exact frequency
of the cpu. The clock has a value in Hz, but in the DT we have kHz. So
there are always rounding issues. The question is how to handle it.

> Solutions:
> - Add another entry to your DT table to reflect the currently programmed
> frequency.
> - Just ignore the error, as that is just for information.

Ignoring errors isn't a solution. I have another idea. I've looked a
little bit at the code in the cpufreq-(cpu0/dt). Usually the frequencies
are rounded down, but in cpu0_set_target() with
dev_pm_opp_find_freq_ceil(cpu_dev, &freq_Hz) they are rounded up. From
my point of view that's wrong.

I fixed the problem by decreasing frequency in DT and replacing
dev_pm_opp_find_freq_ceil() with dev_pm_opp_find_freq_floor() in
cpufreq-cpu0.c . Unfortunatelly this will break all other DTS files with
roundings in OPPs.

Stefan

  reply	other threads:[~2014-10-06  6:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-02 13:17 cpufreq: Unable to set cpufreq to maximum Stefan Wahren
2014-10-02 13:59 ` Lucas Stach
2014-10-02 15:01   ` Stefan Wahren
2014-10-02 15:22     ` Lucas Stach
2014-10-02 16:10       ` Stefan Wahren
2014-10-06  4:21       ` Viresh Kumar
2014-10-06  6:41         ` Stefan Wahren [this message]
2014-10-06  8:50           ` Viresh Kumar
2014-10-06  9:13             ` Stefan Wahren
2014-10-06  9:26               ` Viresh Kumar
2014-10-06 10:05                 ` Stefan Wahren
2014-10-06 10:16                   ` Viresh Kumar
2014-10-06 11:12                     ` Stefan Wahren
2014-10-06 11:18                       ` Viresh Kumar

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=54323990.6000401@i2se.com \
    --to=stefan.wahren@i2se.com \
    --cc=festevam@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=l.stach@pengutronix.de \
    --cc=linux-pm@vger.kernel.org \
    --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 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.