Skip to contentSkip to conversation

cpufreq: Migrate away from ->stop_cpu() callback

PATCH In review Viresh Kumar 4 participants 11 messages Jun 23, 2021 – Jun 30, 2021

Subsystems (6)
lore
Share & tools
lore

Viresh Kumar

author maintainer
#0 lore raw

v4 cover cpufreq: Migrate away from ->stop_cpu() callback

Hi Rafael,

These are based on your patch [1] now.

commit 367dc4aa932b ("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 offline() or exit() callback instead of stop_cpu().

V3->V4:
- Based on a cleanup patch [1] from Rafael, apart from 5.13-rc7.
- No need to update exit() for intel pstate anymore.
- Remove the stop_cpu() callback completely.

--
Viresh

[1] https://lore.kernel.org/linux-pm/5490292.DvuYhMxLoT@kreacher/

Viresh Kumar (4):
cpufreq: cppc: Migrate to ->exit() callback instead of ->stop_cpu()
cpufreq: intel_pstate: Migrate to ->offline() instead of ->stop_cpu()
cpufreq: powerenv: Migrate to ->exit() callback instead of

    ->stop_cpu()

cpufreq: Remove stop_cpu() callback

 Documentation/cpu-freq/cpu-drivers.rst        |  3 --
 .../zh_CN/cpu-freq/cpu-drivers.rst            |  3 --
 drivers/cpufreq/cppc_cpufreq.c                | 46 ++++++++++---------
 drivers/cpufreq/cpufreq.c                     |  3 --
 drivers/cpufreq/intel_pstate.c                | 10 +---
 drivers/cpufreq/powernv-cpufreq.c             | 23 ++++------
 include/linux/cpufreq.h                       |  1 -
 7 files changed, 35 insertions(+), 54 deletions(-)
Signature · 1 line
2.31.1.272.g89b43f80a514
author maintainer
#1 lore raw

PATCH v4 1/4 cpufreq: cppc: Migrate to ->exit() callback instead of ->stop_cpu()

commit 367dc4aa932b ("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().

---
 drivers/cpufreq/cppc_cpufreq.c | 46 ++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 22 deletions(-)
drivers/cpufreq/cppc_cpufreq.c +24 -22
index 2f769b1630c5..be4f62e2c5f1 100644
@@ -182,27 +182,6 @@ static int cppc_verify_policy(struct cpufreq_policy_data *policy)
 	return 0;
 }
 
-static void cppc_cpufreq_stop_cpu(struct cpufreq_policy *policy)
-{
-	struct cppc_cpudata *cpu_data = policy->driver_data;
-	struct cppc_perf_caps *caps = &cpu_data->perf_caps;
-	unsigned int cpu = policy->cpu;
-	int ret;
-
-	cpu_data->perf_ctrls.desired_perf = caps->lowest_perf;
-
-	ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls);
-	if (ret)
-		pr_debug("Err setting perf value:%d on CPU:%d. ret:%d\n",
-			 caps->lowest_perf, cpu, ret);
-
-	/* Remove CPU node from list and free driver data for policy */
-	free_cpumask_var(cpu_data->shared_cpu_map);
-	list_del(&cpu_data->node);
-	kfree(policy->driver_data);
-	policy->driver_data = NULL;
-}
-
 /*
  * The PCC subspace describes the rate at which platform can accept commands
  * 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)
 	return ret;
 }
 
+static int cppc_cpufreq_cpu_exit(struct cpufreq_policy *policy)
+{
+	struct cppc_cpudata *cpu_data = policy->driver_data;
+	struct cppc_perf_caps *caps = &cpu_data->perf_caps;
+	unsigned int cpu = policy->cpu;
+	int ret;
+
+	cpu_data->perf_ctrls.desired_perf = caps->lowest_perf;
+
+	ret = cppc_set_perf(cpu, &cpu_data->perf_ctrls);
+	if (ret)
+		pr_debug("Err setting perf value:%d on CPU:%d. ret:%d\n",
+			 caps->lowest_perf, cpu, ret);
+
+	/* Remove CPU node from list and free driver data for policy */
+	free_cpumask_var(cpu_data->shared_cpu_map);
+	list_del(&cpu_data->node);
+	kfree(policy->driver_data);
+	policy->driver_data = NULL;
+
+	return 0;
+}
+
 static inline u64 get_delta(u64 t1, u64 t0)
 {
 	if (t1 > t0 || t0 > ~(u32)0)
@@ -451,7 +453,7 @@ static struct cpufreq_driver cppc_cpufreq_driver = {
 	.target = cppc_cpufreq_set_target,
 	.get = cppc_cpufreq_get_rate,
 	.init = cppc_cpufreq_cpu_init,
-	.stop_cpu = cppc_cpufreq_stop_cpu,
+	.exit = cppc_cpufreq_cpu_exit,
 	.set_boost = cppc_cpufreq_set_boost,
 	.attr = cppc_cpufreq_attr,
 	.name = "cppc_cpufreq",
Signature · 1 line
2.31.1.272.g89b43f80a514
author maintainer
#2 lore raw

PATCH v4 2/4 cpufreq: intel_pstate: Migrate to ->offline() instead of ->stop_cpu()

In reply to Viresh Kumar

commit 367dc4aa932b ("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 to separately call stop_cpu() for cpufreq drivers.

Migrate to using the offline() callbacks instead of stop_cpu().

Cc Dirk Brandewie <[email protected]>
---
 drivers/cpufreq/intel_pstate.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/cpufreq/intel_pstate.c +2 -8
index 0e69dffd5a76..b4c0ff7f5b71 100644
@@ -2335,6 +2335,8 @@ static int intel_pstate_cpu_offline(struct cpufreq_policy *policy)
 
 	pr_debug("CPU %d going offline\n", cpu->cpu);
 
+	intel_pstate_clear_update_util_hook(policy->cpu);
+
 	if (cpu->suspended)
 		return 0;
 
@@ -2374,13 +2376,6 @@ static int intel_pstate_cpu_online(struct cpufreq_policy *policy)
 	return 0;
 }
 
-static void intel_pstate_stop_cpu(struct cpufreq_policy *policy)
-{
-	pr_debug("CPU %d stopping\n", policy->cpu);
-
-	intel_pstate_clear_update_util_hook(policy->cpu);
-}
-
 static int intel_pstate_cpu_exit(struct cpufreq_policy *policy)
 {
 	pr_debug("CPU %d exiting\n", policy->cpu);
@@ -2451,7 +2446,6 @@ static struct cpufreq_driver intel_pstate = {
 	.resume		= intel_pstate_resume,
 	.init		= intel_pstate_cpu_init,
 	.exit		= intel_pstate_cpu_exit,
-	.stop_cpu	= intel_pstate_stop_cpu,
 	.offline	= intel_pstate_cpu_offline,
 	.online		= intel_pstate_cpu_online,
 	.update_limits	= intel_pstate_update_limits,
Signature · 1 line
2.31.1.272.g89b43f80a514
#3 lore raw

Re: [PATCH V4 2/4] cpufreq: intel_pstate: Migrate to ->offline() instead of ->stop_cpu()

Quoted 27 lines · CEST Viresh Kumar

commit 367dc4aa932b ("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 to separately call stop_cpu() for cpufreq drivers.

Migrate to using the offline() callbacks instead of stop_cpu().

Cc Dirk Brandewie <[email protected]>
---
 drivers/cpufreq/intel_pstate.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/cpufreq/intel_pstate.c +0 -0
index 0e69dffd5a76..b4c0ff7f5b71 100644

drivers/cpufreq/intel_pstate.c static int intel_pstate_cpu_offline(struct cpufreq_policy *policy) · line 2338

Quoted 4 lines
drivers/cpufreq/intel_pstate.c +1 -0
@@ -2335,6 +2335,8 @@ static int intel_pstate_cpu_offline(struct cpufreq_policy *policy)
 
 	pr_debug("CPU %d going offline\n", cpu->cpu);
 
+	intel_pstate_clear_update_util_hook(policy->cpu);

As mentioned already in

https://lore.kernel.org/linux-pm/CAJZ5v0g2tCZptcqh+c55YYiO7rDHmZivMLsmpq_7005zNPN1xg@mail.gmail.com/

this isn't particularly clean, because intel_pstate_cpu_offline() is also used in the passive mode where the above call is not needed.

I would make a change like in the patch below instead.

drivers/cpufreq/intel_pstate.c static int intel_pstate_cpu_offline(struct cpufreq_policy *policy) · line 2341

Quoted 3 lines
drivers/cpufreq/intel_pstate.c +1 -0
+
 	if (cpu->suspended)
 		return 0;

---
From: Rafael J. Wysocki <[email protected]>
Subject: [PATCH] cpufreq: intel_pstate: Combine ->stop_cpu() and ->offline()

Combine the ->stop_cpu() and ->offline() callback routines for the active mode of intel_pstate so as to avoid setting the ->stop_cpu callback pointer which is going to be dropped from the framework.

---
 drivers/cpufreq/intel_pstate.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/cpufreq/intel_pstate.c +4 -3
Index: linux-pm/drivers/cpufreq/intel_pstate.c
===================================================================
@@ -2577,11 +2577,13 @@ static int intel_pstate_cpu_online(struc
 	return 0;
 }
 
-static void intel_pstate_stop_cpu(struct cpufreq_policy *policy)
+static int intel_pstate_stop_cpu(struct cpufreq_policy *policy)
 {
 	pr_debug("CPU %d stopping\n", policy->cpu);
 
 	intel_pstate_clear_update_util_hook(policy->cpu);
+
+	return intel_pstate_cpu_offline(policy);
 }
 
 static int intel_pstate_cpu_exit(struct cpufreq_policy *policy)
@@ -2654,8 +2656,7 @@ static struct cpufreq_driver intel_pstat
 	.resume		= intel_pstate_resume,
 	.init		= intel_pstate_cpu_init,
 	.exit		= intel_pstate_cpu_exit,
-	.stop_cpu	= intel_pstate_stop_cpu,
-	.offline	= intel_pstate_cpu_offline,
+	.offline	= intel_pstate_stop_cpu,
 	.online		= intel_pstate_cpu_online,
 	.update_limits	= intel_pstate_update_limits,
 	.name		= "intel_pstate",
author maintainer Acked-by
#4 lore raw

Re: [PATCH V4 2/4] cpufreq: intel_pstate: Migrate to ->offline() instead of ->stop_cpu()

Quoted 3 lines · Rafael J. Wysocki

As mentioned already in

https://lore.kernel.org/linux-pm/CAJZ5v0g2tCZptcqh+c55YYiO7rDHmZivMLsmpq_7005zNPN1xg@mail.gmail.com/

Sorry about failing to reply over that, I got confused somehow..

Quoted 2 lines

this isn't particularly clean, because intel_pstate_cpu_offline() is also used in the passive mode where the above call is not needed.

intel_pstate_clear_update_util_hook() returns early if the hook was never registered, and so calling it was safe, but yes not very clean.

Quoted 32 lines

From: Rafael J. Wysocki <[email protected]>
Subject: [PATCH] cpufreq: intel_pstate: Combine ->stop_cpu() and ->offline()

Combine the ->stop_cpu() and ->offline() callback routines for the active mode of intel_pstate so as to avoid setting the ->stop_cpu callback pointer which is going to be dropped from the framework.

---
 drivers/cpufreq/intel_pstate.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Index: linux-pm/drivers/cpufreq/intel_pstate.c
===================================================================

drivers/cpufreq/intel_pstate.c +3 -1
@@ -2577,11 +2577,13 @@ static int intel_pstate_cpu_online(struc
 	return 0;
 }
 
-static void intel_pstate_stop_cpu(struct cpufreq_policy *policy)
+static int intel_pstate_stop_cpu(struct cpufreq_policy *policy)
 {
 	pr_debug("CPU %d stopping\n", policy->cpu);
 
 	intel_pstate_clear_update_util_hook(policy->cpu);
+
+	return intel_pstate_cpu_offline(policy);
 }
 
 static int intel_pstate_cpu_exit(struct cpufreq_policy *policy)

drivers/cpufreq/intel_pstate.c static struct cpufreq_driver intel_pstat · line 2659

Quoted 6 lines
drivers/cpufreq/intel_pstate.c +1 -2
@@ -2654,8 +2656,7 @@ static struct cpufreq_driver intel_pstat
 	.resume		= intel_pstate_resume,
 	.init		= intel_pstate_cpu_init,
 	.exit		= intel_pstate_cpu_exit,
-	.stop_cpu	= intel_pstate_stop_cpu,
-	.offline	= intel_pstate_cpu_offline,
+	.offline	= intel_pstate_stop_cpu,

I would suggest to rename intel_pstate_cpu_offline() as intel_cpufreq_cpu_offline() and intel_pstate_stop_cpu() as intel_pstate_cpu_offline(), so we remove the stop-cpu terminology completely.

Either way:

Quoted 3 lines
drivers/cpufreq/intel_pstate.c +0 -0
 	.online		= intel_pstate_cpu_online,
 	.update_limits	= intel_pstate_update_limits,
 	.name		= "intel_pstate",
Signature · 1 line
viresh
#5 lore raw

Re: [PATCH V4 2/4] cpufreq: intel_pstate: Migrate to ->offline() instead of ->stop_cpu()

Quoted 44 lines · Viresh Kumar
Quoted 3 lines · Rafael J. Wysocki

As mentioned already in

https://lore.kernel.org/linux-pm/CAJZ5v0g2tCZptcqh+c55YYiO7rDHmZivMLsmpq_7005zNPN1xg@mail.gmail.com/

Sorry about failing to reply over that, I got confused somehow..

Quoted 2 lines

this isn't particularly clean, because intel_pstate_cpu_offline() is also used in the passive mode where the above call is not needed.

intel_pstate_clear_update_util_hook() returns early if the hook was never registered, and so calling it was safe, but yes not very clean.

Quoted 30 lines

From: Rafael J. Wysocki <[email protected]>
Subject: [PATCH] cpufreq: intel_pstate: Combine ->stop_cpu() and ->offline()

Combine the ->stop_cpu() and ->offline() callback routines for the active mode of intel_pstate so as to avoid setting the ->stop_cpu callback pointer which is going to be dropped from the framework.

---
 drivers/cpufreq/intel_pstate.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Index: linux-pm/drivers/cpufreq/intel_pstate.c
===================================================================

drivers/cpufreq/intel_pstate.c +3 -1
@@ -2577,11 +2577,13 @@ static int intel_pstate_cpu_online(struc
      return 0;
 }
 
-static void intel_pstate_stop_cpu(struct cpufreq_policy *policy)
+static int intel_pstate_stop_cpu(struct cpufreq_policy *policy)
 {
      pr_debug("CPU %d stopping\n", policy->cpu);
 
      intel_pstate_clear_update_util_hook(policy->cpu);
+
+     return intel_pstate_cpu_offline(policy);
 }
 
Quoted 12 lines

drivers/cpufreq/intel_pstate.c static struct cpufreq_driver intel_pstat · line 2659

Quoted 8 lines
drivers/cpufreq/intel_pstate.c +1 -2
 static int intel_pstate_cpu_exit(struct cpufreq_policy *policy)
@@ -2654,8 +2656,7 @@ static struct cpufreq_driver intel_pstat
      .resume         = intel_pstate_resume,
      .init           = intel_pstate_cpu_init,
      .exit           = intel_pstate_cpu_exit,
-     .stop_cpu       = intel_pstate_stop_cpu,
-     .offline        = intel_pstate_cpu_offline,
+     .offline        = intel_pstate_stop_cpu,

I would suggest to rename intel_pstate_cpu_offline() as intel_cpufreq_cpu_offline() and intel_pstate_stop_cpu() as intel_pstate_cpu_offline(), so we remove the stop-cpu terminology completely.

I have followed the above suggestion and applied the modified patch along with the rest of this series.

Quoted 2 lines

Either way:

Thanks!

Quoted 3 lines
Quoted 3 lines
drivers/cpufreq/intel_pstate.c +0 -0
      .online         = intel_pstate_cpu_online,
      .update_limits  = intel_pstate_update_limits,
      .name           = "intel_pstate",
author maintainer
#6 lore raw

PATCH v4 3/4 cpufreq: powerenv: Migrate to ->exit() callback instead of ->stop_cpu()

In reply to Viresh Kumar

commit 367dc4aa932b ("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().

---
 drivers/cpufreq/powernv-cpufreq.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)
drivers/cpufreq/powernv-cpufreq.c +9 -14
index e439b43c19eb..005600cef273 100644
@@ -875,7 +875,15 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
 
 static int powernv_cpufreq_cpu_exit(struct cpufreq_policy *policy)
 {
-	/* timer is deleted in cpufreq_cpu_stop() */
+	struct powernv_smp_call_data freq_data;
+	struct global_pstate_info *gpstates = policy->driver_data;
+
+	freq_data.pstate_id = idx_to_pstate(powernv_pstate_info.min);
+	freq_data.gpstate_id = idx_to_pstate(powernv_pstate_info.min);
+	smp_call_function_single(policy->cpu, set_pstate, &freq_data, 1);
+	if (gpstates)
+		del_timer_sync(&gpstates->timer);
+
 	kfree(policy->driver_data);
 
 	return 0;
@@ -1007,18 +1015,6 @@ static struct notifier_block powernv_cpufreq_opal_nb = {
 	.priority	= 0,
 };
 
-static void powernv_cpufreq_stop_cpu(struct cpufreq_policy *policy)
-{
-	struct powernv_smp_call_data freq_data;
-	struct global_pstate_info *gpstates = policy->driver_data;
-
-	freq_data.pstate_id = idx_to_pstate(powernv_pstate_info.min);
-	freq_data.gpstate_id = idx_to_pstate(powernv_pstate_info.min);
-	smp_call_function_single(policy->cpu, set_pstate, &freq_data, 1);
-	if (gpstates)
-		del_timer_sync(&gpstates->timer);
-}
-
 static unsigned int powernv_fast_switch(struct cpufreq_policy *policy,
 					unsigned int target_freq)
 {
@@ -1042,7 +1038,6 @@ static struct cpufreq_driver powernv_cpufreq_driver = {
 	.target_index	= powernv_cpufreq_target_index,
 	.fast_switch	= powernv_fast_switch,
 	.get		= powernv_cpufreq_get,
-	.stop_cpu	= powernv_cpufreq_stop_cpu,
 	.attr		= powernv_cpu_freq_attr,
 };
 
Signature · 1 line
2.31.1.272.g89b43f80a514
#7 lore raw

Re: [PATCH V4 3/4] cpufreq: powerenv: Migrate to ->exit() callback instead of ->stop_cpu()

Quoted 2 lines · Viresh Kumar

Subject: Re: [PATCH V4 3/4] cpufreq: powerenv: Migrate to ->exit() callback instead of ->stop_cpu()

Typo in subject should be "powernv".

cheers

author maintainer
#8 lore raw

Re: [PATCH V4 3/4] cpufreq: powerenv: Migrate to ->exit() callback instead of ->stop_cpu()

Quoted 5 lines · Michael Ellerman
Quoted 2 lines · Viresh Kumar

Subject: Re: [PATCH V4 3/4] cpufreq: powerenv: Migrate to ->exit() callback instead of ->stop_cpu()

Typo in subject should be "powernv".

Thanks for noticing it :)

Signature · 1 line
viresh
author maintainer
#9 lore raw

PATCH v4 3/4 cpufreq: powernv: Migrate to ->exit() callback instead of ->stop_cpu()

In reply to Viresh Kumar

commit 367dc4aa932b ("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().

---
V4->V4.1:
- s/powerenv/powernv/

 drivers/cpufreq/powernv-cpufreq.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)
drivers/cpufreq/powernv-cpufreq.c +9 -14
index e439b43c19eb..005600cef273 100644
@@ -875,7 +875,15 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)
 
 static int powernv_cpufreq_cpu_exit(struct cpufreq_policy *policy)
 {
-	/* timer is deleted in cpufreq_cpu_stop() */
+	struct powernv_smp_call_data freq_data;
+	struct global_pstate_info *gpstates = policy->driver_data;
+
+	freq_data.pstate_id = idx_to_pstate(powernv_pstate_info.min);
+	freq_data.gpstate_id = idx_to_pstate(powernv_pstate_info.min);
+	smp_call_function_single(policy->cpu, set_pstate, &freq_data, 1);
+	if (gpstates)
+		del_timer_sync(&gpstates->timer);
+
 	kfree(policy->driver_data);
 
 	return 0;
@@ -1007,18 +1015,6 @@ static struct notifier_block powernv_cpufreq_opal_nb = {
 	.priority	= 0,
 };
 
-static void powernv_cpufreq_stop_cpu(struct cpufreq_policy *policy)
-{
-	struct powernv_smp_call_data freq_data;
-	struct global_pstate_info *gpstates = policy->driver_data;
-
-	freq_data.pstate_id = idx_to_pstate(powernv_pstate_info.min);
-	freq_data.gpstate_id = idx_to_pstate(powernv_pstate_info.min);
-	smp_call_function_single(policy->cpu, set_pstate, &freq_data, 1);
-	if (gpstates)
-		del_timer_sync(&gpstates->timer);
-}
-
 static unsigned int powernv_fast_switch(struct cpufreq_policy *policy,
 					unsigned int target_freq)
 {
@@ -1042,7 +1038,6 @@ static struct cpufreq_driver powernv_cpufreq_driver = {
 	.target_index	= powernv_cpufreq_target_index,
 	.fast_switch	= powernv_fast_switch,
 	.get		= powernv_cpufreq_get,
-	.stop_cpu	= powernv_cpufreq_stop_cpu,
 	.attr		= powernv_cpu_freq_attr,
 };
 
Signature · 1 line
2.31.1.272.g89b43f80a514
author maintainer
#10 lore raw

PATCH v4 4/4 cpufreq: Remove stop_cpu() callback

In reply to Viresh Kumar

Now that all users of stop_cpu() are migrated to use other callbacks, lets remove its support from the core.

---
 Documentation/cpu-freq/cpu-drivers.rst                    | 3 ---
 Documentation/translations/zh_CN/cpu-freq/cpu-drivers.rst | 3 ---
 drivers/cpufreq/cpufreq.c                                 | 3 ---
 include/linux/cpufreq.h                                   | 1 -
 4 files changed, 10 deletions(-)
Documentation/cpu-freq/cpu-drivers.rst +0 -3
index a697278ce190..74fac797c396 100644
@@ -71,9 +71,6 @@ 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.
-
  .suspend - A pointer to a per-policy suspend function which is called
  with interrupts disabled and _after_ the governor is stopped for the
  policy.
Documentation/translations/zh_CN/cpu-freq/cpu-drivers.rst +0 -3
index 0ca2cb646666..9570e9c9e939 100644
@@ -76,9 +76,6 @@ 并且可选择
  .exit - 一个指向per-policy清理函数的指针,该函数在cpu热插拔过程的CPU_POST_DEAD
  阶段被调用。
 
- .stop_cpu - 一个指向per-policy停止函数的指针,该函数在cpu热插拔过程的CPU_DOWN_PREPARE
- 阶段被调用。
-
  .suspend - 一个指向per-policy暂停函数的指针,该函数在关中断且在该策略的调节器停止
  后被调用。
 
drivers/cpufreq/cpufreq.c +0 -3
index cbab834c37a0..5e4b5316d254 100644
@@ -1606,9 +1606,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);
 
include/linux/cpufreq.h +0 -1
index 353969c7acd3..2e2267a36502 100644
@@ -371,7 +371,6 @@ 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);
 	int		(*suspend)(struct cpufreq_policy *policy);
 	int		(*resume)(struct cpufreq_policy *policy);
 
Signature · 1 line
2.31.1.272.g89b43f80a514