Skip to content

Commit ae2170d

Browse files
committed
thermal: trip: Trigger trip down notifications when trips involved in mitigation become invalid
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: 8c69a77 ("thermal: core: Fix the handling of invalid trip points") Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent cb573ee commit ae2170d

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

drivers/thermal/thermal_core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,12 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,
602602
}
603603
EXPORT_SYMBOL_GPL(thermal_zone_device_update);
604604

605+
void thermal_zone_trip_down(struct thermal_zone_device *tz,
606+
const struct thermal_trip *trip)
607+
{
608+
thermal_trip_crossed(tz, trip, thermal_get_tz_governor(tz), false);
609+
}
610+
605611
int for_each_thermal_governor(int (*cb)(struct thermal_governor *, void *),
606612
void *data)
607613
{

drivers/thermal/thermal_core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ int thermal_zone_trip_id(const struct thermal_zone_device *tz,
246246
void thermal_zone_trip_updated(struct thermal_zone_device *tz,
247247
const struct thermal_trip *trip);
248248
int __thermal_zone_get_temp(struct thermal_zone_device *tz, int *temp);
249+
void thermal_zone_trip_down(struct thermal_zone_device *tz,
250+
const struct thermal_trip *trip);
249251

250252
/* sysfs I/F */
251253
int thermal_zone_create_device_groups(struct thermal_zone_device *tz);

drivers/thermal/thermal_trip.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,25 +152,29 @@ void thermal_zone_set_trip_temp(struct thermal_zone_device *tz,
152152
if (trip->temperature == temp)
153153
return;
154154

155+
trip->temperature = temp;
156+
thermal_notify_tz_trip_change(tz, trip);
157+
155158
if (temp == THERMAL_TEMP_INVALID) {
156159
struct thermal_trip_desc *td = trip_to_trip_desc(trip);
157160

158-
if (trip->type == THERMAL_TRIP_PASSIVE &&
159-
tz->temperature >= td->threshold) {
161+
if (tz->temperature >= td->threshold) {
160162
/*
161-
* The trip has been crossed, so the thermal zone's
162-
* passive count needs to be adjusted.
163+
* The trip has been crossed on the way up, so some
164+
* adjustments are needed to compensate for the lack
165+
* of it going forward.
163166
*/
164-
tz->passive--;
165-
WARN_ON_ONCE(tz->passive < 0);
167+
if (trip->type == THERMAL_TRIP_PASSIVE) {
168+
tz->passive--;
169+
WARN_ON_ONCE(tz->passive < 0);
170+
}
171+
thermal_zone_trip_down(tz, trip);
166172
}
167173
/*
168174
* Invalidate the threshold to avoid triggering a spurious
169175
* trip crossing notification when the trip becomes valid.
170176
*/
171177
td->threshold = INT_MAX;
172178
}
173-
trip->temperature = temp;
174-
thermal_notify_tz_trip_change(tz, trip);
175179
}
176180
EXPORT_SYMBOL_GPL(thermal_zone_set_trip_temp);

0 commit comments

Comments
 (0)