aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/processor_throttling.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/processor_throttling.c')
-rw-r--r--drivers/acpi/processor_throttling.c133
1 files changed, 62 insertions, 71 deletions
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index be9f569d39d3..74a52d4e79ae 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -43,21 +43,17 @@
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 Throttling Control 49 Throttling Control
51 -------------------------------------------------------------------------- */ 50 -------------------------------------------------------------------------- */
52 51static int acpi_processor_get_throttling(struct acpi_processor *pr)
53static int
54acpi_processor_get_throttling (
55 struct acpi_processor *pr)
56{ 52{
57 int state = 0; 53 int state = 0;
58 u32 value = 0; 54 u32 value = 0;
59 u32 duty_mask = 0; 55 u32 duty_mask = 0;
60 u32 duty_value = 0; 56 u32 duty_value = 0;
61 57
62 ACPI_FUNCTION_TRACE("acpi_processor_get_throttling"); 58 ACPI_FUNCTION_TRACE("acpi_processor_get_throttling");
63 59
@@ -86,7 +82,7 @@ acpi_processor_get_throttling (
86 duty_value >>= pr->throttling.duty_offset; 82 duty_value >>= pr->throttling.duty_offset;
87 83
88 if (duty_value) 84 if (duty_value)
89 state = pr->throttling.state_count-duty_value; 85 state = pr->throttling.state_count - duty_value;
90 } 86 }
91 87
92 pr->throttling.state = state; 88 pr->throttling.state = state;
@@ -94,20 +90,17 @@ acpi_processor_get_throttling (
94 local_irq_enable(); 90 local_irq_enable();
95 91
96 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 92 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
97 "Throttling state is T%d (%d%% throttling applied)\n", 93 "Throttling state is T%d (%d%% throttling applied)\n",
98 state, pr->throttling.states[state].performance)); 94 state, pr->throttling.states[state].performance));
99 95
100 return_VALUE(0); 96 return_VALUE(0);
101} 97}
102 98
103 99int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
104int acpi_processor_set_throttling (
105 struct acpi_processor *pr,
106 int state)
107{ 100{
108 u32 value = 0; 101 u32 value = 0;
109 u32 duty_mask = 0; 102 u32 duty_mask = 0;
110 u32 duty_value = 0; 103 u32 duty_value = 0;
111 104
112 ACPI_FUNCTION_TRACE("acpi_processor_set_throttling"); 105 ACPI_FUNCTION_TRACE("acpi_processor_set_throttling");
113 106
@@ -168,28 +161,26 @@ int acpi_processor_set_throttling (
168 local_irq_enable(); 161 local_irq_enable();
169 162
170 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 163 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
171 "Throttling state set to T%d (%d%%)\n", state, 164 "Throttling state set to T%d (%d%%)\n", state,
172 (pr->throttling.states[state].performance?pr->throttling.states[state].performance/10:0))); 165 (pr->throttling.states[state].performance ? pr->
166 throttling.states[state].performance / 10 : 0)));
173 167
174 return_VALUE(0); 168 return_VALUE(0);
175} 169}
176 170
177 171int acpi_processor_get_throttling_info(struct acpi_processor *pr)
178int
179acpi_processor_get_throttling_info (
180 struct acpi_processor *pr)
181{ 172{
182 int result = 0; 173 int result = 0;
183 int step = 0; 174 int step = 0;
184 int i = 0; 175 int i = 0;
185 176
186 ACPI_FUNCTION_TRACE("acpi_processor_get_throttling_info"); 177 ACPI_FUNCTION_TRACE("acpi_processor_get_throttling_info");
187 178
188 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 179 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
189 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", 180 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
190 pr->throttling.address, 181 pr->throttling.address,
191 pr->throttling.duty_offset, 182 pr->throttling.duty_offset,
192 pr->throttling.duty_width)); 183 pr->throttling.duty_width));
193 184
194 if (!pr) 185 if (!pr)
195 return_VALUE(-EINVAL); 186 return_VALUE(-EINVAL);
@@ -199,14 +190,12 @@ acpi_processor_get_throttling_info (
199 if (!pr->throttling.address) { 190 if (!pr->throttling.address) {
200 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n")); 191 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
201 return_VALUE(0); 192 return_VALUE(0);
202 } 193 } else if (!pr->throttling.duty_width) {
203 else if (!pr->throttling.duty_width) {
204 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n")); 194 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
205 return_VALUE(0); 195 return_VALUE(0);
206 } 196 }
207 /* TBD: Support duty_cycle values that span bit 4. */ 197 /* TBD: Support duty_cycle values that span bit 4. */
208 else if ((pr->throttling.duty_offset 198 else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
209 + pr->throttling.duty_width) > 4) {
210 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "duty_cycle spans bit 4\n")); 199 ACPI_DEBUG_PRINT((ACPI_DB_WARN, "duty_cycle spans bit 4\n"));
211 return_VALUE(0); 200 return_VALUE(0);
212 } 201 }
@@ -218,7 +207,7 @@ acpi_processor_get_throttling_info (
218 */ 207 */
219 if (errata.piix4.throttle) { 208 if (errata.piix4.throttle) {
220 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 209 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
221 "Throttling not supported on PIIX4 A- or B-step\n")); 210 "Throttling not supported on PIIX4 A- or B-step\n"));
222 return_VALUE(0); 211 return_VALUE(0);
223 } 212 }
224 213
@@ -232,13 +221,13 @@ acpi_processor_get_throttling_info (
232 221
233 step = (1000 / pr->throttling.state_count); 222 step = (1000 / pr->throttling.state_count);
234 223
235 for (i=0; i<pr->throttling.state_count; i++) { 224 for (i = 0; i < pr->throttling.state_count; i++) {
236 pr->throttling.states[i].performance = step * i; 225 pr->throttling.states[i].performance = step * i;
237 pr->throttling.states[i].power = step * i; 226 pr->throttling.states[i].power = step * i;
238 } 227 }
239 228
240 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n", 229 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n",
241 pr->throttling.state_count)); 230 pr->throttling.state_count));
242 231
243 pr->flags.throttling = 1; 232 pr->flags.throttling = 1;
244 233
@@ -253,28 +242,29 @@ acpi_processor_get_throttling_info (
253 goto end; 242 goto end;
254 243
255 if (pr->throttling.state) { 244 if (pr->throttling.state) {
256 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Disabling throttling (was T%d)\n", 245 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
257 pr->throttling.state)); 246 "Disabling throttling (was T%d)\n",
247 pr->throttling.state));
258 result = acpi_processor_set_throttling(pr, 0); 248 result = acpi_processor_set_throttling(pr, 0);
259 if (result) 249 if (result)
260 goto end; 250 goto end;
261 } 251 }
262 252
263end: 253 end:
264 if (result) 254 if (result)
265 pr->flags.throttling = 0; 255 pr->flags.throttling = 0;
266 256
267 return_VALUE(result); 257 return_VALUE(result);
268} 258}
269 259
270
271/* proc interface */ 260/* proc interface */
272 261
273static int acpi_processor_throttling_seq_show(struct seq_file *seq, void *offset) 262static int acpi_processor_throttling_seq_show(struct seq_file *seq,
263 void *offset)
274{ 264{
275 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 265 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
276 int i = 0; 266 int i = 0;
277 int result = 0; 267 int result = 0;
278 268
279 ACPI_FUNCTION_TRACE("acpi_processor_throttling_seq_show"); 269 ACPI_FUNCTION_TRACE("acpi_processor_throttling_seq_show");
280 270
@@ -289,41 +279,41 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq, void *offset
289 result = acpi_processor_get_throttling(pr); 279 result = acpi_processor_get_throttling(pr);
290 280
291 if (result) { 281 if (result) {
292 seq_puts(seq, "Could not determine current throttling state.\n"); 282 seq_puts(seq,
283 "Could not determine current throttling state.\n");
293 goto end; 284 goto end;
294 } 285 }
295 286
296 seq_printf(seq, "state count: %d\n" 287 seq_printf(seq, "state count: %d\n"
297 "active state: T%d\n", 288 "active state: T%d\n",
298 pr->throttling.state_count, 289 pr->throttling.state_count, pr->throttling.state);
299 pr->throttling.state);
300 290
301 seq_puts(seq, "states:\n"); 291 seq_puts(seq, "states:\n");
302 for (i = 0; i < pr->throttling.state_count; i++) 292 for (i = 0; i < pr->throttling.state_count; i++)
303 seq_printf(seq, " %cT%d: %02d%%\n", 293 seq_printf(seq, " %cT%d: %02d%%\n",
304 (i == pr->throttling.state?'*':' '), i, 294 (i == pr->throttling.state ? '*' : ' '), i,
305 (pr->throttling.states[i].performance?pr->throttling.states[i].performance/10:0)); 295 (pr->throttling.states[i].performance ? pr->
296 throttling.states[i].performance / 10 : 0));
306 297
307end: 298 end:
308 return_VALUE(0); 299 return_VALUE(0);
309} 300}
310 301
311static int acpi_processor_throttling_open_fs(struct inode *inode, struct file *file) 302static int acpi_processor_throttling_open_fs(struct inode *inode,
303 struct file *file)
312{ 304{
313 return single_open(file, acpi_processor_throttling_seq_show, 305 return single_open(file, acpi_processor_throttling_seq_show,
314 PDE(inode)->data); 306 PDE(inode)->data);
315} 307}
316 308
317ssize_t acpi_processor_write_throttling ( 309ssize_t acpi_processor_write_throttling(struct file * file,
318 struct file *file, 310 const char __user * buffer,
319 const char __user *buffer, 311 size_t count, loff_t * data)
320 size_t count,
321 loff_t *data)
322{ 312{
323 int result = 0; 313 int result = 0;
324 struct seq_file *m = (struct seq_file *)file->private_data; 314 struct seq_file *m = (struct seq_file *)file->private_data;
325 struct acpi_processor *pr = (struct acpi_processor *)m->private; 315 struct acpi_processor *pr = (struct acpi_processor *)m->private;
326 char state_string[12] = {'\0'}; 316 char state_string[12] = { '\0' };
327 317
328 ACPI_FUNCTION_TRACE("acpi_processor_write_throttling"); 318 ACPI_FUNCTION_TRACE("acpi_processor_write_throttling");
329 319
@@ -336,7 +326,8 @@ ssize_t acpi_processor_write_throttling (
336 state_string[count] = '\0'; 326 state_string[count] = '\0';
337 327
338 result = acpi_processor_set_throttling(pr, 328 result = acpi_processor_set_throttling(pr,
339 simple_strtoul(state_string, NULL, 0)); 329 simple_strtoul(state_string,
330 NULL, 0));
340 if (result) 331 if (result)
341 return_VALUE(result); 332 return_VALUE(result);
342 333
@@ -344,8 +335,8 @@ ssize_t acpi_processor_write_throttling (
344} 335}
345 336
346struct file_operations acpi_processor_throttling_fops = { 337struct file_operations acpi_processor_throttling_fops = {
347 .open = acpi_processor_throttling_open_fs, 338 .open = acpi_processor_throttling_open_fs,
348 .read = seq_read, 339 .read = seq_read,
349 .llseek = seq_lseek, 340 .llseek = seq_lseek,
350 .release = single_release, 341 .release = single_release,
351}; 342};