@@ -368,18 +368,23 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
368
368
if (trip -> temperature == THERMAL_TEMP_INVALID )
369
369
return ;
370
370
371
+ /*
372
+ * If the trip temperature or hysteresis has been updated recently,
373
+ * the threshold needs to be computed again using the new values.
374
+ * However, its initial value still reflects the old ones and that
375
+ * is what needs to be compared with the previous zone temperature
376
+ * to decide which action to take.
377
+ */
371
378
if (tz -> last_temperature == THERMAL_TEMP_INVALID ) {
372
379
/* Initialization. */
373
380
td -> threshold = trip -> temperature ;
374
381
if (tz -> temperature >= td -> threshold )
375
382
td -> threshold -= trip -> hysteresis ;
376
383
} else if (tz -> last_temperature < td -> threshold ) {
377
384
/*
378
- * The trip threshold is equal to the trip temperature, unless
379
- * the latter has changed in the meantime. In either case,
380
- * the trip is crossed if the current zone temperature is at
381
- * least equal to its temperature, but otherwise ensure that
382
- * the threshold and the trip temperature will be equal.
385
+ * There is no mitigation under way, so it needs to be started
386
+ * if the zone temperature exceeds the trip one. The new
387
+ * threshold is then set to the low temperature of the trip.
383
388
*/
384
389
if (tz -> temperature >= trip -> temperature ) {
385
390
thermal_notify_tz_trip_up (tz , trip );
@@ -390,14 +395,9 @@ static void handle_thermal_trip(struct thermal_zone_device *tz,
390
395
}
391
396
} else {
392
397
/*
393
- * The previous zone temperature was above or equal to the trip
394
- * threshold, which would be equal to the "low temperature" of
395
- * the trip (its temperature minus its hysteresis), unless the
396
- * trip temperature or hysteresis had changed. In either case,
397
- * the trip is crossed if the current zone temperature is below
398
- * the low temperature of the trip, but otherwise ensure that
399
- * the trip threshold will be equal to the low temperature of
400
- * the trip.
398
+ * Mitigation is under way, so it needs to stop if the zone
399
+ * temperature falls below the low temperature of the trip.
400
+ * In that case, the trip temperature becomes the new threshold.
401
401
*/
402
402
if (tz -> temperature < trip -> temperature - trip -> hysteresis ) {
403
403
thermal_notify_tz_trip_down (tz , trip );
0 commit comments