]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
thermal: trip: Trigger trip down notifications when trips involved in mitigation...
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 23 May 2024 16:05:03 +0000 (18:05 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 27 May 2024 11:00:00 +0000 (13:00 +0200)
When a trip point becomes invalid after being crossed on the way up,
it is involved in a mitigation episode that needs to be adjusted to
compensate for the trip going away.

For this reason, introduce thermal_zone_trip_down() as a wrapper
around thermal_trip_crossed() and make thermal_zone_set_trip_temp()
call it if the new temperature of the trip at hand is equal to
THERMAL_TEMP_INVALID and it has been crossed on the way up to trigger
all of the necessary adjustments in user space, the thermal debug
code and the zone governor.

Fixes: 8c69a777e480 ("thermal: core: Fix the handling of invalid trip points")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/thermal_core.c
drivers/thermal/thermal_core.h
drivers/thermal/thermal_trip.c

index c119ef920793d38965ce1f2861c328bac2b384ec..30567b4994551b174e2b96bdfe1189816be115e6 100644 (file)
@@ -602,6 +602,12 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,
 }
 EXPORT_SYMBOL_GPL(thermal_zone_device_update);
 
+void thermal_zone_trip_down(struct thermal_zone_device *tz,
+                           const struct thermal_trip *trip)
+{
+       thermal_trip_crossed(tz, trip, thermal_get_tz_governor(tz), false);
+}
+
 int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *),
                              void *data)
 {
index d9785e5bbb08cde8b2c5a672aa1c14936a4fc06c..20e7b45673d683064209f63ecb0d4cb1b2f5fbdb 100644 (file)
@@ -246,6 +246,8 @@ int thermal_zone_trip_id(const struct thermal_zone_device *tz,
 void thermal_zone_trip_updated(struct thermal_zone_device *tz,
                               const struct thermal_trip *trip);
 int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
+void thermal_zone_trip_down(struct thermal_zone_device *tz,
+                           const struct thermal_trip *trip);
 
 /* sysfs I/F */
 int thermal_zone_create_device_groups(struct thermal_zone_device *tz);
index d6a6acc78ddb6c1586bd32c878e59a128933464f..49e63db685172e44a7f3c83a2df958bc5d839d90 100644 (file)
@@ -152,17 +152,23 @@ void thermal_zone_set_trip_temp(struct thermal_zone_device *tz,
        if (trip->temperature == temp)
                return;
 
+       trip->temperature = temp;
+       thermal_notify_tz_trip_change(tz, trip);
+
        if (temp == THERMAL_TEMP_INVALID) {
                struct thermal_trip_desc *td = trip_to_trip_desc(trip);
 
-               if (trip->type == THERMAL_TRIP_PASSIVE &&
-                   tz->temperature >= td->threshold) {
+               if (tz->temperature >= td->threshold) {
                        /*
-                        * The trip has been crossed, so the thermal zone's
-                        * passive count needs to be adjusted.
+                        * The trip has been crossed on the way up, so some
+                        * adjustments are needed to compensate for the lack
+                        * of it going forward.
                         */
-                       tz->passive--;
-                       WARN_ON_ONCE(tz->passive < 0);
+                       if (trip->type == THERMAL_TRIP_PASSIVE) {
+                               tz->passive--;
+                               WARN_ON_ONCE(tz->passive < 0);
+                       }
+                       thermal_zone_trip_down(tz, trip);
                }
                /*
                 * Invalidate the threshold to avoid triggering a spurious
@@ -170,7 +176,5 @@ void thermal_zone_set_trip_temp(struct thermal_zone_device *tz,
                 */
                td->threshold = INT_MAX;
        }
-       trip->temperature = temp;
-       thermal_notify_tz_trip_change(tz, trip);
 }
 EXPORT_SYMBOL_GPL(thermal_zone_set_trip_temp);