[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1d1c3ee64c0a5a701c8d7c66440fd2781512432c.1623313323.git.viresh.kumar@linaro.org>
Date: Thu, 10 Jun 2021 13:54:00 +0530
From: Viresh Kumar <viresh.kumar@...aro.org>
To: Rafael Wysocki <rjw@...ysocki.net>,
Qian Cai <quic_qiancai@...cinc.com>,
Viresh Kumar <viresh.kumar@...aro.org>,
Jonathan Corbet <corbet@....net>
Cc: linux-pm@...r.kernel.org,
Vincent Guittot <vincent.guittot@...aro.org>,
Ionela Voinescu <ionela.voinescu@....com>,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 4/5] cpufreq: Add start_cpu() and stop_cpu() callbacks
On CPU hotplug, the cpufreq core doesn't call any driver specific
callback unless all the CPUs of a policy went away.
There is need for a callback to be called in such cases (for the CPPC
cpufreq driver) now. Reuse the existing stop_cpu() callback and add a
new one for start_cpu().
Signed-off-by: Viresh Kumar <viresh.kumar@...aro.org>
---
Documentation/cpu-freq/cpu-drivers.rst | 7 +++++--
drivers/cpufreq/cpufreq.c | 11 ++++++++---
include/linux/cpufreq.h | 5 ++++-
3 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/Documentation/cpu-freq/cpu-drivers.rst b/Documentation/cpu-freq/cpu-drivers.rst
index a697278ce190..15cfe42b4075 100644
--- a/Documentation/cpu-freq/cpu-drivers.rst
+++ b/Documentation/cpu-freq/cpu-drivers.rst
@@ -71,8 +71,11 @@ And optionally
.exit - A pointer to a per-policy cleanup function called during
CPU_POST_DEAD phase of cpu hotplug process.
- .stop_cpu - A pointer to a per-policy stop function called during
- CPU_DOWN_PREPARE phase of cpu hotplug process.
+ .start_cpu - A pointer to a per-policy per-cpu start function called
+ during CPU online phase.
+
+ .stop_cpu - A pointer to a per-policy per-cpu stop function called
+ during CPU offline phase.
.suspend - A pointer to a per-policy suspend function which is called
with interrupts disabled and _after_ the governor is stopped for the
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 802abc925b2a..fac2522be5c3 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -1119,6 +1119,10 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cp
cpumask_set_cpu(cpu, policy->cpus);
+ /* Do CPU specific initialization if required */
+ if (cpufreq_driver->start_cpu)
+ cpufreq_driver->start_cpu(policy, cpu);
+
if (has_target()) {
ret = cpufreq_start_governor(policy);
if (ret)
@@ -1581,6 +1585,10 @@ static int cpufreq_offline(unsigned int cpu)
policy->cpu = cpumask_any(policy->cpus);
}
+ /* Do CPU specific de-initialization if required */
+ if (cpufreq_driver->stop_cpu)
+ cpufreq_driver->stop_cpu(policy, cpu);
+
/* Start governor again for active policy */
if (!policy_is_inactive(policy)) {
if (has_target()) {
@@ -1597,9 +1605,6 @@ static int cpufreq_offline(unsigned int cpu)
policy->cdev = NULL;
}
- if (cpufreq_driver->stop_cpu)
- cpufreq_driver->stop_cpu(policy);
-
if (has_target())
cpufreq_exit_governor(policy);
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
index 353969c7acd3..c281b3df4e2f 100644
--- a/include/linux/cpufreq.h
+++ b/include/linux/cpufreq.h
@@ -371,7 +371,10 @@ struct cpufreq_driver {
int (*online)(struct cpufreq_policy *policy);
int (*offline)(struct cpufreq_policy *policy);
int (*exit)(struct cpufreq_policy *policy);
- void (*stop_cpu)(struct cpufreq_policy *policy);
+
+ /* CPU specific start/stop */
+ void (*start_cpu)(struct cpufreq_policy *policy, unsigned int cpu);
+ void (*stop_cpu)(struct cpufreq_policy *policy, unsigned int cpu);
int (*suspend)(struct cpufreq_policy *policy);
int (*resume)(struct cpufreq_policy *policy);
--
2.31.1.272.g89b43f80a514
Powered by blists - more mailing lists