Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPICA: Allow ACPI id to be u32 instead of u8.

Allow ACPI id to be u32 instead of u8.
Requires drop of conversion tables with the acpiid as index.

Signed-off-by: Len Brown <len.brown@intel.com>

authored by

Alexey Starikovskiy and committed by
Len Brown
f18c5a08 5008740e

+128 -65
-17
arch/i386/kernel/acpi/boot.c
··· 92 92 #warning ACPI uses CMPXCHG, i486 and later hardware 93 93 #endif 94 94 95 - #define MAX_MADT_ENTRIES 256 96 - u8 x86_acpiid_to_apicid[MAX_MADT_ENTRIES] = 97 - {[0 ... MAX_MADT_ENTRIES - 1] = 0xff }; 98 - EXPORT_SYMBOL(x86_acpiid_to_apicid); 99 - 100 95 /* -------------------------------------------------------------------------- 101 96 Boot-time Configuration 102 97 -------------------------------------------------------------------------- */ ··· 247 252 return -EINVAL; 248 253 249 254 acpi_table_print_madt_entry(header); 250 - 251 - /* Record local apic id only when enabled */ 252 - if (processor->lapic_flags & ACPI_MADT_ENABLED) 253 - x86_acpiid_to_apicid[processor->processor_id] = processor->id; 254 255 255 256 /* 256 257 * We need to register disabled CPU as well to permit ··· 554 563 555 564 int acpi_unmap_lsapic(int cpu) 556 565 { 557 - int i; 558 - 559 - for_each_possible_cpu(i) { 560 - if (x86_acpiid_to_apicid[i] == x86_cpu_to_apicid[cpu]) { 561 - x86_acpiid_to_apicid[i] = -1; 562 - break; 563 - } 564 - } 565 566 x86_cpu_to_apicid[cpu] = -1; 566 567 cpu_clear(cpu, cpu_present_map); 567 568 num_processors--;
-16
arch/ia64/kernel/acpi.c
··· 67 67 unsigned int acpi_cpei_override; 68 68 unsigned int acpi_cpei_phys_cpuid; 69 69 70 - #define MAX_SAPICS 256 71 - u16 ia64_acpiid_to_sapicid[MAX_SAPICS] = {[0 ... MAX_SAPICS - 1] = -1 }; 72 - 73 - EXPORT_SYMBOL(ia64_acpiid_to_sapicid); 74 - 75 70 const char *acpi_get_sysname(void) 76 71 { 77 72 #ifdef CONFIG_IA64_GENERIC ··· 195 200 smp_boot_data.cpu_phys_id[available_cpus] = 196 201 (lsapic->id << 8) | lsapic->eid; 197 202 #endif 198 - ia64_acpiid_to_sapicid[lsapic->processor_id] = 199 - (lsapic->id << 8) | lsapic->eid; 200 203 ++available_cpus; 201 204 } 202 205 ··· 873 880 874 881 cpu_set(cpu, cpu_present_map); 875 882 ia64_cpu_to_sapicid[cpu] = physid; 876 - ia64_acpiid_to_sapicid[lsapic->processor_id] = ia64_cpu_to_sapicid[cpu]; 877 883 878 884 *pcpu = cpu; 879 885 return (0); ··· 882 890 883 891 int acpi_unmap_lsapic(int cpu) 884 892 { 885 - int i; 886 - 887 - for (i = 0; i < MAX_SAPICS; i++) { 888 - if (ia64_acpiid_to_sapicid[i] == ia64_cpu_to_sapicid[cpu]) { 889 - ia64_acpiid_to_sapicid[i] = -1; 890 - break; 891 - } 892 - } 893 893 ia64_cpu_to_sapicid[cpu] = -1; 894 894 cpu_clear(cpu, cpu_present_map); 895 895
+114 -12
drivers/acpi/processor_core.c
··· 375 375 } 376 376 377 377 /* Use the acpiid in MADT to map cpus in case of SMP */ 378 + 378 379 #ifndef CONFIG_SMP 379 380 #define convert_acpiid_to_cpu(acpi_id) (-1) 380 381 #else 381 382 383 + static struct acpi_table_madt *madt; 384 + 385 + static int map_lapic_id(struct acpi_subtable_header *entry, 386 + u32 acpi_id, int *apic_id) 387 + { 388 + struct acpi_madt_local_apic *lapic = 389 + (struct acpi_madt_local_apic *)entry; 390 + if ((lapic->lapic_flags & ACPI_MADT_ENABLED) && 391 + lapic->processor_id == acpi_id) { 392 + *apic_id = lapic->id; 393 + return 1; 394 + } 395 + return 0; 396 + } 397 + 398 + static int map_lsapic_id(struct acpi_subtable_header *entry, 399 + u32 acpi_id, int *apic_id) 400 + { 401 + struct acpi_madt_local_sapic *lsapic = 402 + (struct acpi_madt_local_sapic *)entry; 403 + /* Only check enabled APICs*/ 404 + if (lsapic->lapic_flags & ACPI_MADT_ENABLED) { 405 + /* First check against id */ 406 + if (lsapic->processor_id == acpi_id) { 407 + *apic_id = lsapic->id; 408 + return 1; 409 + /* Check against optional uid */ 410 + } else if (entry->length >= 16 && 411 + lsapic->uid == acpi_id) { 412 + *apic_id = lsapic->uid; 413 + return 1; 414 + } 415 + } 416 + return 0; 417 + } 418 + 382 419 #ifdef CONFIG_IA64 383 - #define arch_acpiid_to_apicid ia64_acpiid_to_sapicid 384 420 #define arch_cpu_to_apicid ia64_cpu_to_sapicid 385 - #define ARCH_BAD_APICID (0xffff) 386 421 #else 387 - #define arch_acpiid_to_apicid x86_acpiid_to_apicid 388 422 #define arch_cpu_to_apicid x86_cpu_to_apicid 389 - #define ARCH_BAD_APICID (0xff) 390 423 #endif 391 424 392 - static int convert_acpiid_to_cpu(u8 acpi_id) 425 + static int map_madt_entry(u32 acpi_id) 393 426 { 394 - u16 apic_id; 427 + unsigned long madt_end, entry; 428 + int apic_id = -1; 429 + 430 + if (!madt) 431 + return apic_id; 432 + 433 + entry = (unsigned long)madt; 434 + madt_end = entry + madt->header.length; 435 + 436 + /* Parse all entries looking for a match. */ 437 + 438 + entry += sizeof(struct acpi_table_madt); 439 + while (entry + sizeof(struct acpi_subtable_header) < madt_end) { 440 + struct acpi_subtable_header *header = 441 + (struct acpi_subtable_header *)entry; 442 + if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) { 443 + if (map_lapic_id(header, acpi_id, &apic_id)) 444 + break; 445 + } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { 446 + if (map_lsapic_id(header, acpi_id, &apic_id)) 447 + break; 448 + } 449 + entry += header->length; 450 + } 451 + return apic_id; 452 + } 453 + 454 + static int map_mat_entry(acpi_handle handle, u32 acpi_id) 455 + { 456 + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 457 + union acpi_object *obj; 458 + struct acpi_subtable_header *header; 459 + int apic_id = -1; 460 + 461 + if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) 462 + goto exit; 463 + 464 + if (!buffer.length || !buffer.pointer) 465 + goto exit; 466 + 467 + obj = buffer.pointer; 468 + if (obj->type != ACPI_TYPE_BUFFER || 469 + obj->buffer.length < sizeof(struct acpi_subtable_header)) { 470 + goto exit; 471 + } 472 + 473 + header = (struct acpi_subtable_header *)obj->buffer.pointer; 474 + if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) { 475 + map_lapic_id(header, acpi_id, &apic_id); 476 + } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { 477 + map_lsapic_id(header, acpi_id, &apic_id); 478 + } 479 + 480 + exit: 481 + if (buffer.pointer) 482 + kfree(buffer.pointer); 483 + return apic_id; 484 + } 485 + 486 + static int get_apic_id(acpi_handle handle, u32 acpi_id) 487 + { 395 488 int i; 489 + int apic_id = -1; 396 490 397 - apic_id = arch_acpiid_to_apicid[acpi_id]; 398 - if (apic_id == ARCH_BAD_APICID) 399 - return -1; 491 + apic_id = map_mat_entry(handle, acpi_id); 492 + if (apic_id == -1) 493 + apic_id = map_madt_entry(acpi_id); 494 + if (apic_id == -1) 495 + return apic_id; 400 496 401 - for (i = 0; i < NR_CPUS; i++) { 497 + for (i = 0; i < NR_CPUS; ++i) { 402 498 if (arch_cpu_to_apicid[i] == apic_id) 403 499 return i; 404 500 } ··· 552 456 */ 553 457 pr->acpi_id = object.processor.proc_id; 554 458 555 - cpu_index = convert_acpiid_to_cpu(pr->acpi_id); 459 + cpu_index = get_apic_id(pr->handle, pr->acpi_id); 556 460 557 461 /* Handle UP system running SMP kernel, with no LAPIC in MADT */ 558 462 if (!cpu0_initialized && (cpu_index == -1) && ··· 569 473 * less than the max # of CPUs. They should be ignored _iff 570 474 * they are physically not present. 571 475 */ 572 - if (cpu_index == -1) { 476 + if (pr->id == -1) { 573 477 if (ACPI_FAILURE 574 478 (acpi_processor_hotadd_init(pr->handle, &pr->id))) { 575 479 return -ENODEV; ··· 990 894 991 895 memset(&processors, 0, sizeof(processors)); 992 896 memset(&errata, 0, sizeof(errata)); 897 + 898 + #ifdef CONFIG_SMP 899 + if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0, 900 + (struct acpi_table_header **)&madt))) 901 + madt = 0; 902 + #endif 993 903 994 904 acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); 995 905 if (!acpi_processor_dir)
+7 -9
include/asm-i386/acpi.h
··· 39 39 * Calling conventions: 40 40 * 41 41 * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) 42 - * ACPI_EXTERNAL_XFACE - External ACPI interfaces 42 + * ACPI_EXTERNAL_XFACE - External ACPI interfaces 43 43 * ACPI_INTERNAL_XFACE - Internal ACPI interfaces 44 44 * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces 45 45 */ ··· 87 87 static inline void check_acpi_pci(void) { } 88 88 #endif 89 89 90 - #ifdef CONFIG_ACPI 90 + #ifdef CONFIG_ACPI 91 91 extern int acpi_lapic; 92 92 extern int acpi_ioapic; 93 93 extern int acpi_noirq; ··· 95 95 extern int acpi_disabled; 96 96 extern int acpi_ht; 97 97 extern int acpi_pci_disabled; 98 - static inline void disable_acpi(void) 99 - { 100 - acpi_disabled = 1; 98 + static inline void disable_acpi(void) 99 + { 100 + acpi_disabled = 1; 101 101 acpi_ht = 0; 102 102 acpi_pci_disabled = 1; 103 103 acpi_noirq = 1; ··· 114 114 #endif 115 115 116 116 static inline void acpi_noirq_set(void) { acpi_noirq = 1; } 117 - static inline void acpi_disable_pci(void) 117 + static inline void acpi_disable_pci(void) 118 118 { 119 - acpi_pci_disabled = 1; 119 + acpi_pci_disabled = 1; 120 120 acpi_noirq_set(); 121 121 } 122 122 extern int acpi_irq_balance_set(char *str); ··· 143 143 extern void acpi_reserve_bootmem(void); 144 144 145 145 #endif /*CONFIG_ACPI_SLEEP*/ 146 - 147 - extern u8 x86_acpiid_to_apicid[]; 148 146 149 147 #define ARCH_HAS_POWER_INIT 1 150 148
-2
include/asm-ia64/acpi.h
··· 119 119 extern int __initdata nid_to_pxm_map[MAX_NUMNODES]; 120 120 #endif 121 121 122 - extern u16 ia64_acpiid_to_sapicid[]; 123 - 124 122 /* 125 123 * Refer Intel ACPI _PDC support document for bit definitions 126 124 */
+7 -9
include/asm-x86_64/acpi.h
··· 37 37 * Calling conventions: 38 38 * 39 39 * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) 40 - * ACPI_EXTERNAL_XFACE - External ACPI interfaces 40 + * ACPI_EXTERNAL_XFACE - External ACPI interfaces 41 41 * ACPI_INTERNAL_XFACE - Internal ACPI interfaces 42 42 * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces 43 43 */ ··· 87 87 extern int acpi_disabled; 88 88 extern int acpi_pci_disabled; 89 89 extern int acpi_ht; 90 - static inline void disable_acpi(void) 91 - { 92 - acpi_disabled = 1; 93 - acpi_ht = 0; 90 + static inline void disable_acpi(void) 91 + { 92 + acpi_disabled = 1; 93 + acpi_ht = 0; 94 94 acpi_pci_disabled = 1; 95 95 acpi_noirq = 1; 96 96 } ··· 100 100 101 101 extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq); 102 102 static inline void acpi_noirq_set(void) { acpi_noirq = 1; } 103 - static inline void acpi_disable_pci(void) 103 + static inline void acpi_disable_pci(void) 104 104 { 105 - acpi_pci_disabled = 1; 105 + acpi_pci_disabled = 1; 106 106 acpi_noirq_set(); 107 107 } 108 108 extern int acpi_irq_balance_set(char *str); ··· 135 135 136 136 extern int acpi_disabled; 137 137 extern int acpi_pci_disabled; 138 - 139 - extern u8 x86_acpiid_to_apicid[]; 140 138 141 139 #define ARCH_HAS_POWER_INIT 1 142 140