|
17 | 17 | #include "thermal_core.h" |
18 | 18 |
|
19 | 19 | /* |
20 | | - * If the temperature is higher than a trip point, |
| 20 | + * If the temperature is higher than a hysteresis temperature, |
21 | 21 | * a. if the trend is THERMAL_TREND_RAISING, use higher cooling |
22 | 22 | * state for this trip point |
23 | 23 | * b. if the trend is THERMAL_TREND_DROPPING, use a lower cooling state |
24 | 24 | * for this trip point, but keep the cooling state above the applicable |
25 | 25 | * minimum |
26 | | - * If the temperature is lower than a trip point, |
| 26 | + * If the temperature is lower than a hysteresis temperature, |
27 | 27 | * a. if the trend is THERMAL_TREND_RAISING, do nothing |
28 | | - * b. if the trend is THERMAL_TREND_DROPPING, use lower cooling |
29 | | - * state for this trip point, if the cooling state already |
| 28 | + * b. if the trend is THERMAL_TREND_DROPPING, use the minimum applicable |
| 29 | + * cooling state for this trip point, or if the cooling state already |
30 | 30 | * equals lower limit, deactivate the thermal instance |
31 | 31 | */ |
32 | 32 | static unsigned long get_target_state(struct thermal_instance *instance, |
@@ -83,23 +83,36 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, |
83 | 83 | int trip_threshold) |
84 | 84 | { |
85 | 85 | const struct thermal_trip *trip = &td->trip; |
| 86 | + int hyst_temp = trip->temperature - trip->hysteresis; |
| 87 | + bool throttle = tz->temperature >= hyst_temp; |
86 | 88 | enum thermal_trend trend = get_tz_trend(tz, trip); |
87 | 89 | int trip_id = thermal_zone_trip_id(tz, trip); |
88 | 90 | struct thermal_instance *instance; |
89 | | - bool throttle = false; |
90 | 91 |
|
91 | | - if (tz->temperature >= trip_threshold) { |
92 | | - throttle = true; |
| 92 | + if (throttle) |
93 | 93 | trace_thermal_zone_trip(tz, trip_id, trip->type); |
94 | | - } |
95 | 94 |
|
96 | | - dev_dbg(&tz->device, "Trip%d[type=%d,temp=%d]:trend=%d,throttle=%d\n", |
97 | | - trip_id, trip->type, trip_threshold, trend, throttle); |
| 95 | + dev_dbg(&tz->device, |
| 96 | + "Trip%d[type=%d,temp=%d,hyst=%d]:trend=%d,throttle=%d\n", |
| 97 | + trip_id, trip->type, trip->temperature, hyst_temp, trend, throttle); |
98 | 98 |
|
99 | 99 | list_for_each_entry(instance, &td->thermal_instances, trip_node) { |
100 | 100 | int old_target; |
101 | 101 |
|
102 | 102 | old_target = instance->target; |
| 103 | + throttle = false; |
| 104 | + |
| 105 | + /* |
| 106 | + * Lower the mitigation only if the temperature |
| 107 | + * goes below the hysteresis temperature. |
| 108 | + */ |
| 109 | + if (tz->temperature >= trip->temperature || |
| 110 | + (tz->temperature >= hyst_temp && |
| 111 | + old_target == instance->upper)) { |
| 112 | + throttle = true; |
| 113 | + trace_thermal_zone_trip(tz, trip_id, trip->type); |
| 114 | + } |
| 115 | + |
103 | 116 | instance->target = get_target_state(instance, trend, throttle); |
104 | 117 |
|
105 | 118 | dev_dbg(&instance->cdev->device, "old_target=%d, target=%ld\n", |
|
0 commit comments