diff options
author | Zhang Rui <rui.zhang@intel.com> | 2012-11-19 03:10:20 -0500 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2013-01-04 02:22:37 -0500 |
commit | 3dbfff3dfe6714aeefb615c65bec0800dc5a4c51 (patch) | |
tree | 1b9deca1bad750a932c435c9187f976494180070 /drivers/thermal | |
parent | d069015e268bcac6c8bd8997b3235f5f977d3ab6 (diff) |
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>
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/step_wise.c | 64 |
1 files changed, 46 insertions, 18 deletions
diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c index 0cd5e9fbab1c..f45dd0f768f0 100644 --- a/drivers/thermal/step_wise.c +++ b/drivers/thermal/step_wise.c | |||
@@ -35,21 +35,54 @@ | |||
35 | * state for this trip point | 35 | * state for this trip point |
36 | * b. if the trend is THERMAL_TREND_DROPPING, use lower cooling | 36 | * b. if the trend is THERMAL_TREND_DROPPING, use lower cooling |
37 | * state for this trip point | 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 | static unsigned long get_target_state(struct thermal_instance *instance, | 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 | struct thermal_cooling_device *cdev = instance->cdev; | 55 | struct thermal_cooling_device *cdev = instance->cdev; |
43 | unsigned long cur_state; | 56 | unsigned long cur_state; |
44 | 57 | ||
45 | cdev->ops->get_cur_state(cdev, &cur_state); | 58 | cdev->ops->get_cur_state(cdev, &cur_state); |
46 | 59 | ||
47 | if (trend == THERMAL_TREND_RAISING) { | 60 | switch (trend) { |
48 | cur_state = cur_state < instance->upper ? | 61 | case THERMAL_TREND_RAISING: |
49 | (cur_state + 1) : instance->upper; | 62 | if (throttle) |
50 | } else if (trend == THERMAL_TREND_DROPPING) { | 63 | cur_state = cur_state < instance->upper ? |
51 | cur_state = cur_state > instance->lower ? | 64 | (cur_state + 1) : instance->upper; |
52 | (cur_state - 1) : instance->lower; | 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 | return cur_state; | 88 | return cur_state; |
@@ -76,7 +109,7 @@ static void update_instance_for_throttle(struct thermal_zone_device *tz, | |||
76 | if (instance->trip != trip) | 109 | if (instance->trip != trip) |
77 | continue; | 110 | continue; |
78 | 111 | ||
79 | instance->target = get_target_state(instance, trend); | 112 | instance->target = get_target_state(instance, trend, true); |
80 | 113 | ||
81 | /* Activate a passive thermal instance */ | 114 | /* Activate a passive thermal instance */ |
82 | if (instance->target == THERMAL_NO_TARGET) | 115 | if (instance->target == THERMAL_NO_TARGET) |
@@ -87,28 +120,23 @@ static void update_instance_for_throttle(struct thermal_zone_device *tz, | |||
87 | } | 120 | } |
88 | 121 | ||
89 | static void update_instance_for_dethrottle(struct thermal_zone_device *tz, | 122 | static void update_instance_for_dethrottle(struct thermal_zone_device *tz, |
90 | int trip, enum thermal_trip_type trip_type) | 123 | int trip, enum thermal_trip_type trip_type, |
124 | enum thermal_trend trend) | ||
91 | { | 125 | { |
92 | struct thermal_instance *instance; | 126 | struct thermal_instance *instance; |
93 | struct thermal_cooling_device *cdev; | ||
94 | unsigned long cur_state; | ||
95 | 127 | ||
96 | list_for_each_entry(instance, &tz->thermal_instances, tz_node) { | 128 | list_for_each_entry(instance, &tz->thermal_instances, tz_node) { |
97 | if (instance->trip != trip || | 129 | if (instance->trip != trip || |
98 | instance->target == THERMAL_NO_TARGET) | 130 | instance->target == THERMAL_NO_TARGET) |
99 | continue; | 131 | continue; |
100 | 132 | ||
101 | cdev = instance->cdev; | 133 | instance->target = get_target_state(instance, trend, false); |
102 | cdev->ops->get_cur_state(cdev, &cur_state); | ||
103 | |||
104 | instance->target = cur_state > instance->lower ? | ||
105 | (cur_state - 1) : THERMAL_NO_TARGET; | ||
106 | 134 | ||
107 | /* Deactivate a passive thermal instance */ | 135 | /* Deactivate a passive thermal instance */ |
108 | if (instance->target == THERMAL_NO_TARGET) | 136 | if (instance->target == THERMAL_NO_TARGET) |
109 | update_passive_instance(tz, trip_type, -1); | 137 | update_passive_instance(tz, trip_type, -1); |
110 | 138 | ||
111 | cdev->updated = false; /* cdev needs update */ | 139 | instance->cdev->updated = false; /* cdev needs update */ |
112 | } | 140 | } |
113 | } | 141 | } |
114 | 142 | ||
@@ -133,7 +161,7 @@ static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) | |||
133 | if (tz->temperature >= trip_temp) | 161 | if (tz->temperature >= trip_temp) |
134 | update_instance_for_throttle(tz, trip, trip_type, trend); | 162 | update_instance_for_throttle(tz, trip, trip_type, trend); |
135 | else | 163 | else |
136 | update_instance_for_dethrottle(tz, trip, trip_type); | 164 | update_instance_for_dethrottle(tz, trip, trip_type, trend); |
137 | 165 | ||
138 | mutex_unlock(&tz->lock); | 166 | mutex_unlock(&tz->lock); |
139 | } | 167 | } |