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.c153
1 files changed, 69 insertions, 84 deletions
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 12bd980a12e9..37528c3b64b0 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -43,20 +43,16 @@
43#define ACPI_PROCESSOR_CLASS "processor" 43#define ACPI_PROCESSOR_CLASS "processor"
44#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" 44#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver"
45#define _COMPONENT ACPI_PROCESSOR_COMPONENT 45#define _COMPONENT ACPI_PROCESSOR_COMPONENT
46ACPI_MODULE_NAME ("acpi_processor") 46ACPI_MODULE_NAME("acpi_processor")
47
48 47
49/* -------------------------------------------------------------------------- 48/* --------------------------------------------------------------------------
50 Limit Interface 49 Limit Interface
51 -------------------------------------------------------------------------- */ 50 -------------------------------------------------------------------------- */
52 51static int acpi_processor_apply_limit(struct acpi_processor *pr)
53static int
54acpi_processor_apply_limit (
55 struct acpi_processor* pr)
56{ 52{
57 int result = 0; 53 int result = 0;
58 u16 px = 0; 54 u16 px = 0;
59 u16 tx = 0; 55 u16 tx = 0;
60 56
61 ACPI_FUNCTION_TRACE("acpi_processor_apply_limit"); 57 ACPI_FUNCTION_TRACE("acpi_processor_apply_limit");
62 58
@@ -80,19 +76,17 @@ acpi_processor_apply_limit (
80 pr->limit.state.px = px; 76 pr->limit.state.px = px;
81 pr->limit.state.tx = tx; 77 pr->limit.state.tx = tx;
82 78
83 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d] limit set to (P%d:T%d)\n", 79 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
84 pr->id, 80 "Processor [%d] limit set to (P%d:T%d)\n", pr->id,
85 pr->limit.state.px, 81 pr->limit.state.px, pr->limit.state.tx));
86 pr->limit.state.tx));
87 82
88end: 83 end:
89 if (result) 84 if (result)
90 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to set limit\n")); 85 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to set limit\n"));
91 86
92 return_VALUE(result); 87 return_VALUE(result);
93} 88}
94 89
95
96#ifdef CONFIG_CPU_FREQ 90#ifdef CONFIG_CPU_FREQ
97 91
98/* If a passive cooling situation is detected, primarily CPUfreq is used, as it 92/* If a passive cooling situation is detected, primarily CPUfreq is used, as it
@@ -104,7 +98,6 @@ end:
104static unsigned int cpufreq_thermal_reduction_pctg[NR_CPUS]; 98static unsigned int cpufreq_thermal_reduction_pctg[NR_CPUS];
105static unsigned int acpi_thermal_cpufreq_is_init = 0; 99static unsigned int acpi_thermal_cpufreq_is_init = 0;
106 100
107
108static int cpu_has_cpufreq(unsigned int cpu) 101static int cpu_has_cpufreq(unsigned int cpu)
109{ 102{
110 struct cpufreq_policy policy; 103 struct cpufreq_policy policy;
@@ -115,7 +108,6 @@ static int cpu_has_cpufreq(unsigned int cpu)
115 return 0; 108 return 0;
116} 109}
117 110
118
119static int acpi_thermal_cpufreq_increase(unsigned int cpu) 111static int acpi_thermal_cpufreq_increase(unsigned int cpu)
120{ 112{
121 if (!cpu_has_cpufreq(cpu)) 113 if (!cpu_has_cpufreq(cpu))
@@ -130,7 +122,6 @@ static int acpi_thermal_cpufreq_increase(unsigned int cpu)
130 return -ERANGE; 122 return -ERANGE;
131} 123}
132 124
133
134static int acpi_thermal_cpufreq_decrease(unsigned int cpu) 125static int acpi_thermal_cpufreq_decrease(unsigned int cpu)
135{ 126{
136 if (!cpu_has_cpufreq(cpu)) 127 if (!cpu_has_cpufreq(cpu))
@@ -145,11 +136,8 @@ static int acpi_thermal_cpufreq_decrease(unsigned int cpu)
145 return -ERANGE; 136 return -ERANGE;
146} 137}
147 138
148 139static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb,
149static int acpi_thermal_cpufreq_notifier( 140 unsigned long event, void *data)
150 struct notifier_block *nb,
151 unsigned long event,
152 void *data)
153{ 141{
154 struct cpufreq_policy *policy = data; 142 struct cpufreq_policy *policy = data;
155 unsigned long max_freq = 0; 143 unsigned long max_freq = 0;
@@ -157,68 +145,74 @@ static int acpi_thermal_cpufreq_notifier(
157 if (event != CPUFREQ_ADJUST) 145 if (event != CPUFREQ_ADJUST)
158 goto out; 146 goto out;
159 147
160 max_freq = (policy->cpuinfo.max_freq * (100 - cpufreq_thermal_reduction_pctg[policy->cpu])) / 100; 148 max_freq =
149 (policy->cpuinfo.max_freq *
150 (100 - cpufreq_thermal_reduction_pctg[policy->cpu])) / 100;
161 151
162 cpufreq_verify_within_limits(policy, 0, max_freq); 152 cpufreq_verify_within_limits(policy, 0, max_freq);
163 153
164 out: 154 out:
165 return 0; 155 return 0;
166} 156}
167 157
168
169static struct notifier_block acpi_thermal_cpufreq_notifier_block = { 158static struct notifier_block acpi_thermal_cpufreq_notifier_block = {
170 .notifier_call = acpi_thermal_cpufreq_notifier, 159 .notifier_call = acpi_thermal_cpufreq_notifier,
171}; 160};
172 161
173 162void acpi_thermal_cpufreq_init(void)
174void acpi_thermal_cpufreq_init(void) { 163{
175 int i; 164 int i;
176 165
177 for (i=0; i<NR_CPUS; i++) 166 for (i = 0; i < NR_CPUS; i++)
178 cpufreq_thermal_reduction_pctg[i] = 0; 167 cpufreq_thermal_reduction_pctg[i] = 0;
179 168
180 i = cpufreq_register_notifier(&acpi_thermal_cpufreq_notifier_block, CPUFREQ_POLICY_NOTIFIER); 169 i = cpufreq_register_notifier(&acpi_thermal_cpufreq_notifier_block,
170 CPUFREQ_POLICY_NOTIFIER);
181 if (!i) 171 if (!i)
182 acpi_thermal_cpufreq_is_init = 1; 172 acpi_thermal_cpufreq_is_init = 1;
183} 173}
184 174
185void acpi_thermal_cpufreq_exit(void) { 175void acpi_thermal_cpufreq_exit(void)
176{
186 if (acpi_thermal_cpufreq_is_init) 177 if (acpi_thermal_cpufreq_is_init)
187 cpufreq_unregister_notifier(&acpi_thermal_cpufreq_notifier_block, CPUFREQ_POLICY_NOTIFIER); 178 cpufreq_unregister_notifier
179 (&acpi_thermal_cpufreq_notifier_block,
180 CPUFREQ_POLICY_NOTIFIER);
188 181
189 acpi_thermal_cpufreq_is_init = 0; 182 acpi_thermal_cpufreq_is_init = 0;
190} 183}
191 184
192#else /* ! CONFIG_CPU_FREQ */ 185#else /* ! CONFIG_CPU_FREQ */
193
194static int acpi_thermal_cpufreq_increase(unsigned int cpu) { return -ENODEV; }
195static int acpi_thermal_cpufreq_decrease(unsigned int cpu) { return -ENODEV; }
196 186
187static int acpi_thermal_cpufreq_increase(unsigned int cpu)
188{
189 return -ENODEV;
190}
191static int acpi_thermal_cpufreq_decrease(unsigned int cpu)
192{
193 return -ENODEV;
194}
197 195
198#endif 196#endif
199 197
200 198int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
201int
202acpi_processor_set_thermal_limit (
203 acpi_handle handle,
204 int type)
205{ 199{
206 int result = 0; 200 int result = 0;
207 struct acpi_processor *pr = NULL; 201 struct acpi_processor *pr = NULL;
208 struct acpi_device *device = NULL; 202 struct acpi_device *device = NULL;
209 int tx = 0; 203 int tx = 0;
210 204
211 ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit"); 205 ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit");
212 206
213 if ((type < ACPI_PROCESSOR_LIMIT_NONE) 207 if ((type < ACPI_PROCESSOR_LIMIT_NONE)
214 || (type > ACPI_PROCESSOR_LIMIT_DECREMENT)) 208 || (type > ACPI_PROCESSOR_LIMIT_DECREMENT))
215 return_VALUE(-EINVAL); 209 return_VALUE(-EINVAL);
216 210
217 result = acpi_bus_get_device(handle, &device); 211 result = acpi_bus_get_device(handle, &device);
218 if (result) 212 if (result)
219 return_VALUE(result); 213 return_VALUE(result);
220 214
221 pr = (struct acpi_processor *) acpi_driver_data(device); 215 pr = (struct acpi_processor *)acpi_driver_data(device);
222 if (!pr) 216 if (!pr)
223 return_VALUE(-ENODEV); 217 return_VALUE(-ENODEV);
224 218
@@ -250,12 +244,12 @@ acpi_processor_set_thermal_limit (
250 goto end; 244 goto end;
251 else if (result == -ERANGE) 245 else if (result == -ERANGE)
252 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 246 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
253 "At maximum performance state\n")); 247 "At maximum performance state\n"));
254 248
255 if (pr->flags.throttling) { 249 if (pr->flags.throttling) {
256 if (tx == (pr->throttling.state_count - 1)) 250 if (tx == (pr->throttling.state_count - 1))
257 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 251 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
258 "At maximum throttling state\n")); 252 "At maximum throttling state\n"));
259 else 253 else
260 tx++; 254 tx++;
261 } 255 }
@@ -267,7 +261,7 @@ acpi_processor_set_thermal_limit (
267 if (pr->flags.throttling) { 261 if (pr->flags.throttling) {
268 if (tx == 0) 262 if (tx == 0)
269 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 263 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
270 "At minimum throttling state\n")); 264 "At minimum throttling state\n"));
271 else { 265 else {
272 tx--; 266 tx--;
273 goto end; 267 goto end;
@@ -277,12 +271,12 @@ acpi_processor_set_thermal_limit (
277 result = acpi_thermal_cpufreq_decrease(pr->id); 271 result = acpi_thermal_cpufreq_decrease(pr->id);
278 if (result == -ERANGE) 272 if (result == -ERANGE)
279 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 273 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
280 "At minimum performance state\n")); 274 "At minimum performance state\n"));
281 275
282 break; 276 break;
283 } 277 }
284 278
285end: 279 end:
286 if (pr->flags.throttling) { 280 if (pr->flags.throttling) {
287 pr->limit.thermal.px = 0; 281 pr->limit.thermal.px = 0;
288 pr->limit.thermal.tx = tx; 282 pr->limit.thermal.tx = tx;
@@ -293,18 +287,14 @@ end:
293 "Unable to set thermal limit\n")); 287 "Unable to set thermal limit\n"));
294 288
295 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Thermal limit now (P%d:T%d)\n", 289 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Thermal limit now (P%d:T%d)\n",
296 pr->limit.thermal.px, 290 pr->limit.thermal.px, pr->limit.thermal.tx));
297 pr->limit.thermal.tx));
298 } else 291 } else
299 result = 0; 292 result = 0;
300 293
301 return_VALUE(result); 294 return_VALUE(result);
302} 295}
303 296
304 297int acpi_processor_get_limit_info(struct acpi_processor *pr)
305int
306acpi_processor_get_limit_info (
307 struct acpi_processor *pr)
308{ 298{
309 ACPI_FUNCTION_TRACE("acpi_processor_get_limit_info"); 299 ACPI_FUNCTION_TRACE("acpi_processor_get_limit_info");
310 300
@@ -317,12 +307,11 @@ acpi_processor_get_limit_info (
317 return_VALUE(0); 307 return_VALUE(0);
318} 308}
319 309
320
321/* /proc interface */ 310/* /proc interface */
322 311
323static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset) 312static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset)
324{ 313{
325 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 314 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
326 315
327 ACPI_FUNCTION_TRACE("acpi_processor_limit_seq_show"); 316 ACPI_FUNCTION_TRACE("acpi_processor_limit_seq_show");
328 317
@@ -335,34 +324,32 @@ static int acpi_processor_limit_seq_show(struct seq_file *seq, void *offset)
335 } 324 }
336 325
337 seq_printf(seq, "active limit: P%d:T%d\n" 326 seq_printf(seq, "active limit: P%d:T%d\n"
338 "user limit: P%d:T%d\n" 327 "user limit: P%d:T%d\n"
339 "thermal limit: P%d:T%d\n", 328 "thermal limit: P%d:T%d\n",
340 pr->limit.state.px, pr->limit.state.tx, 329 pr->limit.state.px, pr->limit.state.tx,
341 pr->limit.user.px, pr->limit.user.tx, 330 pr->limit.user.px, pr->limit.user.tx,
342 pr->limit.thermal.px, pr->limit.thermal.tx); 331 pr->limit.thermal.px, pr->limit.thermal.tx);
343 332
344end: 333 end:
345 return_VALUE(0); 334 return_VALUE(0);
346} 335}
347 336
348static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file) 337static int acpi_processor_limit_open_fs(struct inode *inode, struct file *file)
349{ 338{
350 return single_open(file, acpi_processor_limit_seq_show, 339 return single_open(file, acpi_processor_limit_seq_show,
351 PDE(inode)->data); 340 PDE(inode)->data);
352} 341}
353 342
354ssize_t acpi_processor_write_limit ( 343ssize_t acpi_processor_write_limit(struct file * file,
355 struct file *file, 344 const char __user * buffer,
356 const char __user *buffer, 345 size_t count, loff_t * data)
357 size_t count,
358 loff_t *data)
359{ 346{
360 int result = 0; 347 int result = 0;
361 struct seq_file *m = (struct seq_file *)file->private_data; 348 struct seq_file *m = (struct seq_file *)file->private_data;
362 struct acpi_processor *pr = (struct acpi_processor *)m->private; 349 struct acpi_processor *pr = (struct acpi_processor *)m->private;
363 char limit_string[25] = {'\0'}; 350 char limit_string[25] = { '\0' };
364 int px = 0; 351 int px = 0;
365 int tx = 0; 352 int tx = 0;
366 353
367 ACPI_FUNCTION_TRACE("acpi_processor_write_limit"); 354 ACPI_FUNCTION_TRACE("acpi_processor_write_limit");
368 355
@@ -396,11 +383,9 @@ ssize_t acpi_processor_write_limit (
396 return_VALUE(count); 383 return_VALUE(count);
397} 384}
398 385
399
400struct file_operations acpi_processor_limit_fops = { 386struct file_operations acpi_processor_limit_fops = {
401 .open = acpi_processor_limit_open_fs, 387 .open = acpi_processor_limit_open_fs,
402 .read = seq_read, 388 .read = seq_read,
403 .llseek = seq_lseek, 389 .llseek = seq_lseek,
404 .release = single_release, 390 .release = single_release,
405}; 391};
406