]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/6.8.6/cpufreq-don-t-unregister-cpufreq-cooling-on-cpu-hotp.patch
Linux 6.8.6
[thirdparty/kernel/stable-queue.git] / releases / 6.8.6 / cpufreq-don-t-unregister-cpufreq-cooling-on-cpu-hotp.patch
CommitLineData
335f7cc0
SL
1From eee289fa5e07e0be94dfad2b17de823945329f4c Mon Sep 17 00:00:00 2001
2From: Sasha Levin <sashal@kernel.org>
3Date: Thu, 29 Feb 2024 13:42:07 +0530
4Subject: cpufreq: Don't unregister cpufreq cooling on CPU hotplug
5
6From: Viresh Kumar <viresh.kumar@linaro.org>
7
8[ Upstream commit c4d61a529db788d2e52654f5b02c8d1de4952c5b ]
9
10Offlining a CPU and bringing it back online is a common operation and it
11happens frequently during system suspend/resume, where the non-boot CPUs
12are hotplugged out during suspend and brought back at resume.
13
14The cpufreq core already tries to make this path as fast as possible as
15the changes are only temporary in nature and full cleanup of resources
16isn't required in this case. For example the drivers can implement
17online()/offline() callbacks to avoid a lot of tear down of resources.
18
19On similar lines, there is no need to unregister the cpufreq cooling
20device during suspend / resume, but only while the policy is getting
21removed.
22
23Moreover, unregistering the cpufreq cooling device is resulting in an
24unwanted outcome, where the system suspend is eventually aborted in the
25process. Currently, during system suspend the cpufreq core unregisters
26the cooling device, which in turn removes a kobject using device_del()
27and that generates a notification to the userspace via uevent broadcast.
28This causes system suspend to abort in some setups.
29
30This was also earlier reported (indirectly) by Roman [1]. Maybe there is
31another way around to fixing that problem properly, but this change
32makes sense anyways.
33
34Move the registering and unregistering of the cooling device to policy
35creation and removal times onlyy.
36
37Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218521
38Reported-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
39Reported-by: Roman Stratiienko <r.stratiienko@gmail.com>
40Link: https://patchwork.kernel.org/project/linux-pm/patch/20220710164026.541466-1-r.stratiienko@gmail.com/ [1]
41Tested-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
42Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
43Reviewed-by: Dhruva Gole <d-gole@ti.com>
44Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
45Signed-off-by: Sasha Levin <sashal@kernel.org>
46---
47 drivers/cpufreq/cpufreq.c | 17 +++++++++++------
48 1 file changed, 11 insertions(+), 6 deletions(-)
49
50diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
51index 7d570b44777ac..3c2c955fbbbd6 100644
52--- a/drivers/cpufreq/cpufreq.c
53+++ b/drivers/cpufreq/cpufreq.c
54@@ -1576,7 +1576,8 @@ static int cpufreq_online(unsigned int cpu)
55 if (cpufreq_driver->ready)
56 cpufreq_driver->ready(policy);
57
58- if (cpufreq_thermal_control_enabled(cpufreq_driver))
59+ /* Register cpufreq cooling only for a new policy */
60+ if (new_policy && cpufreq_thermal_control_enabled(cpufreq_driver))
61 policy->cdev = of_cpufreq_cooling_register(policy);
62
63 pr_debug("initialization complete\n");
64@@ -1660,11 +1661,6 @@ static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy)
65 else
66 policy->last_policy = policy->policy;
67
68- if (cpufreq_thermal_control_enabled(cpufreq_driver)) {
69- cpufreq_cooling_unregister(policy->cdev);
70- policy->cdev = NULL;
71- }
72-
73 if (has_target())
74 cpufreq_exit_governor(policy);
75
76@@ -1725,6 +1721,15 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
77 return;
78 }
79
80+ /*
81+ * Unregister cpufreq cooling once all the CPUs of the policy are
82+ * removed.
83+ */
84+ if (cpufreq_thermal_control_enabled(cpufreq_driver)) {
85+ cpufreq_cooling_unregister(policy->cdev);
86+ policy->cdev = NULL;
87+ }
88+
89 /* We did light-weight exit earlier, do full tear down now */
90 if (cpufreq_driver->offline)
91 cpufreq_driver->exit(policy);
92--
932.43.0
94