aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/processor_core.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-08-05 00:44:28 -0400
committerLen Brown <len.brown@intel.com>2005-08-05 00:45:14 -0400
commit4be44fcd3bf648b782f4460fd06dfae6c42ded4b (patch)
tree5b5b7d296ea58786f53b95e5eac9565ff66890b0 /drivers/acpi/processor_core.c
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/processor_core.c')
-rw-r--r--drivers/acpi/processor_core.c437
1 files changed, 191 insertions, 246 deletions
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index d56a439ac61..819cb0b453f 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -58,7 +58,6 @@
58#include <acpi/acpi_drivers.h> 58#include <acpi/acpi_drivers.h>
59#include <acpi/processor.h> 59#include <acpi/processor.h>
60 60
61
62#define ACPI_PROCESSOR_COMPONENT 0x01000000 61#define ACPI_PROCESSOR_COMPONENT 0x01000000
63#define ACPI_PROCESSOR_CLASS "processor" 62#define ACPI_PROCESSOR_CLASS "processor"
64#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver" 63#define ACPI_PROCESSOR_DRIVER_NAME "ACPI Processor Driver"
@@ -75,59 +74,53 @@
75#define ACPI_STA_PRESENT 0x00000001 74#define ACPI_STA_PRESENT 0x00000001
76 75
77#define _COMPONENT ACPI_PROCESSOR_COMPONENT 76#define _COMPONENT ACPI_PROCESSOR_COMPONENT
78ACPI_MODULE_NAME ("acpi_processor") 77ACPI_MODULE_NAME("acpi_processor")
79 78
80MODULE_AUTHOR("Paul Diefenbaugh"); 79 MODULE_AUTHOR("Paul Diefenbaugh");
81MODULE_DESCRIPTION(ACPI_PROCESSOR_DRIVER_NAME); 80MODULE_DESCRIPTION(ACPI_PROCESSOR_DRIVER_NAME);
82MODULE_LICENSE("GPL"); 81MODULE_LICENSE("GPL");
83 82
84 83static int acpi_processor_add(struct acpi_device *device);
85static int acpi_processor_add (struct acpi_device *device); 84static int acpi_processor_start(struct acpi_device *device);
86static int acpi_processor_start (struct acpi_device *device); 85static int acpi_processor_remove(struct acpi_device *device, int type);
87static int acpi_processor_remove (struct acpi_device *device, int type);
88static int acpi_processor_info_open_fs(struct inode *inode, struct file *file); 86static int acpi_processor_info_open_fs(struct inode *inode, struct file *file);
89static void acpi_processor_notify ( acpi_handle handle, u32 event, void *data); 87static void acpi_processor_notify(acpi_handle handle, u32 event, void *data);
90static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu); 88static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu);
91static int acpi_processor_handle_eject(struct acpi_processor *pr); 89static int acpi_processor_handle_eject(struct acpi_processor *pr);
92 90
93static struct acpi_driver acpi_processor_driver = { 91static struct acpi_driver acpi_processor_driver = {
94 .name = ACPI_PROCESSOR_DRIVER_NAME, 92 .name = ACPI_PROCESSOR_DRIVER_NAME,
95 .class = ACPI_PROCESSOR_CLASS, 93 .class = ACPI_PROCESSOR_CLASS,
96 .ids = ACPI_PROCESSOR_HID, 94 .ids = ACPI_PROCESSOR_HID,
97 .ops = { 95 .ops = {
98 .add = acpi_processor_add, 96 .add = acpi_processor_add,
99 .remove = acpi_processor_remove, 97 .remove = acpi_processor_remove,
100 .start = acpi_processor_start, 98 .start = acpi_processor_start,
101 }, 99 },
102}; 100};
103 101
104#define INSTALL_NOTIFY_HANDLER 1 102#define INSTALL_NOTIFY_HANDLER 1
105#define UNINSTALL_NOTIFY_HANDLER 2 103#define UNINSTALL_NOTIFY_HANDLER 2
106 104
107
108static struct file_operations acpi_processor_info_fops = { 105static struct file_operations acpi_processor_info_fops = {
109 .open = acpi_processor_info_open_fs, 106 .open = acpi_processor_info_open_fs,
110 .read = seq_read, 107 .read = seq_read,
111 .llseek = seq_lseek, 108 .llseek = seq_lseek,
112 .release = single_release, 109 .release = single_release,
113}; 110};
114 111
115 112struct acpi_processor *processors[NR_CPUS];
116struct acpi_processor *processors[NR_CPUS];
117struct acpi_processor_errata errata; 113struct acpi_processor_errata errata;
118 114
119
120/* -------------------------------------------------------------------------- 115/* --------------------------------------------------------------------------
121 Errata Handling 116 Errata Handling
122 -------------------------------------------------------------------------- */ 117 -------------------------------------------------------------------------- */
123 118
124static int 119static int acpi_processor_errata_piix4(struct pci_dev *dev)
125acpi_processor_errata_piix4 (
126 struct pci_dev *dev)
127{ 120{
128 u8 rev = 0; 121 u8 rev = 0;
129 u8 value1 = 0; 122 u8 value1 = 0;
130 u8 value2 = 0; 123 u8 value2 = 0;
131 124
132 ACPI_FUNCTION_TRACE("acpi_processor_errata_piix4"); 125 ACPI_FUNCTION_TRACE("acpi_processor_errata_piix4");
133 126
@@ -188,8 +181,8 @@ acpi_processor_errata_piix4 (
188 * DMA activity. 181 * DMA activity.
189 */ 182 */
190 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, 183 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
191 PCI_DEVICE_ID_INTEL_82371AB, 184 PCI_DEVICE_ID_INTEL_82371AB,
192 PCI_ANY_ID, PCI_ANY_ID, NULL); 185 PCI_ANY_ID, PCI_ANY_ID, NULL);
193 if (dev) { 186 if (dev) {
194 errata.piix4.bmisx = pci_resource_start(dev, 4); 187 errata.piix4.bmisx = pci_resource_start(dev, 4);
195 pci_dev_put(dev); 188 pci_dev_put(dev);
@@ -205,8 +198,8 @@ acpi_processor_errata_piix4 (
205 * devices won't operate well if fast DMA is disabled. 198 * devices won't operate well if fast DMA is disabled.
206 */ 199 */
207 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, 200 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
208 PCI_DEVICE_ID_INTEL_82371AB_0, 201 PCI_DEVICE_ID_INTEL_82371AB_0,
209 PCI_ANY_ID, PCI_ANY_ID, NULL); 202 PCI_ANY_ID, PCI_ANY_ID, NULL);
210 if (dev) { 203 if (dev) {
211 pci_read_config_byte(dev, 0x76, &value1); 204 pci_read_config_byte(dev, 0x76, &value1);
212 pci_read_config_byte(dev, 0x77, &value2); 205 pci_read_config_byte(dev, 0x77, &value2);
@@ -220,21 +213,18 @@ acpi_processor_errata_piix4 (
220 213
221 if (errata.piix4.bmisx) 214 if (errata.piix4.bmisx)
222 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 215 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
223 "Bus master activity detection (BM-IDE) erratum enabled\n")); 216 "Bus master activity detection (BM-IDE) erratum enabled\n"));
224 if (errata.piix4.fdma) 217 if (errata.piix4.fdma)
225 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 218 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
226 "Type-F DMA livelock erratum (C3 disabled)\n")); 219 "Type-F DMA livelock erratum (C3 disabled)\n"));
227 220
228 return_VALUE(0); 221 return_VALUE(0);
229} 222}
230 223
231 224int acpi_processor_errata(struct acpi_processor *pr)
232int
233acpi_processor_errata (
234 struct acpi_processor *pr)
235{ 225{
236 int result = 0; 226 int result = 0;
237 struct pci_dev *dev = NULL; 227 struct pci_dev *dev = NULL;
238 228
239 ACPI_FUNCTION_TRACE("acpi_processor_errata"); 229 ACPI_FUNCTION_TRACE("acpi_processor_errata");
240 230
@@ -245,7 +235,8 @@ acpi_processor_errata (
245 * PIIX4 235 * PIIX4
246 */ 236 */
247 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL, 237 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
248 PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID, PCI_ANY_ID, NULL); 238 PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID,
239 PCI_ANY_ID, NULL);
249 if (dev) { 240 if (dev) {
250 result = acpi_processor_errata_piix4(dev); 241 result = acpi_processor_errata_piix4(dev);
251 pci_dev_put(dev); 242 pci_dev_put(dev);
@@ -254,7 +245,6 @@ acpi_processor_errata (
254 return_VALUE(result); 245 return_VALUE(result);
255} 246}
256 247
257
258/* -------------------------------------------------------------------------- 248/* --------------------------------------------------------------------------
259 Common ACPI processor fucntions 249 Common ACPI processor fucntions
260 -------------------------------------------------------------------------- */ 250 -------------------------------------------------------------------------- */
@@ -265,13 +255,13 @@ acpi_processor_errata (
265 */ 255 */
266 256
267int acpi_processor_set_pdc(struct acpi_processor *pr, 257int acpi_processor_set_pdc(struct acpi_processor *pr,
268 struct acpi_object_list *pdc_in) 258 struct acpi_object_list *pdc_in)
269{ 259{
270 acpi_status status = AE_OK; 260 acpi_status status = AE_OK;
271 u32 arg0_buf[3]; 261 u32 arg0_buf[3];
272 union acpi_object arg0 = {ACPI_TYPE_BUFFER}; 262 union acpi_object arg0 = { ACPI_TYPE_BUFFER };
273 struct acpi_object_list no_object = {1, &arg0}; 263 struct acpi_object_list no_object = { 1, &arg0 };
274 struct acpi_object_list *pdc; 264 struct acpi_object_list *pdc;
275 265
276 ACPI_FUNCTION_TRACE("acpi_processor_set_pdc"); 266 ACPI_FUNCTION_TRACE("acpi_processor_set_pdc");
277 267
@@ -286,21 +276,21 @@ int acpi_processor_set_pdc(struct acpi_processor *pr,
286 status = acpi_evaluate_object(pr->handle, "_PDC", pdc, NULL); 276 status = acpi_evaluate_object(pr->handle, "_PDC", pdc, NULL);
287 277
288 if ((ACPI_FAILURE(status)) && (pdc_in)) 278 if ((ACPI_FAILURE(status)) && (pdc_in))
289 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Error evaluating _PDC, using legacy perf. control...\n")); 279 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
280 "Error evaluating _PDC, using legacy perf. control...\n"));
290 281
291 return_VALUE(status); 282 return_VALUE(status);
292} 283}
293 284
294
295/* -------------------------------------------------------------------------- 285/* --------------------------------------------------------------------------
296 FS Interface (/proc) 286 FS Interface (/proc)
297 -------------------------------------------------------------------------- */ 287 -------------------------------------------------------------------------- */
298 288
299static struct proc_dir_entry *acpi_processor_dir = NULL; 289static struct proc_dir_entry *acpi_processor_dir = NULL;
300 290
301static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset) 291static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
302{ 292{
303 struct acpi_processor *pr = (struct acpi_processor *)seq->private; 293 struct acpi_processor *pr = (struct acpi_processor *)seq->private;
304 294
305 ACPI_FUNCTION_TRACE("acpi_processor_info_seq_show"); 295 ACPI_FUNCTION_TRACE("acpi_processor_info_seq_show");
306 296
@@ -308,40 +298,37 @@ static int acpi_processor_info_seq_show(struct seq_file *seq, void *offset)
308 goto end; 298 goto end;
309 299
310 seq_printf(seq, "processor id: %d\n" 300 seq_printf(seq, "processor id: %d\n"
311 "acpi id: %d\n" 301 "acpi id: %d\n"
312 "bus mastering control: %s\n" 302 "bus mastering control: %s\n"
313 "power management: %s\n" 303 "power management: %s\n"
314 "throttling control: %s\n" 304 "throttling control: %s\n"
315 "limit interface: %s\n", 305 "limit interface: %s\n",
316 pr->id, 306 pr->id,
317 pr->acpi_id, 307 pr->acpi_id,
318 pr->flags.bm_control ? "yes" : "no", 308 pr->flags.bm_control ? "yes" : "no",
319 pr->flags.power ? "yes" : "no", 309 pr->flags.power ? "yes" : "no",
320 pr->flags.throttling ? "yes" : "no", 310 pr->flags.throttling ? "yes" : "no",
321 pr->flags.limit ? "yes" : "no"); 311 pr->flags.limit ? "yes" : "no");
322 312
323end: 313 end:
324 return_VALUE(0); 314 return_VALUE(0);
325} 315}
326 316
327static int acpi_processor_info_open_fs(struct inode *inode, struct file *file) 317static int acpi_processor_info_open_fs(struct inode *inode, struct file *file)
328{ 318{
329 return single_open(file, acpi_processor_info_seq_show, 319 return single_open(file, acpi_processor_info_seq_show,
330 PDE(inode)->data); 320 PDE(inode)->data);
331} 321}
332 322
333 323static int acpi_processor_add_fs(struct acpi_device *device)
334static int
335acpi_processor_add_fs (
336 struct acpi_device *device)
337{ 324{
338 struct proc_dir_entry *entry = NULL; 325 struct proc_dir_entry *entry = NULL;
339 326
340 ACPI_FUNCTION_TRACE("acpi_processor_add_fs"); 327 ACPI_FUNCTION_TRACE("acpi_processor_add_fs");
341 328
342 if (!acpi_device_dir(device)) { 329 if (!acpi_device_dir(device)) {
343 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 330 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
344 acpi_processor_dir); 331 acpi_processor_dir);
345 if (!acpi_device_dir(device)) 332 if (!acpi_device_dir(device))
346 return_VALUE(-ENODEV); 333 return_VALUE(-ENODEV);
347 } 334 }
@@ -349,11 +336,11 @@ acpi_processor_add_fs (
349 336
350 /* 'info' [R] */ 337 /* 'info' [R] */
351 entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO, 338 entry = create_proc_entry(ACPI_PROCESSOR_FILE_INFO,
352 S_IRUGO, acpi_device_dir(device)); 339 S_IRUGO, acpi_device_dir(device));
353 if (!entry) 340 if (!entry)
354 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 341 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
355 "Unable to create '%s' fs entry\n", 342 "Unable to create '%s' fs entry\n",
356 ACPI_PROCESSOR_FILE_INFO)); 343 ACPI_PROCESSOR_FILE_INFO));
357 else { 344 else {
358 entry->proc_fops = &acpi_processor_info_fops; 345 entry->proc_fops = &acpi_processor_info_fops;
359 entry->data = acpi_driver_data(device); 346 entry->data = acpi_driver_data(device);
@@ -362,11 +349,12 @@ acpi_processor_add_fs (
362 349
363 /* 'throttling' [R/W] */ 350 /* 'throttling' [R/W] */
364 entry = create_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING, 351 entry = create_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING,
365 S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 352 S_IFREG | S_IRUGO | S_IWUSR,
353 acpi_device_dir(device));
366 if (!entry) 354 if (!entry)
367 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 355 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
368 "Unable to create '%s' fs entry\n", 356 "Unable to create '%s' fs entry\n",
369 ACPI_PROCESSOR_FILE_THROTTLING)); 357 ACPI_PROCESSOR_FILE_THROTTLING));
370 else { 358 else {
371 entry->proc_fops = &acpi_processor_throttling_fops; 359 entry->proc_fops = &acpi_processor_throttling_fops;
372 entry->proc_fops->write = acpi_processor_write_throttling; 360 entry->proc_fops->write = acpi_processor_write_throttling;
@@ -376,11 +364,12 @@ acpi_processor_add_fs (
376 364
377 /* 'limit' [R/W] */ 365 /* 'limit' [R/W] */
378 entry = create_proc_entry(ACPI_PROCESSOR_FILE_LIMIT, 366 entry = create_proc_entry(ACPI_PROCESSOR_FILE_LIMIT,
379 S_IFREG|S_IRUGO|S_IWUSR, acpi_device_dir(device)); 367 S_IFREG | S_IRUGO | S_IWUSR,
368 acpi_device_dir(device));
380 if (!entry) 369 if (!entry)
381 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 370 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
382 "Unable to create '%s' fs entry\n", 371 "Unable to create '%s' fs entry\n",
383 ACPI_PROCESSOR_FILE_LIMIT)); 372 ACPI_PROCESSOR_FILE_LIMIT));
384 else { 373 else {
385 entry->proc_fops = &acpi_processor_limit_fops; 374 entry->proc_fops = &acpi_processor_limit_fops;
386 entry->proc_fops->write = acpi_processor_write_limit; 375 entry->proc_fops->write = acpi_processor_write_limit;
@@ -391,18 +380,17 @@ acpi_processor_add_fs (
391 return_VALUE(0); 380 return_VALUE(0);
392} 381}
393 382
394 383static int acpi_processor_remove_fs(struct acpi_device *device)
395static int
396acpi_processor_remove_fs (
397 struct acpi_device *device)
398{ 384{
399 ACPI_FUNCTION_TRACE("acpi_processor_remove_fs"); 385 ACPI_FUNCTION_TRACE("acpi_processor_remove_fs");
400 386
401 if (acpi_device_dir(device)) { 387 if (acpi_device_dir(device)) {
402 remove_proc_entry(ACPI_PROCESSOR_FILE_INFO,acpi_device_dir(device)); 388 remove_proc_entry(ACPI_PROCESSOR_FILE_INFO,
389 acpi_device_dir(device));
403 remove_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING, 390 remove_proc_entry(ACPI_PROCESSOR_FILE_THROTTLING,
404 acpi_device_dir(device)); 391 acpi_device_dir(device));
405 remove_proc_entry(ACPI_PROCESSOR_FILE_LIMIT,acpi_device_dir(device)); 392 remove_proc_entry(ACPI_PROCESSOR_FILE_LIMIT,
393 acpi_device_dir(device));
406 remove_proc_entry(acpi_device_bid(device), acpi_processor_dir); 394 remove_proc_entry(acpi_device_bid(device), acpi_processor_dir);
407 acpi_device_dir(device) = NULL; 395 acpi_device_dir(device) = NULL;
408 } 396 }
@@ -446,15 +434,13 @@ static u8 convert_acpiid_to_cpu(u8 acpi_id)
446 Driver Interface 434 Driver Interface
447 -------------------------------------------------------------------------- */ 435 -------------------------------------------------------------------------- */
448 436
449static int 437static int acpi_processor_get_info(struct acpi_processor *pr)
450acpi_processor_get_info (
451 struct acpi_processor *pr)
452{ 438{
453 acpi_status status = 0; 439 acpi_status status = 0;
454 union acpi_object object = {0}; 440 union acpi_object object = { 0 };
455 struct acpi_buffer buffer = {sizeof(union acpi_object), &object}; 441 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
456 u8 cpu_index; 442 u8 cpu_index;
457 static int cpu0_initialized; 443 static int cpu0_initialized;
458 444
459 ACPI_FUNCTION_TRACE("acpi_processor_get_info"); 445 ACPI_FUNCTION_TRACE("acpi_processor_get_info");
460 446
@@ -473,11 +459,10 @@ acpi_processor_get_info (
473 if (acpi_fadt.V1_pm2_cnt_blk && acpi_fadt.pm2_cnt_len) { 459 if (acpi_fadt.V1_pm2_cnt_blk && acpi_fadt.pm2_cnt_len) {
474 pr->flags.bm_control = 1; 460 pr->flags.bm_control = 1;
475 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 461 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
476 "Bus mastering arbitration control present\n")); 462 "Bus mastering arbitration control present\n"));
477 } 463 } else
478 else
479 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 464 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
480 "No bus mastering arbitration control\n")); 465 "No bus mastering arbitration control\n"));
481 466
482 /* 467 /*
483 * Evalute the processor object. Note that it is common on SMP to 468 * Evalute the processor object. Note that it is common on SMP to
@@ -487,50 +472,51 @@ acpi_processor_get_info (
487 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); 472 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
488 if (ACPI_FAILURE(status)) { 473 if (ACPI_FAILURE(status)) {
489 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 474 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
490 "Error evaluating processor object\n")); 475 "Error evaluating processor object\n"));
491 return_VALUE(-ENODEV); 476 return_VALUE(-ENODEV);
492 } 477 }
493 478
494 /* 479 /*
495 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP. 480 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP.
496 * >>> 'acpi_get_processor_id(acpi_id, &id)' in arch/xxx/acpi.c 481 * >>> 'acpi_get_processor_id(acpi_id, &id)' in arch/xxx/acpi.c
497 */ 482 */
498 pr->acpi_id = object.processor.proc_id; 483 pr->acpi_id = object.processor.proc_id;
499 484
500 cpu_index = convert_acpiid_to_cpu(pr->acpi_id); 485 cpu_index = convert_acpiid_to_cpu(pr->acpi_id);
501 486
502 /* Handle UP system running SMP kernel, with no LAPIC in MADT */ 487 /* Handle UP system running SMP kernel, with no LAPIC in MADT */
503 if ( !cpu0_initialized && (cpu_index == 0xff) && 488 if (!cpu0_initialized && (cpu_index == 0xff) &&
504 (num_online_cpus() == 1)) { 489 (num_online_cpus() == 1)) {
505 cpu_index = 0; 490 cpu_index = 0;
506 } 491 }
507 492
508 cpu0_initialized = 1; 493 cpu0_initialized = 1;
509 494
510 pr->id = cpu_index; 495 pr->id = cpu_index;
511 496
512 /* 497 /*
513 * Extra Processor objects may be enumerated on MP systems with 498 * Extra Processor objects may be enumerated on MP systems with
514 * less than the max # of CPUs. They should be ignored _iff 499 * less than the max # of CPUs. They should be ignored _iff
515 * they are physically not present. 500 * they are physically not present.
516 */ 501 */
517 if (cpu_index >= NR_CPUS) { 502 if (cpu_index >= NR_CPUS) {
518 if (ACPI_FAILURE(acpi_processor_hotadd_init(pr->handle, &pr->id))) { 503 if (ACPI_FAILURE
519 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 504 (acpi_processor_hotadd_init(pr->handle, &pr->id))) {
520 "Error getting cpuindex for acpiid 0x%x\n", 505 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
521 pr->acpi_id)); 506 "Error getting cpuindex for acpiid 0x%x\n",
522 return_VALUE(-ENODEV); 507 pr->acpi_id));
523 } 508 return_VALUE(-ENODEV);
524 } 509 }
510 }
525 511
526 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id, 512 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Processor [%d:%d]\n", pr->id,
527 pr->acpi_id)); 513 pr->acpi_id));
528 514
529 if (!object.processor.pblk_address) 515 if (!object.processor.pblk_address)
530 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n")); 516 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n"));
531 else if (object.processor.pblk_length != 6) 517 else if (object.processor.pblk_length != 6)
532 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid PBLK length [%d]\n", 518 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid PBLK length [%d]\n",
533 object.processor.pblk_length)); 519 object.processor.pblk_length));
534 else { 520 else {
535 pr->throttling.address = object.processor.pblk_address; 521 pr->throttling.address = object.processor.pblk_address;
536 pr->throttling.duty_offset = acpi_fadt.duty_offset; 522 pr->throttling.duty_offset = acpi_fadt.duty_offset;
@@ -557,13 +543,11 @@ acpi_processor_get_info (
557 return_VALUE(0); 543 return_VALUE(0);
558} 544}
559 545
560static int 546static int acpi_processor_start(struct acpi_device *device)
561acpi_processor_start(
562 struct acpi_device *device)
563{ 547{
564 int result = 0; 548 int result = 0;
565 acpi_status status = AE_OK; 549 acpi_status status = AE_OK;
566 struct acpi_processor *pr; 550 struct acpi_processor *pr;
567 551
568 ACPI_FUNCTION_TRACE("acpi_processor_start"); 552 ACPI_FUNCTION_TRACE("acpi_processor_start");
569 553
@@ -584,36 +568,30 @@ acpi_processor_start(
584 goto end; 568 goto end;
585 569
586 status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, 570 status = acpi_install_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
587 acpi_processor_notify, pr); 571 acpi_processor_notify, pr);
588 if (ACPI_FAILURE(status)) { 572 if (ACPI_FAILURE(status)) {
589 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 573 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
590 "Error installing device notify handler\n")); 574 "Error installing device notify handler\n"));
591 } 575 }
592 576
593 acpi_processor_power_init(pr, device); 577 acpi_processor_power_init(pr, device);
594 578
595 if (pr->flags.throttling) { 579 if (pr->flags.throttling) {
596 printk(KERN_INFO PREFIX "%s [%s] (supports", 580 printk(KERN_INFO PREFIX "%s [%s] (supports",
597 acpi_device_name(device), acpi_device_bid(device)); 581 acpi_device_name(device), acpi_device_bid(device));
598 printk(" %d throttling states", pr->throttling.state_count); 582 printk(" %d throttling states", pr->throttling.state_count);
599 printk(")\n"); 583 printk(")\n");
600 } 584 }
601 585
602end: 586 end:
603 587
604 return_VALUE(result); 588 return_VALUE(result);
605} 589}
606 590
607 591static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
608
609static void
610acpi_processor_notify (
611 acpi_handle handle,
612 u32 event,
613 void *data)
614{ 592{
615 struct acpi_processor *pr = (struct acpi_processor *) data; 593 struct acpi_processor *pr = (struct acpi_processor *)data;
616 struct acpi_device *device = NULL; 594 struct acpi_device *device = NULL;
617 595
618 ACPI_FUNCTION_TRACE("acpi_processor_notify"); 596 ACPI_FUNCTION_TRACE("acpi_processor_notify");
619 597
@@ -627,7 +605,7 @@ acpi_processor_notify (
627 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: 605 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
628 acpi_processor_ppc_has_changed(pr); 606 acpi_processor_ppc_has_changed(pr);
629 acpi_bus_generate_event(device, event, 607 acpi_bus_generate_event(device, event,
630 pr->performance_platform_limit); 608 pr->performance_platform_limit);
631 break; 609 break;
632 case ACPI_PROCESSOR_NOTIFY_POWER: 610 case ACPI_PROCESSOR_NOTIFY_POWER:
633 acpi_processor_cst_has_changed(pr); 611 acpi_processor_cst_has_changed(pr);
@@ -635,19 +613,16 @@ acpi_processor_notify (
635 break; 613 break;
636 default: 614 default:
637 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 615 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
638 "Unsupported event [0x%x]\n", event)); 616 "Unsupported event [0x%x]\n", event));
639 break; 617 break;
640 } 618 }
641 619
642 return_VOID; 620 return_VOID;
643} 621}
644 622
645 623static int acpi_processor_add(struct acpi_device *device)
646static int
647acpi_processor_add (
648 struct acpi_device *device)
649{ 624{
650 struct acpi_processor *pr = NULL; 625 struct acpi_processor *pr = NULL;
651 626
652 ACPI_FUNCTION_TRACE("acpi_processor_add"); 627 ACPI_FUNCTION_TRACE("acpi_processor_add");
653 628
@@ -667,21 +642,17 @@ acpi_processor_add (
667 return_VALUE(0); 642 return_VALUE(0);
668} 643}
669 644
670 645static int acpi_processor_remove(struct acpi_device *device, int type)
671static int
672acpi_processor_remove (
673 struct acpi_device *device,
674 int type)
675{ 646{
676 acpi_status status = AE_OK; 647 acpi_status status = AE_OK;
677 struct acpi_processor *pr = NULL; 648 struct acpi_processor *pr = NULL;
678 649
679 ACPI_FUNCTION_TRACE("acpi_processor_remove"); 650 ACPI_FUNCTION_TRACE("acpi_processor_remove");
680 651
681 if (!device || !acpi_driver_data(device)) 652 if (!device || !acpi_driver_data(device))
682 return_VALUE(-EINVAL); 653 return_VALUE(-EINVAL);
683 654
684 pr = (struct acpi_processor *) acpi_driver_data(device); 655 pr = (struct acpi_processor *)acpi_driver_data(device);
685 656
686 if (pr->id >= NR_CPUS) { 657 if (pr->id >= NR_CPUS) {
687 kfree(pr); 658 kfree(pr);
@@ -696,10 +667,10 @@ acpi_processor_remove (
696 acpi_processor_power_exit(pr, device); 667 acpi_processor_power_exit(pr, device);
697 668
698 status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY, 669 status = acpi_remove_notify_handler(pr->handle, ACPI_DEVICE_NOTIFY,
699 acpi_processor_notify); 670 acpi_processor_notify);
700 if (ACPI_FAILURE(status)) { 671 if (ACPI_FAILURE(status)) {
701 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 672 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
702 "Error removing notify handler\n")); 673 "Error removing notify handler\n"));
703 } 674 }
704 675
705 acpi_processor_remove_fs(device); 676 acpi_processor_remove_fs(device);
@@ -718,33 +689,28 @@ acpi_processor_remove (
718 689
719static int is_processor_present(acpi_handle handle); 690static int is_processor_present(acpi_handle handle);
720 691
721static int 692static int is_processor_present(acpi_handle handle)
722is_processor_present(
723 acpi_handle handle)
724{ 693{
725 acpi_status status; 694 acpi_status status;
726 unsigned long sta = 0; 695 unsigned long sta = 0;
727 696
728 ACPI_FUNCTION_TRACE("is_processor_present"); 697 ACPI_FUNCTION_TRACE("is_processor_present");
729 698
730 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta); 699 status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
731 if (ACPI_FAILURE(status) || !(sta & ACPI_STA_PRESENT)) { 700 if (ACPI_FAILURE(status) || !(sta & ACPI_STA_PRESENT)) {
732 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 701 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
733 "Processor Device is not present\n")); 702 "Processor Device is not present\n"));
734 return_VALUE(0); 703 return_VALUE(0);
735 } 704 }
736 return_VALUE(1); 705 return_VALUE(1);
737} 706}
738 707
739
740static 708static
741int acpi_processor_device_add( 709int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
742 acpi_handle handle,
743 struct acpi_device **device)
744{ 710{
745 acpi_handle phandle; 711 acpi_handle phandle;
746 struct acpi_device *pdev; 712 struct acpi_device *pdev;
747 struct acpi_processor *pr; 713 struct acpi_processor *pr;
748 714
749 ACPI_FUNCTION_TRACE("acpi_processor_device_add"); 715 ACPI_FUNCTION_TRACE("acpi_processor_device_add");
750 716
@@ -766,21 +732,17 @@ int acpi_processor_device_add(
766 if (!pr) 732 if (!pr)
767 return_VALUE(-ENODEV); 733 return_VALUE(-ENODEV);
768 734
769 if ((pr->id >=0) && (pr->id < NR_CPUS)) { 735 if ((pr->id >= 0) && (pr->id < NR_CPUS)) {
770 kobject_hotplug(&(*device)->kobj, KOBJ_ONLINE); 736 kobject_hotplug(&(*device)->kobj, KOBJ_ONLINE);
771 } 737 }
772 return_VALUE(0); 738 return_VALUE(0);
773} 739}
774 740
775
776static void 741static void
777acpi_processor_hotplug_notify ( 742acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
778 acpi_handle handle,
779 u32 event,
780 void *data)
781{ 743{
782 struct acpi_processor *pr; 744 struct acpi_processor *pr;
783 struct acpi_device *device = NULL; 745 struct acpi_device *device = NULL;
784 int result; 746 int result;
785 747
786 ACPI_FUNCTION_TRACE("acpi_processor_hotplug_notify"); 748 ACPI_FUNCTION_TRACE("acpi_processor_hotplug_notify");
@@ -789,8 +751,8 @@ acpi_processor_hotplug_notify (
789 case ACPI_NOTIFY_BUS_CHECK: 751 case ACPI_NOTIFY_BUS_CHECK:
790 case ACPI_NOTIFY_DEVICE_CHECK: 752 case ACPI_NOTIFY_DEVICE_CHECK:
791 printk("Processor driver received %s event\n", 753 printk("Processor driver received %s event\n",
792 (event==ACPI_NOTIFY_BUS_CHECK)? 754 (event == ACPI_NOTIFY_BUS_CHECK) ?
793 "ACPI_NOTIFY_BUS_CHECK":"ACPI_NOTIFY_DEVICE_CHECK"); 755 "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK");
794 756
795 if (!is_processor_present(handle)) 757 if (!is_processor_present(handle))
796 break; 758 break;
@@ -799,14 +761,14 @@ acpi_processor_hotplug_notify (
799 result = acpi_processor_device_add(handle, &device); 761 result = acpi_processor_device_add(handle, &device);
800 if (result) 762 if (result)
801 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 763 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
802 "Unable to add the device\n")); 764 "Unable to add the device\n"));
803 break; 765 break;
804 } 766 }
805 767
806 pr = acpi_driver_data(device); 768 pr = acpi_driver_data(device);
807 if (!pr) { 769 if (!pr) {
808 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 770 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
809 "Driver data is NULL\n")); 771 "Driver data is NULL\n"));
810 break; 772 break;
811 } 773 }
812 774
@@ -816,24 +778,27 @@ acpi_processor_hotplug_notify (
816 } 778 }
817 779
818 result = acpi_processor_start(device); 780 result = acpi_processor_start(device);
819 if ((!result) && ((pr->id >=0) && (pr->id < NR_CPUS))) { 781 if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) {
820 kobject_hotplug(&device->kobj, KOBJ_ONLINE); 782 kobject_hotplug(&device->kobj, KOBJ_ONLINE);
821 } else { 783 } else {
822 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 784 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
823 "Device [%s] failed to start\n", 785 "Device [%s] failed to start\n",
824 acpi_device_bid(device))); 786 acpi_device_bid(device)));
825 } 787 }
826 break; 788 break;
827 case ACPI_NOTIFY_EJECT_REQUEST: 789 case ACPI_NOTIFY_EJECT_REQUEST:
828 ACPI_DEBUG_PRINT((ACPI_DB_INFO,"received ACPI_NOTIFY_EJECT_REQUEST\n")); 790 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
791 "received ACPI_NOTIFY_EJECT_REQUEST\n"));
829 792
830 if (acpi_bus_get_device(handle, &device)) { 793 if (acpi_bus_get_device(handle, &device)) {
831 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"Device don't exist, dropping EJECT\n")); 794 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
795 "Device don't exist, dropping EJECT\n"));
832 break; 796 break;
833 } 797 }
834 pr = acpi_driver_data(device); 798 pr = acpi_driver_data(device);
835 if (!pr) { 799 if (!pr) {
836 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"Driver data is NULL, dropping EJECT\n")); 800 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
801 "Driver data is NULL, dropping EJECT\n"));
837 return_VOID; 802 return_VOID;
838 } 803 }
839 804
@@ -842,7 +807,7 @@ acpi_processor_hotplug_notify (
842 break; 807 break;
843 default: 808 default:
844 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 809 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
845 "Unsupported event [0x%x]\n", event)); 810 "Unsupported event [0x%x]\n", event));
846 break; 811 break;
847 } 812 }
848 813
@@ -851,45 +816,39 @@ acpi_processor_hotplug_notify (
851 816
852static acpi_status 817static acpi_status
853processor_walk_namespace_cb(acpi_handle handle, 818processor_walk_namespace_cb(acpi_handle handle,
854 u32 lvl, 819 u32 lvl, void *context, void **rv)
855 void *context,
856 void **rv)
857{ 820{
858 acpi_status status; 821 acpi_status status;
859 int *action = context; 822 int *action = context;
860 acpi_object_type type = 0; 823 acpi_object_type type = 0;
861 824
862 status = acpi_get_type(handle, &type); 825 status = acpi_get_type(handle, &type);
863 if (ACPI_FAILURE(status)) 826 if (ACPI_FAILURE(status))
864 return(AE_OK); 827 return (AE_OK);
865 828
866 if (type != ACPI_TYPE_PROCESSOR) 829 if (type != ACPI_TYPE_PROCESSOR)
867 return(AE_OK); 830 return (AE_OK);
868 831
869 switch(*action) { 832 switch (*action) {
870 case INSTALL_NOTIFY_HANDLER: 833 case INSTALL_NOTIFY_HANDLER:
871 acpi_install_notify_handler(handle, 834 acpi_install_notify_handler(handle,
872 ACPI_SYSTEM_NOTIFY, 835 ACPI_SYSTEM_NOTIFY,
873 acpi_processor_hotplug_notify, 836 acpi_processor_hotplug_notify,
874 NULL); 837 NULL);
875 break; 838 break;
876 case UNINSTALL_NOTIFY_HANDLER: 839 case UNINSTALL_NOTIFY_HANDLER:
877 acpi_remove_notify_handler(handle, 840 acpi_remove_notify_handler(handle,
878 ACPI_SYSTEM_NOTIFY, 841 ACPI_SYSTEM_NOTIFY,
879 acpi_processor_hotplug_notify); 842 acpi_processor_hotplug_notify);
880 break; 843 break;
881 default: 844 default:
882 break; 845 break;
883 } 846 }
884 847
885 return(AE_OK); 848 return (AE_OK);
886} 849}
887 850
888 851static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu)
889static acpi_status
890acpi_processor_hotadd_init(
891 acpi_handle handle,
892 int *p_cpu)
893{ 852{
894 ACPI_FUNCTION_TRACE("acpi_processor_hotadd_init"); 853 ACPI_FUNCTION_TRACE("acpi_processor_hotadd_init");
895 854
@@ -908,57 +867,47 @@ acpi_processor_hotadd_init(
908 return_VALUE(AE_OK); 867 return_VALUE(AE_OK);
909} 868}
910 869
911 870static int acpi_processor_handle_eject(struct acpi_processor *pr)
912static int
913acpi_processor_handle_eject(struct acpi_processor *pr)
914{ 871{
915 if (cpu_online(pr->id)) { 872 if (cpu_online(pr->id)) {
916 return(-EINVAL); 873 return (-EINVAL);
917 } 874 }
918 arch_unregister_cpu(pr->id); 875 arch_unregister_cpu(pr->id);
919 acpi_unmap_lsapic(pr->id); 876 acpi_unmap_lsapic(pr->id);
920 return(0); 877 return (0);
921} 878}
922#else 879#else
923static acpi_status 880static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu)
924acpi_processor_hotadd_init(
925 acpi_handle handle,
926 int *p_cpu)
927{ 881{
928 return AE_ERROR; 882 return AE_ERROR;
929} 883}
930static int 884static int acpi_processor_handle_eject(struct acpi_processor *pr)
931acpi_processor_handle_eject(struct acpi_processor *pr)
932{ 885{
933 return(-EINVAL); 886 return (-EINVAL);
934} 887}
935#endif 888#endif
936 889
937
938static 890static
939void acpi_processor_install_hotplug_notify(void) 891void acpi_processor_install_hotplug_notify(void)
940{ 892{
941#ifdef CONFIG_ACPI_HOTPLUG_CPU 893#ifdef CONFIG_ACPI_HOTPLUG_CPU
942 int action = INSTALL_NOTIFY_HANDLER; 894 int action = INSTALL_NOTIFY_HANDLER;
943 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, 895 acpi_walk_namespace(ACPI_TYPE_PROCESSOR,
944 ACPI_ROOT_OBJECT, 896 ACPI_ROOT_OBJECT,
945 ACPI_UINT32_MAX, 897 ACPI_UINT32_MAX,
946 processor_walk_namespace_cb, 898 processor_walk_namespace_cb, &action, NULL);
947 &action, NULL);
948#endif 899#endif
949} 900}
950 901
951
952static 902static
953void acpi_processor_uninstall_hotplug_notify(void) 903void acpi_processor_uninstall_hotplug_notify(void)
954{ 904{
955#ifdef CONFIG_ACPI_HOTPLUG_CPU 905#ifdef CONFIG_ACPI_HOTPLUG_CPU
956 int action = UNINSTALL_NOTIFY_HANDLER; 906 int action = UNINSTALL_NOTIFY_HANDLER;
957 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, 907 acpi_walk_namespace(ACPI_TYPE_PROCESSOR,
958 ACPI_ROOT_OBJECT, 908 ACPI_ROOT_OBJECT,
959 ACPI_UINT32_MAX, 909 ACPI_UINT32_MAX,
960 processor_walk_namespace_cb, 910 processor_walk_namespace_cb, &action, NULL);
961 &action, NULL);
962#endif 911#endif
963} 912}
964 913
@@ -968,10 +917,9 @@ void acpi_processor_uninstall_hotplug_notify(void)
968 * ACPI, but needs symbols from this driver 917 * ACPI, but needs symbols from this driver
969 */ 918 */
970 919
971static int __init 920static int __init acpi_processor_init(void)
972acpi_processor_init (void)
973{ 921{
974 int result = 0; 922 int result = 0;
975 923
976 ACPI_FUNCTION_TRACE("acpi_processor_init"); 924 ACPI_FUNCTION_TRACE("acpi_processor_init");
977 925
@@ -998,9 +946,7 @@ acpi_processor_init (void)
998 return_VALUE(0); 946 return_VALUE(0);
999} 947}
1000 948
1001 949static void __exit acpi_processor_exit(void)
1002static void __exit
1003acpi_processor_exit (void)
1004{ 950{
1005 ACPI_FUNCTION_TRACE("acpi_processor_exit"); 951 ACPI_FUNCTION_TRACE("acpi_processor_exit");
1006 952
@@ -1017,7 +963,6 @@ acpi_processor_exit (void)
1017 return_VOID; 963 return_VOID;
1018} 964}
1019 965
1020
1021module_init(acpi_processor_init); 966module_init(acpi_processor_init);
1022module_exit(acpi_processor_exit); 967module_exit(acpi_processor_exit);
1023 968