]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cpufreq: Add new helper function returning cpufreq policy
authorLifeng Zheng <zhenglifeng1@huawei.com>
Wed, 19 Nov 2025 08:13:55 +0000 (16:13 +0800)
committerWill Deacon <will@kernel.org>
Mon, 5 Jan 2026 21:11:48 +0000 (21:11 +0000)
cpufreq_cpu_get_raw() gets cpufreq policy only if the CPU is in
policy->cpus mask, which means the CPU is already online. But in some
cases, the policy is needed before the CPU is added to cpus mask. Add a
function to get the policy in these cases.

Signed-off-by: Lifeng Zheng <zhenglifeng1@huawei.com>
Reviewed-by: Rafael J. Wysocki (Intel) <rafael@kernel.org>
Reviewed-by: Jie Zhan <zhanjie9@hisilicon.com>
Acked-by: Beata Michalska <beata.michalska@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>
drivers/cpufreq/cpufreq.c
include/linux/cpufreq.h

index 4472bb1ec83c728deccba736a011ffaad8614414..076c8eb5db3711d94f20b361a9a1fea74706ba92 100644 (file)
@@ -198,6 +198,12 @@ struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu)
 }
 EXPORT_SYMBOL_GPL(cpufreq_cpu_get_raw);
 
+struct cpufreq_policy *cpufreq_cpu_policy(unsigned int cpu)
+{
+       return per_cpu(cpufreq_cpu_data, cpu);
+}
+EXPORT_SYMBOL_GPL(cpufreq_cpu_policy);
+
 unsigned int cpufreq_generic_get(unsigned int cpu)
 {
        struct cpufreq_policy *policy = cpufreq_cpu_get_raw(cpu);
index 0465d1e6f72ac0bd146c6d9cabeaac844a6284f5..cc894fc389710521152f5884e543e03bd194958a 100644 (file)
@@ -203,6 +203,7 @@ struct cpufreq_freqs {
 
 #ifdef CONFIG_CPU_FREQ
 struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu);
+struct cpufreq_policy *cpufreq_cpu_policy(unsigned int cpu);
 struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu);
 void cpufreq_cpu_put(struct cpufreq_policy *policy);
 #else
@@ -210,6 +211,10 @@ static inline struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu)
 {
        return NULL;
 }
+static inline struct cpufreq_policy *cpufreq_cpu_policy(unsigned int cpu)
+{
+       return NULL;
+}
 static inline struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu)
 {
        return NULL;