linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpufreq_ondemand: fix bad auto calculated frequency.
@ 2021-08-27  8:17 schspa
  2021-08-31  4:58 ` Viresh Kumar
  0 siblings, 1 reply; 2+ messages in thread
From: schspa @ 2021-08-27  8:17 UTC (permalink / raw)
  To: rjw, viresh.kumar; +Cc: linux-pm, linux-kernel, schspa

We can litmit cpufreq range by change min & max from cpufreq_policy.
So cpu frequency target should be in range [policy->min, policy->max].

Signed-off-by: schspa <schspa@gmail.com>
---
 drivers/cpufreq/cpufreq_ondemand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index ac361a8b1d3b..8afb2c84c38c 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -151,8 +151,8 @@ static void od_update(struct cpufreq_policy *policy)
 		/* Calculate the next frequency proportional to load */
 		unsigned int freq_next, min_f, max_f;
 
-		min_f = policy->cpuinfo.min_freq;
-		max_f = policy->cpuinfo.max_freq;
+		min_f = policy->min;
+		max_f = policy->max;
 		freq_next = min_f + load * (max_f - min_f) / 100;
 
 		/* No longer fully busy, reset rate_mult */
-- 
2.29.0


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

* Re: [PATCH] cpufreq_ondemand: fix bad auto calculated frequency.
  2021-08-27  8:17 [PATCH] cpufreq_ondemand: fix bad auto calculated frequency schspa
@ 2021-08-31  4:58 ` Viresh Kumar
  0 siblings, 0 replies; 2+ messages in thread
From: Viresh Kumar @ 2021-08-31  4:58 UTC (permalink / raw)
  To: schspa; +Cc: rjw, linux-pm, linux-kernel

On 27-08-21, 16:17, schspa wrote:
> We can litmit cpufreq range by change min & max from cpufreq_policy.
> So cpu frequency target should be in range [policy->min, policy->max].
> 
> Signed-off-by: schspa <schspa@gmail.com>
> ---
>  drivers/cpufreq/cpufreq_ondemand.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
> index ac361a8b1d3b..8afb2c84c38c 100644
> --- a/drivers/cpufreq/cpufreq_ondemand.c
> +++ b/drivers/cpufreq/cpufreq_ondemand.c
> @@ -151,8 +151,8 @@ static void od_update(struct cpufreq_policy *policy)
>  		/* Calculate the next frequency proportional to load */
>  		unsigned int freq_next, min_f, max_f;
>  
> -		min_f = policy->cpuinfo.min_freq;
> -		max_f = policy->cpuinfo.max_freq;
> +		min_f = policy->min;
> +		max_f = policy->max;
>  		freq_next = min_f + load * (max_f - min_f) / 100;

No. The current calculations are right. The new frequency is proportional to
current load and it needs to take into account the entire freq range of the
CPUs. Note that we will eventually try to get the resultant frequency within
policy->min/max range in __cpufreq_driver_target().

-- 
viresh

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

end of thread, other threads:[~2021-08-31  4:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27  8:17 [PATCH] cpufreq_ondemand: fix bad auto calculated frequency schspa
2021-08-31  4:58 ` Viresh Kumar

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