linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/5] thermal/core: Update cooling device during thermal zone unregistration
@ 2023-03-24  7:08 Zhang Rui
  2023-03-24  7:08 ` [PATCH 2/5] thermal/core: Reset cooling state during cooling device unregistration Zhang Rui
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Zhang Rui @ 2023-03-24  7:08 UTC (permalink / raw)
  To: linux-pm, rafael.j.wysocki, daniel.lezcano; +Cc: linux-kernel

When unregistering a thermal zone device, update all cooling devices
bound to the thermal zone device.

This fixes a problem that the frequency of ACPI processors are still
limited after unloading ACPI thermal driver while ACPI passive cooling
is activated.

Cc: stable@vger.kernel.org
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
v1 -> v2
	Changelog update.
	Rearrange the code to elimiate an "iterator used outside loop"
warning.
---
 drivers/thermal/thermal_core.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index cfd4c1afeae7..30ff39154598 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1497,9 +1497,24 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
 
 	/* Unbind all cdevs associated with 'this' thermal zone */
 	list_for_each_entry(cdev, &thermal_cdev_list, node) {
+		struct thermal_instance *ti;
+
+		mutex_lock(&tz->lock);
+		list_for_each_entry(ti, &tz->thermal_instances, tz_node) {
+			if (ti->cdev == cdev) {
+				mutex_unlock(&tz->lock);
+				goto unbind;
+			}
+		}
+
+		/* The cooling device is not bound to current thermal zone */
+		mutex_unlock(&tz->lock);
+		continue;
+
+unbind:
 		if (tz->ops->unbind) {
 			tz->ops->unbind(tz, cdev);
-			continue;
+			goto deactivate;
 		}
 
 		if (!tzp || !tzp->tbp)
@@ -1511,6 +1526,16 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
 				tzp->tbp[i].cdev = NULL;
 			}
 		}
+
+deactivate:
+		/*
+		 * The thermal instances for current thermal zone has been
+		 * removed. Update the cooling device in case it is activated
+		 * by current thermal zone device.
+		 */
+		mutex_lock(&cdev->lock);
+		__thermal_cdev_update(cdev);
+		mutex_unlock(&cdev->lock);
 	}
 
 	mutex_unlock(&thermal_list_lock);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-03-30  1:12 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-24  7:08 [PATCH v2 1/5] thermal/core: Update cooling device during thermal zone unregistration Zhang Rui
2023-03-24  7:08 ` [PATCH 2/5] thermal/core: Reset cooling state during cooling device unregistration Zhang Rui
2023-03-24 13:19   ` Rafael J. Wysocki
2023-03-27 14:50     ` Zhang, Rui
2023-03-27 15:13       ` Rafael J. Wysocki
2023-03-28  2:46         ` Zhang, Rui
2023-03-28 17:54           ` Rafael J. Wysocki
2023-03-29  6:28             ` Zhang, Rui
2023-03-24  7:08 ` [PATCH 3/5] thermal/core: Remove thermal_bind_params structure Zhang Rui
2023-03-29 18:39   ` Rafael J. Wysocki
2023-03-30  1:11     ` Zhang, Rui
2023-03-24  7:08 ` [PATCH 4/5] thermal/core: Enforce paired .bind/.unbind callbacks Zhang Rui
2023-03-24 13:24   ` Rafael J. Wysocki
2023-03-24 13:25     ` Rafael J. Wysocki
2023-03-27 15:03     ` Zhang, Rui
2023-03-24  7:08 ` [PATCH 5/5] thermal/core: Avoid unbind for thermal zones without .unbind() Zhang Rui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).