All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thara Gopinath <thara.gopinath@linaro.org>
To: Viresh Kumar <viresh.kumar@linaro.org>,
	Steev Klimaszewski <steev@kali.org>
Cc: rafael@kernel.org, bjorn.andersson@linaro.org,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH] cpufreq: freq_table: Initialize cpuinfo.max_freq to correct max frequency.
Date: Tue, 16 Nov 2021 10:27:33 -0500	[thread overview]
Message-ID: <fd153d84-411a-c843-eab9-2dc66940a3d3@linaro.org> (raw)
In-Reply-To: <20211116035935.wmazontuznhys6qu@vireshk-i7>



On 11/15/21 10:59 PM, Viresh Kumar wrote:
> On 15-11-21, 19:23, Steev Klimaszewski wrote:
>> Hi Thara,
>>
>> On 11/15/21 1:50 PM, Thara Gopinath wrote:
>>> cpuinfo.max_freq reflects the maximum supported frequency of cpus in a
>>> cpufreq policy. When cpus support boost frequency and if boost is disabled
>>> during boot up (which is the default), cpuinfo.max_freq does not reflect
>>> boost frequency as the maximum supported frequency till boost is explicitly
>>> enabled via sysfs interface later. This also means that policy reports two
>>> different cpuinfo.max_freq before and after turning on boost.  Fix this by
>>> separating out setting of policy->max and cpuinfo.max_freq in
>>> cpufreq_frequency_table_cpuinfo.
>>>
>>> e.g. of the problem. Qualcomm sdm845 supports boost frequency for gold
>>> cluster (cpus 4-7). After boot up (boost disabled),
>>>
>>> 1.  cat /sys/devices/system/cpu/cpufreq/policy4/cpuinfo_max_freq 2649600
>>> <- This is wrong because boost frequency is
>>>
>>> 2.  echo 1 > /sys/devices/system/cpu/cpufreq/boost  <- Enable boost cat
>>> /sys/devices/system/cpu/cpufreq/policy4/cpuinfo_max_freq 2803200	<-
>>> max freq reflects boost freq.
>>>
>>> 3.  echo 0 > /sys/devices/system/cpu/cpufreq/boost <- Disable boost cat
>>> /sys/devices/system/cpu/cpufreq/policy4/cpuinfo_max_freq 2803200	<-
>>> Discrepancy with step 1 as in both cases boost is disabled.
>>>
>>> Note that the other way to fix this is to set cpuinfo.max_freq in Soc
>>> cpufreq driver during initialization. Fixing it in
>>> cpufreq_frequency_table_cpuinfo seems more generic solution
>>>
>>> Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
>>> ---
>>>    drivers/cpufreq/freq_table.c | 8 ++++++--
>>>    1 file changed, 6 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
>>> index 67e56cf638ef..6784f94124df 100644
>>> --- a/drivers/cpufreq/freq_table.c
>>> +++ b/drivers/cpufreq/freq_table.c
>>> @@ -35,11 +35,15 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
>>>    	struct cpufreq_frequency_table *pos;
>>>    	unsigned int min_freq = ~0;
>>>    	unsigned int max_freq = 0;
>>> +	unsigned int cpuinfo_max_freq = 0;
>>>    	unsigned int freq;
>>>    	cpufreq_for_each_valid_entry(pos, table) {
>>>    		freq = pos->frequency;
>>> +		if (freq > cpuinfo_max_freq)
>>> +			cpuinfo_max_freq = freq;
>>> +
>>>    		if (!cpufreq_boost_enabled()
>>>    		    && (pos->flags & CPUFREQ_BOOST_FREQ))
>>>    			continue;
>>> @@ -57,8 +61,8 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy,
>>>    	 * If the driver has set its own cpuinfo.max_freq above max_freq, leave
>>>    	 * it as is.
>>>    	 */
>>> -	if (policy->cpuinfo.max_freq < max_freq)
>>> -		policy->max = policy->cpuinfo.max_freq = max_freq;
>>> +	if (policy->cpuinfo.max_freq < cpuinfo_max_freq)
>>> +		policy->cpuinfo.max_freq = cpuinfo_max_freq;
> 
> You need to keep the check of policy->max here and update policy->max,
> else you will never run at boost freq. I think this is what Steev
> reported as well ?

Hi Viresh,
	policy->max is unconditionally set to max_freq in the line before "if 
(policy->cpuinfo.max_freq < max_freq)". So this is not the issue Steev 
is reporting.
	policy->max = max_freq


> 
> So basically something like this:
> 
> 	if (policy->max < max_freq)
> 		policy->max = max_freq;
> 
> 	if (policy->cpuinfo.max_freq < cpuinfo_max_freq)
> 		policy->cpuinfo.max_freq = cpuinfo_max_freq;
> 

-- 
Warm Regards
Thara (She/Her/Hers)

  reply	other threads:[~2021-11-16 15:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15 19:50 [PATCH] cpufreq: freq_table: Initialize cpuinfo.max_freq to correct max frequency Thara Gopinath
2021-11-16  1:23 ` Steev Klimaszewski
2021-11-16  3:00   ` Steev Klimaszewski
2021-11-16  3:59   ` Viresh Kumar
2021-11-16 15:27     ` Thara Gopinath [this message]
2021-11-17  7:24       ` Viresh Kumar
2021-11-16 15:31   ` Thara Gopinath
2021-11-16 16:15     ` Steev Klimaszewski
2021-11-16 16:44       ` Steev Klimaszewski

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=fd153d84-411a-c843-eab9-2dc66940a3d3@linaro.org \
    --to=thara.gopinath@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=steev@kali.org \
    --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.