Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Introduce THERMAL_TREND_RAISE/DROP_FULL support for step_wise governor

step_wise governor should set the device cooling state to
upper/lower limit directly when THERMAL_TREND_RAISE/DROP_FULL.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>

Zhang Rui 3dbfff3d d069015e

+46 -18
+46 -18
drivers/thermal/step_wise.c
··· 35 35 * state for this trip point 36 36 * b. if the trend is THERMAL_TREND_DROPPING, use lower cooling 37 37 * state for this trip point 38 + * c. if the trend is THERMAL_TREND_RAISE_FULL, use upper limit 39 + * for this trip point 40 + * d. if the trend is THERMAL_TREND_DROP_FULL, use lower limit 41 + * for this trip point 42 + * If the temperature is lower than a trip point, 43 + * a. if the trend is THERMAL_TREND_RAISING, do nothing 44 + * b. if the trend is THERMAL_TREND_DROPPING, use lower cooling 45 + * state for this trip point, if the cooling state already 46 + * equals lower limit, deactivate the thermal instance 47 + * c. if the trend is THERMAL_TREND_RAISE_FULL, do nothing 48 + * d. if the trend is THERMAL_TREND_DROP_FULL, use lower limit, 49 + * if the cooling state already equals lower limit, 50 + * deactive the thermal instance 38 51 */ 39 52 static unsigned long get_target_state(struct thermal_instance *instance, 40 - enum thermal_trend trend) 53 + enum thermal_trend trend, bool throttle) 41 54 { 42 55 struct thermal_cooling_device *cdev = instance->cdev; 43 56 unsigned long cur_state; 44 57 45 58 cdev->ops->get_cur_state(cdev, &cur_state); 46 59 47 - if (trend == THERMAL_TREND_RAISING) { 48 - cur_state = cur_state < instance->upper ? 49 - (cur_state + 1) : instance->upper; 50 - } else if (trend == THERMAL_TREND_DROPPING) { 51 - cur_state = cur_state > instance->lower ? 52 - (cur_state - 1) : instance->lower; 60 + switch (trend) { 61 + case THERMAL_TREND_RAISING: 62 + if (throttle) 63 + cur_state = cur_state < instance->upper ? 64 + (cur_state + 1) : instance->upper; 65 + break; 66 + case THERMAL_TREND_RAISE_FULL: 67 + if (throttle) 68 + cur_state = instance->upper; 69 + break; 70 + case THERMAL_TREND_DROPPING: 71 + if (cur_state == instance->lower) { 72 + if (!throttle) 73 + cur_state = -1; 74 + } else 75 + cur_state -= 1; 76 + break; 77 + case THERMAL_TREND_DROP_FULL: 78 + if (cur_state == instance->lower) { 79 + if (!throttle) 80 + cur_state = -1; 81 + } else 82 + cur_state = instance->lower; 83 + break; 84 + default: 85 + break; 53 86 } 54 87 55 88 return cur_state; ··· 109 76 if (instance->trip != trip) 110 77 continue; 111 78 112 - instance->target = get_target_state(instance, trend); 79 + instance->target = get_target_state(instance, trend, true); 113 80 114 81 /* Activate a passive thermal instance */ 115 82 if (instance->target == THERMAL_NO_TARGET) ··· 120 87 } 121 88 122 89 static void update_instance_for_dethrottle(struct thermal_zone_device *tz, 123 - int trip, enum thermal_trip_type trip_type) 90 + int trip, enum thermal_trip_type trip_type, 91 + enum thermal_trend trend) 124 92 { 125 93 struct thermal_instance *instance; 126 - struct thermal_cooling_device *cdev; 127 - unsigned long cur_state; 128 94 129 95 list_for_each_entry(instance, &tz->thermal_instances, tz_node) { 130 96 if (instance->trip != trip || 131 97 instance->target == THERMAL_NO_TARGET) 132 98 continue; 133 99 134 - cdev = instance->cdev; 135 - cdev->ops->get_cur_state(cdev, &cur_state); 136 - 137 - instance->target = cur_state > instance->lower ? 138 - (cur_state - 1) : THERMAL_NO_TARGET; 100 + instance->target = get_target_state(instance, trend, false); 139 101 140 102 /* Deactivate a passive thermal instance */ 141 103 if (instance->target == THERMAL_NO_TARGET) 142 104 update_passive_instance(tz, trip_type, -1); 143 105 144 - cdev->updated = false; /* cdev needs update */ 106 + instance->cdev->updated = false; /* cdev needs update */ 145 107 } 146 108 } 147 109 ··· 161 133 if (tz->temperature >= trip_temp) 162 134 update_instance_for_throttle(tz, trip, trip_type, trend); 163 135 else 164 - update_instance_for_dethrottle(tz, trip, trip_type); 136 + update_instance_for_dethrottle(tz, trip, trip_type, trend); 165 137 166 138 mutex_unlock(&tz->lock); 167 139 }