Skip to content

Commit 6db0f53

Browse files
Zihuan Zhangrafaeljw
authored andcommitted
cpufreq: preserve freq_table_sorted across suspend/hibernate
During S3/S4 suspend and resume, cpufreq policies are not freed or recreated; the freq_table and policy structure remain intact. However, set_freq_table_sorted() currently resets policy->freq_table_sorted to UNSORTED unconditionally, which is unnecessary since the table order does not change across suspend/resume. This patch adds a check to skip validation if policy->freq_table_sorted is already ASCENDING or DESCENDING. This avoids unnecessary traversal of the frequency table on S3/S4 resume or repeated online events, reducing overhead while preserving correctness. Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn> Link: https://patch.msgid.link/20251011072420.11495-1-zhangzihuan@kylinos.cn Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 673e75e commit 6db0f53

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

drivers/cpufreq/cpufreq.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,9 +1421,12 @@ static int cpufreq_policy_online(struct cpufreq_policy *policy,
14211421
* If there is a problem with its frequency table, take it
14221422
* offline and drop it.
14231423
*/
1424-
ret = cpufreq_table_validate_and_sort(policy);
1425-
if (ret)
1426-
goto out_offline_policy;
1424+
if (policy->freq_table_sorted != CPUFREQ_TABLE_SORTED_ASCENDING &&
1425+
policy->freq_table_sorted != CPUFREQ_TABLE_SORTED_DESCENDING) {
1426+
ret = cpufreq_table_validate_and_sort(policy);
1427+
if (ret)
1428+
goto out_offline_policy;
1429+
}
14271430

14281431
/* related_cpus should at least include policy->cpus. */
14291432
cpumask_copy(policy->related_cpus, policy->cpus);

0 commit comments

Comments
 (0)