[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250814072853.3426386-3-zhenglifeng1@huawei.com>
Date: Thu, 14 Aug 2025 15:28:52 +0800
From: Lifeng Zheng <zhenglifeng1@...wei.com>
To: <catalin.marinas@....com>, <will@...nel.org>, <rafael@...nel.org>,
<viresh.kumar@...aro.org>, <beata.michalska@....com>, <sudeep.holla@....com>
CC: <linux-arm-kernel@...ts.infradead.org>, <linux-pm@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linuxarm@...wei.com>,
<jonathan.cameron@...wei.com>, <vincent.guittot@...aro.org>,
<yangyicong@...ilicon.com>, <zhanjie9@...ilicon.com>, <lihuisong@...wei.com>,
<yubowen8@...wei.com>, <linhongye@...artners.com>, <zhenglifeng1@...wei.com>
Subject: [PATCH v4 2/3] cpufreq: Add a new function to get cpufreq policy without checking if the CPU is online
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@...wei.com>
---
drivers/cpufreq/cpufreq.c | 6 ++++++
include/linux/cpufreq.h | 1 +
2 files changed, 7 insertions(+)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index fc7eace8b65b..78ca68ea754d 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -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);
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 95f3807c8c55..f135edeef925 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -205,6 +205,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
--
2.33.0
Powered by blists - more mailing lists