Re: [PATCH] cpufreq: Don't skip cpufreq_frequency_table_cpuinfo()

From: Rafael J. Wysocki

Date: Fri Mar 20 2026 - 07:49:44 EST


On Fri, Mar 20, 2026 at 10:24 AM Viresh Kumar <viresh.kumar@xxxxxxxxxx> wrote:
>
> The commit 6db0f533d320 ("cpufreq: preserve freq_table_sorted across
> suspend/hibernate") unintentionally made a change where
> cpufreq_frequency_table_cpuinfo() isn't getting called anymore for old
> policies getting re-initialized.
>
> This leads to potentially invalid values of policy->max and
> policy->cpuinfo_max_freq.
>
> Fix the issue by reverting the original commit and adding the condition
> for just the sorting function.
>
> Fixes: 6db0f533d320 ("cpufreq: preserve freq_table_sorted across suspend/hibernate")
> Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
> ---
> drivers/cpufreq/cpufreq.c | 9 +++------
> drivers/cpufreq/freq_table.c | 4 ++++
> 2 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index 277884d91913..1f794524a1d9 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1427,12 +1427,9 @@ static int cpufreq_policy_online(struct cpufreq_policy *policy,
> * If there is a problem with its frequency table, take it
> * offline and drop it.
> */
> - if (policy->freq_table_sorted != CPUFREQ_TABLE_SORTED_ASCENDING &&
> - policy->freq_table_sorted != CPUFREQ_TABLE_SORTED_DESCENDING) {
> - ret = cpufreq_table_validate_and_sort(policy);
> - if (ret)
> - goto out_offline_policy;
> - }
> + ret = cpufreq_table_validate_and_sort(policy);
> + if (ret)
> + goto out_offline_policy;
>
> /* related_cpus should at least include policy->cpus. */
> cpumask_copy(policy->related_cpus, policy->cpus);
> diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
> index 7f251daf03ce..5b364d8da4f9 100644
> --- a/drivers/cpufreq/freq_table.c
> +++ b/drivers/cpufreq/freq_table.c
> @@ -360,6 +360,10 @@ int cpufreq_table_validate_and_sort(struct cpufreq_policy *policy)
> if (policy_has_boost_freq(policy))
> policy->boost_supported = true;
>
> + if (policy->freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING ||
> + policy->freq_table_sorted == CPUFREQ_TABLE_SORTED_DESCENDING)
> + return 0;
> +
> return set_freq_table_sorted(policy);
> }
>
> --

Applied as 7.0-rc material, thanks!