aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/processor_thermal.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/processor_thermal.c')
-rw-r--r--drivers/acpi/processor_thermal.c178
1 files changed, 0 insertions, 178 deletions
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 953b25fb9869..fde49b9b1d99 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -44,47 +44,6 @@
44#define _COMPONENT ACPI_PROCESSOR_COMPONENT 44#define _COMPONENT ACPI_PROCESSOR_COMPONENT
45ACPI_MODULE_NAME("processor_thermal"); 45ACPI_MODULE_NAME("processor_thermal");
46 46
47/* --------------------------------------------------------------------------
48 Limit Interface
49 -------------------------------------------------------------------------- */
50static int acpi_processor_apply_limit(struct acpi_processor *pr)
51{
52 int result = 0;
53 u16 px = 0;
54 u16 tx = 0;
55
56
57 if (!pr)
58 return -EINVAL;
59
60 if (!pr->flags.limit)
61 return -ENODEV;
62
63 if (pr->flags.throttling) {
64 if (pr->limit.user.tx > tx)
65 tx = pr->limit.user.tx;
66 if (pr->limit.thermal.tx > tx)
67 tx = pr->limit.thermal.tx;
68
69 result = acpi_processor_set_throttling(pr, tx, false);
70 if (result)
71 goto end;
72 }
73
74 pr->limit.state.px = px;
75 pr->limit.state.tx = tx;
76
77 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
78 "Processor [%d] limit set to (P%d:T%d)\n", pr->id,
79 pr->limit.state.px, pr->limit.state.tx));
80
81 end:
82 if (result)
83 printk(KERN_ERR PREFIX "Unable to set limit\n");
84
85 return result;
86}
87
88#ifdef CONFIG_CPU_FREQ 47#ifdef CONFIG_CPU_FREQ
89 48
90/* If a passive cooling situation is detected, primarily CPUfreq is used, as it 49/* If a passive cooling situation is detected, primarily CPUfreq is used, as it
@@ -107,36 +66,6 @@ static int cpu_has_cpufreq(unsigned int cpu)
107 return 1; 66 return 1;
108} 67}
109 68
110static int acpi_thermal_cpufreq_increase(unsigned int cpu)
111{
112 if (!cpu_has_cpufreq(cpu))
113 return -ENODEV;
114
115 if (per_cpu(cpufreq_thermal_reduction_pctg, cpu) <
116 CPUFREQ_THERMAL_MAX_STEP) {
117 per_cpu(cpufreq_thermal_reduction_pctg, cpu)++;
118 cpufreq_update_policy(cpu);
119 return 0;
120 }
121
122 return -ERANGE;
123}
124
125static int acpi_thermal_cpufreq_decrease(unsigned int cpu)
126{
127 if (!cpu_has_cpufreq(cpu))
128 return -ENODEV;
129
130 if (per_cpu(cpufreq_thermal_reduction_pctg, cpu) >
131 (CPUFREQ_THERMAL_MIN_STEP + 1))
132 per_cpu(cpufreq_thermal_reduction_pctg, cpu)--;
133 else
134 per_cpu(cpufreq_thermal_reduction_pctg, cpu) = 0;
135 cpufreq_update_policy(cpu);
136 /* We reached max freq again and can leave passive mode */
137 return !per_cpu(cpufreq_thermal_reduction_pctg, cpu);
138}
139
140static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb, 69static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb,
141 unsigned long event, void *data) 70 unsigned long event, void *data)
142{ 71{
@@ -238,113 +167,6 @@ static int acpi_thermal_cpufreq_decrease(unsigned int cpu)
238 167
239#endif 168#endif
240 169
241int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
242{
243 int result = 0;
244 struct acpi_processor *pr = NULL;
245 struct acpi_device *device = NULL;
246 int tx = 0, max_tx_px = 0;
247
248
249 if ((type < ACPI_PROCESSOR_LIMIT_NONE)
250 || (type > ACPI_PROCESSOR_LIMIT_DECREMENT))
251 return -EINVAL;
252
253 result = acpi_bus_get_device(handle, &device);
254 if (result)
255 return result;
256
257 pr = acpi_driver_data(device);
258 if (!pr)
259 return -ENODEV;
260
261 /* Thermal limits are always relative to the current Px/Tx state. */
262 if (pr->flags.throttling)
263 pr->limit.thermal.tx = pr->throttling.state;
264
265 /*
266 * Our default policy is to only use throttling at the lowest
267 * performance state.
268 */
269
270 tx = pr->limit.thermal.tx;
271
272 switch (type) {
273
274 case ACPI_PROCESSOR_LIMIT_NONE:
275 do {
276 result = acpi_thermal_cpufreq_decrease(pr->id);
277 } while (!result);
278 tx = 0;
279 break;
280
281 case ACPI_PROCESSOR_LIMIT_INCREMENT:
282 /* if going up: P-states first, T-states later */
283
284 result = acpi_thermal_cpufreq_increase(pr->id);
285 if (!result)
286 goto end;
287 else if (result == -ERANGE)
288 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
289 "At maximum performance state\n"));
290
291 if (pr->flags.throttling) {
292 if (tx == (pr->throttling.state_count - 1))
293 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
294 "At maximum throttling state\n"));
295 else
296 tx++;
297 }
298 break;
299
300 case ACPI_PROCESSOR_LIMIT_DECREMENT:
301 /* if going down: T-states first, P-states later */
302
303 if (pr->flags.throttling) {
304 if (tx == 0) {
305 max_tx_px = 1;
306 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
307 "At minimum throttling state\n"));
308 } else {
309 tx--;
310 goto end;
311 }
312 }
313
314 result = acpi_thermal_cpufreq_decrease(pr->id);
315 if (result) {
316 /*
317 * We only could get -ERANGE, 1 or 0.
318 * In the first two cases we reached max freq again.
319 */
320 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
321 "At minimum performance state\n"));
322 max_tx_px = 1;
323 } else
324 max_tx_px = 0;
325
326 break;
327 }
328
329 end:
330 if (pr->flags.throttling) {
331 pr->limit.thermal.px = 0;
332 pr->limit.thermal.tx = tx;
333
334 result = acpi_processor_apply_limit(pr);
335 if (result)
336 printk(KERN_ERR PREFIX "Unable to set thermal limit\n");
337
338 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Thermal limit now (P%d:T%d)\n",
339 pr->limit.thermal.px, pr->limit.thermal.tx));
340 } else
341 result = 0;
342 if (max_tx_px)
343 return 1;
344 else
345 return result;
346}
347
348int acpi_processor_get_limit_info(struct acpi_processor *pr) 170int acpi_processor_get_limit_info(struct acpi_processor *pr)
349{ 171{
350 172