[PATCH 2/2] cpufreq: dt: Implement light_weight_exit() callback

From: Viresh Kumar
Date: Mon Feb 11 2019 - 03:41:59 EST


Implement the light-weight tear down helper to reduce the amount of work
to do on CPU offline/online operation.

Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
---
drivers/cpufreq/cpufreq-dt.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index 7ba392911cd0..69309a8121f0 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -160,6 +160,15 @@ static int cpufreq_init(struct cpufreq_policy *policy)
const char *name;
int ret;

+ /*
+ * We did light-weight shutdown earlier, nothing else to initialize here
+ * apart from policy->cpus.
+ */
+ if (policy->driver_data) {
+ cpumask_copy(policy->cpus, policy->related_cpus);
+ return 0;
+ }
+
cpu_dev = get_cpu_device(policy->cpu);
if (!cpu_dev) {
pr_err("failed to get cpu%d device\n", policy->cpu);
@@ -295,6 +304,15 @@ static int cpufreq_init(struct cpufreq_policy *policy)
return ret;
}

+static int cpufreq_light_weight_exit(struct cpufreq_policy *policy)
+{
+ /*
+ * Preserve policy->driver_data and don't free resources on light-weight
+ * tear down.
+ */
+ return 0;
+}
+
static int cpufreq_exit(struct cpufreq_policy *policy)
{
struct private_data *priv = policy->driver_data;
@@ -319,6 +337,7 @@ static struct cpufreq_driver dt_cpufreq_driver = {
.get = cpufreq_generic_get,
.init = cpufreq_init,
.exit = cpufreq_exit,
+ .light_weight_exit = cpufreq_light_weight_exit,
.name = "cpufreq-dt",
.attr = cpufreq_dt_attr,
.suspend = cpufreq_generic_suspend,
--
2.20.1.321.g9e740568ce00