diff options
Diffstat (limited to 'drivers/acpi/processor_driver.c')
| -rw-r--r-- | drivers/acpi/processor_driver.c | 159 |
1 files changed, 0 insertions, 159 deletions
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c index 98358251ce2..7eedf7475f4 100644 --- a/drivers/acpi/processor_driver.c +++ b/drivers/acpi/processor_driver.c | |||
| @@ -359,160 +359,6 @@ static inline int acpi_processor_remove_fs(struct acpi_device *device) | |||
| 359 | } | 359 | } |
| 360 | #endif | 360 | #endif |
| 361 | 361 | ||
| 362 | /* Use the acpiid in MADT to map cpus in case of SMP */ | ||
| 363 | |||
| 364 | #ifdef CONFIG_SMP | ||
| 365 | static struct acpi_table_madt *madt; | ||
| 366 | |||
| 367 | static int map_lapic_id(struct acpi_subtable_header *entry, | ||
| 368 | u32 acpi_id, int *apic_id) | ||
| 369 | { | ||
| 370 | struct acpi_madt_local_apic *lapic = | ||
| 371 | (struct acpi_madt_local_apic *)entry; | ||
| 372 | if ((lapic->lapic_flags & ACPI_MADT_ENABLED) && | ||
| 373 | lapic->processor_id == acpi_id) { | ||
| 374 | *apic_id = lapic->id; | ||
| 375 | return 1; | ||
| 376 | } | ||
| 377 | return 0; | ||
| 378 | } | ||
| 379 | |||
| 380 | static int map_x2apic_id(struct acpi_subtable_header *entry, | ||
| 381 | int device_declaration, u32 acpi_id, int *apic_id) | ||
| 382 | { | ||
| 383 | struct acpi_madt_local_x2apic *apic = | ||
| 384 | (struct acpi_madt_local_x2apic *)entry; | ||
| 385 | u32 tmp = apic->local_apic_id; | ||
| 386 | |||
| 387 | /* Only check enabled APICs*/ | ||
| 388 | if (!(apic->lapic_flags & ACPI_MADT_ENABLED)) | ||
| 389 | return 0; | ||
| 390 | |||
| 391 | /* Device statement declaration type */ | ||
| 392 | if (device_declaration) { | ||
| 393 | if (apic->uid == acpi_id) | ||
| 394 | goto found; | ||
| 395 | } | ||
| 396 | |||
| 397 | return 0; | ||
| 398 | found: | ||
| 399 | *apic_id = tmp; | ||
| 400 | return 1; | ||
| 401 | } | ||
| 402 | |||
| 403 | static int map_lsapic_id(struct acpi_subtable_header *entry, | ||
| 404 | int device_declaration, u32 acpi_id, int *apic_id) | ||
| 405 | { | ||
| 406 | struct acpi_madt_local_sapic *lsapic = | ||
| 407 | (struct acpi_madt_local_sapic *)entry; | ||
| 408 | u32 tmp = (lsapic->id << 8) | lsapic->eid; | ||
| 409 | |||
| 410 | /* Only check enabled APICs*/ | ||
| 411 | if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED)) | ||
| 412 | return 0; | ||
| 413 | |||
| 414 | /* Device statement declaration type */ | ||
| 415 | if (device_declaration) { | ||
| 416 | if (entry->length < 16) | ||
| 417 | printk(KERN_ERR PREFIX | ||
| 418 | "Invalid LSAPIC with Device type processor (SAPIC ID %#x)\n", | ||
| 419 | tmp); | ||
| 420 | else if (lsapic->uid == acpi_id) | ||
| 421 | goto found; | ||
| 422 | /* Processor statement declaration type */ | ||
| 423 | } else if (lsapic->processor_id == acpi_id) | ||
| 424 | goto found; | ||
| 425 | |||
| 426 | return 0; | ||
| 427 | found: | ||
| 428 | *apic_id = tmp; | ||
| 429 | return 1; | ||
| 430 | } | ||
| 431 | |||
| 432 | static int map_madt_entry(int type, u32 acpi_id) | ||
| 433 | { | ||
| 434 | unsigned long madt_end, entry; | ||
| 435 | int apic_id = -1; | ||
| 436 | |||
| 437 | if (!madt) | ||
| 438 | return apic_id; | ||
| 439 | |||
| 440 | entry = (unsigned long)madt; | ||
| 441 | madt_end = entry + madt->header.length; | ||
| 442 | |||
| 443 | /* Parse all entries looking for a match. */ | ||
| 444 | |||
| 445 | entry += sizeof(struct acpi_table_madt); | ||
| 446 | while (entry + sizeof(struct acpi_subtable_header) < madt_end) { | ||
| 447 | struct acpi_subtable_header *header = | ||
| 448 | (struct acpi_subtable_header *)entry; | ||
| 449 | if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) { | ||
| 450 | if (map_lapic_id(header, acpi_id, &apic_id)) | ||
| 451 | break; | ||
| 452 | } else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) { | ||
| 453 | if (map_x2apic_id(header, type, acpi_id, &apic_id)) | ||
| 454 | break; | ||
| 455 | } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { | ||
| 456 | if (map_lsapic_id(header, type, acpi_id, &apic_id)) | ||
| 457 | break; | ||
| 458 | } | ||
| 459 | entry += header->length; | ||
| 460 | } | ||
| 461 | return apic_id; | ||
| 462 | } | ||
| 463 | |||
| 464 | static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id) | ||
| 465 | { | ||
| 466 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
| 467 | union acpi_object *obj; | ||
| 468 | struct acpi_subtable_header *header; | ||
| 469 | int apic_id = -1; | ||
| 470 | |||
| 471 | if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) | ||
| 472 | goto exit; | ||
| 473 | |||
| 474 | if (!buffer.length || !buffer.pointer) | ||
| 475 | goto exit; | ||
| 476 | |||
| 477 | obj = buffer.pointer; | ||
| 478 | if (obj->type != ACPI_TYPE_BUFFER || | ||
| 479 | obj->buffer.length < sizeof(struct acpi_subtable_header)) { | ||
| 480 | goto exit; | ||
| 481 | } | ||
| 482 | |||
| 483 | header = (struct acpi_subtable_header *)obj->buffer.pointer; | ||
| 484 | if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) { | ||
| 485 | map_lapic_id(header, acpi_id, &apic_id); | ||
| 486 | } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { | ||
| 487 | map_lsapic_id(header, type, acpi_id, &apic_id); | ||
| 488 | } | ||
| 489 | |||
| 490 | exit: | ||
| 491 | if (buffer.pointer) | ||
| 492 | kfree(buffer.pointer); | ||
| 493 | return apic_id; | ||
| 494 | } | ||
| 495 | |||
| 496 | int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) | ||
| 497 | { | ||
| 498 | int i; | ||
| 499 | int apic_id = -1; | ||
| 500 | |||
| 501 | apic_id = map_mat_entry(handle, type, acpi_id); | ||
| 502 | if (apic_id == -1) | ||
| 503 | apic_id = map_madt_entry(type, acpi_id); | ||
| 504 | if (apic_id == -1) | ||
| 505 | return apic_id; | ||
| 506 | |||
| 507 | for_each_possible_cpu(i) { | ||
| 508 | if (cpu_physical_id(i) == apic_id) | ||
| 509 | return i; | ||
| 510 | } | ||
| 511 | return -1; | ||
| 512 | } | ||
| 513 | EXPORT_SYMBOL_GPL(acpi_get_cpuid); | ||
| 514 | #endif | ||
| 515 | |||
| 516 | /* -------------------------------------------------------------------------- | 362 | /* -------------------------------------------------------------------------- |
| 517 | Driver Interface | 363 | Driver Interface |
| 518 | -------------------------------------------------------------------------- */ | 364 | -------------------------------------------------------------------------- */ |
| @@ -1071,11 +917,6 @@ static int __init acpi_processor_init(void) | |||
| 1071 | 917 | ||
| 1072 | memset(&errata, 0, sizeof(errata)); | 918 | memset(&errata, 0, sizeof(errata)); |
| 1073 | 919 | ||
| 1074 | #ifdef CONFIG_SMP | ||
| 1075 | if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0, | ||
| 1076 | (struct acpi_table_header **)&madt))) | ||
| 1077 | madt = NULL; | ||
| 1078 | #endif | ||
| 1079 | #ifdef CONFIG_ACPI_PROCFS | 920 | #ifdef CONFIG_ACPI_PROCFS |
| 1080 | acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); | 921 | acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); |
| 1081 | if (!acpi_processor_dir) | 922 | if (!acpi_processor_dir) |
