Re: [PATCH V2] cpufreq: tegra186: Fix initial frequency

From: Jon Hunter
Date: Mon Oct 26 2020 - 08:57:12 EST



On 19/10/2020 10:33, Jon Hunter wrote:
>
> On 16/10/2020 05:07, Viresh Kumar wrote:
>> On 15-10-20, 15:03, Jon Hunter wrote:
>>> If not too late, would you mind dropping this patch for v5.10?
>>
>> It is already part of Linus's master now.
>
> OK, thanks. I will send a revert for this once rc1 is out.


Thinking about this some more, what are your thoughts on making the
following change?

Basically, if the driver sets the CPUFREQ_NEED_INITIAL_FREQ_CHECK,
then I wonder if we should not fail if the frequency return by
>get() is not known. This would fix the problem I see on Tegra186
where the initial boot frequency may not be in the frequency table.

Cheers
Jon

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index f4b60663efe6..b7d3b61577b0 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1426,13 +1426,8 @@ static int cpufreq_online(unsigned int cpu)
CPUFREQ_CREATE_POLICY, policy);
}

- if (cpufreq_driver->get && has_target()) {
+ if (cpufreq_driver->get && has_target())
policy->cur = cpufreq_driver->get(policy->cpu);
- if (!policy->cur) {
- pr_err("%s: ->get() failed\n", __func__);
- goto out_destroy_policy;
- }
- }

/*
* Sometimes boot loaders set CPU frequency to a value outside of
@@ -1471,6 +1466,11 @@ static int cpufreq_online(unsigned int cpu)
pr_info("%s: CPU%d: Running at unlisted initial frequency: %u KHz, changing to: %u KHz\n",
__func__, policy->cpu, old_freq, policy->cur);
}
+ } else {
+ if (!policy->cur) {
+ pr_err("%s: ->get() failed\n", __func__);
+ goto out_destroy_policy;
+ }
}

if (new_policy) {

--
nvpublic