Skip to content

Commit 9357a38

Browse files
vireshkrafaeljw
authored andcommitted
cpufreq: CPPC: Migrate to ->exit() callback instead of ->stop_cpu()
Commit 367dc4a ("cpufreq: Add stop CPU callback to cpufreq_driver interface") added the ->stop_cpu() callback to allow the drivers to do clean up before the CPU is completely down and its state can't be modified. At that time the CPU hotplug framework used to call the cpufreq core's registered notifier for different events like CPU_DOWN_PREPARE and CPU_POST_DEAD. The ->stop_cpu() callback was called during the CPU_DOWN_PREPARE event. This is no longer the case, cpuhp_cpufreq_offline() is called only once by the CPU hotplug core now and we don't really need two separate callbacks for cpufreq drivers, i.e. ->stop_cpu() and -<exit(), as everything can be done from the ->exit() callback itself. Migrate to using the ->exit() callback instead of ->stop_cpu(). Signed-off-by: Viresh Kumar <[email protected]> [ rjw: Minor edits in the changelog and subject ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 49d6fee commit 9357a38

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

drivers/cpufreq/cppc_cpufreq.c

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -182,27 +182,6 @@ static int cppc_verify_policy(struct cpufreq_policy_data *policy)
182182
return 0;
183183
}
184184

185-
static void cppc_cpufreq_stop_cpu(struct cpufreq_policy *policy)
186-
{
187-
struct cppc_cpudata *cpu_data = policy->driver_data;
188-
struct cppc_perf_caps *caps = &cpu_data->perf_caps;
189-
unsigned int cpu = policy->cpu;
190-
int ret;
191-
192-
cpu_data->perf_ctrls.desired_perf = caps->lowest_perf;
193-
194-
ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls);
195-
if (ret)
196-
pr_debug("Err setting perf value:%d on CPU:%d. ret:%d\n",
197-
caps->lowest_perf, cpu, ret);
198-
199-
/* Remove CPU node from list and free driver data for policy */
200-
free_cpumask_var(cpu_data->shared_cpu_map);
201-
list_del(&cpu_data->node);
202-
kfree(policy->driver_data);
203-
policy->driver_data = NULL;
204-
}
205-
206185
/*
207186
* The PCC subspace describes the rate at which platform can accept commands
208187
* on the shared PCC channel (including READs which do not count towards freq
@@ -352,6 +331,29 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
352331
return ret;
353332
}
354333

334+
static int cppc_cpufreq_cpu_exit(struct cpufreq_policy *policy)
335+
{
336+
struct cppc_cpudata *cpu_data = policy->driver_data;
337+
struct cppc_perf_caps *caps = &cpu_data->perf_caps;
338+
unsigned int cpu = policy->cpu;
339+
int ret;
340+
341+
cpu_data->perf_ctrls.desired_perf = caps->lowest_perf;
342+
343+
ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls);
344+
if (ret)
345+
pr_debug("Err setting perf value:%d on CPU:%d. ret:%d\n",
346+
caps->lowest_perf, cpu, ret);
347+
348+
/* Remove CPU node from list and free driver data for policy */
349+
free_cpumask_var(cpu_data->shared_cpu_map);
350+
list_del(&cpu_data->node);
351+
kfree(policy->driver_data);
352+
policy->driver_data = NULL;
353+
354+
return 0;
355+
}
356+
355357
static inline u64 get_delta(u64 t1, u64 t0)
356358
{
357359
if (t1 > t0 || t0 > ~(u32)0)
@@ -451,7 +453,7 @@ static struct cpufreq_driver cppc_cpufreq_driver = {
451453
.target = cppc_cpufreq_set_target,
452454
.get = cppc_cpufreq_get_rate,
453455
.init = cppc_cpufreq_cpu_init,
454-
.stop_cpu = cppc_cpufreq_stop_cpu,
456+
.exit = cppc_cpufreq_cpu_exit,
455457
.set_boost = cppc_cpufreq_set_boost,
456458
.attr = cppc_cpufreq_attr,
457459
.name = "cppc_cpufreq",

0 commit comments

Comments
 (0)