diff options
-rw-r--r-- | arch/i386/kernel/acpi/boot.c | 17 | ||||
-rw-r--r-- | arch/ia64/kernel/acpi.c | 16 | ||||
-rw-r--r-- | drivers/acpi/processor_core.c | 126 | ||||
-rw-r--r-- | include/asm-i386/acpi.h | 16 | ||||
-rw-r--r-- | include/asm-ia64/acpi.h | 2 | ||||
-rw-r--r-- | include/asm-x86_64/acpi.h | 16 |
6 files changed, 128 insertions, 65 deletions
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c index 2147511ea78d..e94aff6888ca 100644 --- a/arch/i386/kernel/acpi/boot.c +++ b/arch/i386/kernel/acpi/boot.c | |||
@@ -92,11 +92,6 @@ static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE; | |||
92 | #warning ACPI uses CMPXCHG, i486 and later hardware | 92 | #warning ACPI uses CMPXCHG, i486 and later hardware |
93 | #endif | 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 | Boot-time Configuration | 96 | Boot-time Configuration |
102 | -------------------------------------------------------------------------- */ | 97 | -------------------------------------------------------------------------- */ |
@@ -253,10 +248,6 @@ acpi_parse_lapic(struct acpi_subtable_header * header, const unsigned long end) | |||
253 | 248 | ||
254 | acpi_table_print_madt_entry(header); | 249 | acpi_table_print_madt_entry(header); |
255 | 250 | ||
256 | /* Record local apic id only when enabled */ | ||
257 | if (processor->lapic_flags & ACPI_MADT_ENABLED) | ||
258 | x86_acpiid_to_apicid[processor->processor_id] = processor->id; | ||
259 | |||
260 | /* | 251 | /* |
261 | * We need to register disabled CPU as well to permit | 252 | * We need to register disabled CPU as well to permit |
262 | * counting disabled CPUs. This allows us to size | 253 | * counting disabled CPUs. This allows us to size |
@@ -563,14 +554,6 @@ EXPORT_SYMBOL(acpi_map_lsapic); | |||
563 | 554 | ||
564 | int acpi_unmap_lsapic(int cpu) | 555 | int acpi_unmap_lsapic(int cpu) |
565 | { | 556 | { |
566 | int i; | ||
567 | |||
568 | for_each_possible_cpu(i) { | ||
569 | if (x86_acpiid_to_apicid[i] == x86_cpu_to_apicid[cpu]) { | ||
570 | x86_acpiid_to_apicid[i] = -1; | ||
571 | break; | ||
572 | } | ||
573 | } | ||
574 | x86_cpu_to_apicid[cpu] = -1; | 557 | x86_cpu_to_apicid[cpu] = -1; |
575 | cpu_clear(cpu, cpu_present_map); | 558 | cpu_clear(cpu, cpu_present_map); |
576 | num_processors--; | 559 | num_processors--; |
diff --git a/arch/ia64/kernel/acpi.c b/arch/ia64/kernel/acpi.c index 4719e481d93b..989ffc3f7ce3 100644 --- a/arch/ia64/kernel/acpi.c +++ b/arch/ia64/kernel/acpi.c | |||
@@ -67,11 +67,6 @@ EXPORT_SYMBOL(pm_power_off); | |||
67 | unsigned int acpi_cpei_override; | 67 | unsigned int acpi_cpei_override; |
68 | unsigned int acpi_cpei_phys_cpuid; | 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 | const char *acpi_get_sysname(void) | 70 | const char *acpi_get_sysname(void) |
76 | { | 71 | { |
77 | #ifdef CONFIG_IA64_GENERIC | 72 | #ifdef CONFIG_IA64_GENERIC |
@@ -200,8 +195,6 @@ acpi_parse_lsapic(struct acpi_subtable_header * header, const unsigned long end) | |||
200 | smp_boot_data.cpu_phys_id[available_cpus] = | 195 | smp_boot_data.cpu_phys_id[available_cpus] = |
201 | (lsapic->id << 8) | lsapic->eid; | 196 | (lsapic->id << 8) | lsapic->eid; |
202 | #endif | 197 | #endif |
203 | ia64_acpiid_to_sapicid[lsapic->processor_id] = | ||
204 | (lsapic->id << 8) | lsapic->eid; | ||
205 | ++available_cpus; | 198 | ++available_cpus; |
206 | } | 199 | } |
207 | 200 | ||
@@ -880,7 +873,6 @@ int acpi_map_lsapic(acpi_handle handle, int *pcpu) | |||
880 | 873 | ||
881 | cpu_set(cpu, cpu_present_map); | 874 | cpu_set(cpu, cpu_present_map); |
882 | ia64_cpu_to_sapicid[cpu] = physid; | 875 | ia64_cpu_to_sapicid[cpu] = physid; |
883 | ia64_acpiid_to_sapicid[lsapic->processor_id] = ia64_cpu_to_sapicid[cpu]; | ||
884 | 876 | ||
885 | *pcpu = cpu; | 877 | *pcpu = cpu; |
886 | return (0); | 878 | return (0); |
@@ -890,14 +882,6 @@ EXPORT_SYMBOL(acpi_map_lsapic); | |||
890 | 882 | ||
891 | int acpi_unmap_lsapic(int cpu) | 883 | int acpi_unmap_lsapic(int cpu) |
892 | { | 884 | { |
893 | int i; | ||
894 | |||
895 | for (i = 0; i < MAX_SAPICS; i++) { | ||
896 | if (ia64_acpiid_to_sapicid[i] == ia64_cpu_to_sapicid[cpu]) { | ||
897 | ia64_acpiid_to_sapicid[i] = -1; | ||
898 | break; | ||
899 | } | ||
900 | } | ||
901 | ia64_cpu_to_sapicid[cpu] = -1; | 885 | ia64_cpu_to_sapicid[cpu] = -1; |
902 | cpu_clear(cpu, cpu_present_map); | 886 | cpu_clear(cpu, cpu_present_map); |
903 | 887 | ||
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c index 1b6bc662b3ac..6893c0bffb5a 100644 --- a/drivers/acpi/processor_core.c +++ b/drivers/acpi/processor_core.c | |||
@@ -375,30 +375,126 @@ static int acpi_processor_remove_fs(struct acpi_device *device) | |||
375 | } | 375 | } |
376 | 376 | ||
377 | /* Use the acpiid in MADT to map cpus in case of SMP */ | 377 | /* Use the acpiid in MADT to map cpus in case of SMP */ |
378 | |||
378 | #ifndef CONFIG_SMP | 379 | #ifndef CONFIG_SMP |
379 | #define convert_acpiid_to_cpu(acpi_id) (-1) | 380 | #define convert_acpiid_to_cpu(acpi_id) (-1) |
380 | #else | 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 | #ifdef CONFIG_IA64 | 419 | #ifdef CONFIG_IA64 |
383 | #define arch_acpiid_to_apicid ia64_acpiid_to_sapicid | ||
384 | #define arch_cpu_to_apicid ia64_cpu_to_sapicid | 420 | #define arch_cpu_to_apicid ia64_cpu_to_sapicid |
385 | #define ARCH_BAD_APICID (0xffff) | ||
386 | #else | 421 | #else |
387 | #define arch_acpiid_to_apicid x86_acpiid_to_apicid | ||
388 | #define arch_cpu_to_apicid x86_cpu_to_apicid | 422 | #define arch_cpu_to_apicid x86_cpu_to_apicid |
389 | #define ARCH_BAD_APICID (0xff) | ||
390 | #endif | 423 | #endif |
391 | 424 | ||
392 | static int convert_acpiid_to_cpu(u8 acpi_id) | 425 | static int map_madt_entry(u32 acpi_id) |
426 | { | ||
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) | ||
393 | { | 487 | { |
394 | u16 apic_id; | ||
395 | int i; | 488 | int i; |
489 | int apic_id = -1; | ||
396 | 490 | ||
397 | apic_id = arch_acpiid_to_apicid[acpi_id]; | 491 | apic_id = map_mat_entry(handle, acpi_id); |
398 | if (apic_id == ARCH_BAD_APICID) | 492 | if (apic_id == -1) |
399 | return -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 | if (arch_cpu_to_apicid[i] == apic_id) | 498 | if (arch_cpu_to_apicid[i] == apic_id) |
403 | return i; | 499 | return i; |
404 | } | 500 | } |
@@ -456,7 +552,7 @@ static int acpi_processor_get_info(struct acpi_processor *pr) | |||
456 | */ | 552 | */ |
457 | pr->acpi_id = object.processor.proc_id; | 553 | pr->acpi_id = object.processor.proc_id; |
458 | 554 | ||
459 | cpu_index = convert_acpiid_to_cpu(pr->acpi_id); | 555 | cpu_index = get_apic_id(pr->handle, pr->acpi_id); |
460 | 556 | ||
461 | /* Handle UP system running SMP kernel, with no LAPIC in MADT */ | 557 | /* Handle UP system running SMP kernel, with no LAPIC in MADT */ |
462 | if (!cpu0_initialized && (cpu_index == -1) && | 558 | if (!cpu0_initialized && (cpu_index == -1) && |
@@ -473,7 +569,7 @@ static int acpi_processor_get_info(struct acpi_processor *pr) | |||
473 | * less than the max # of CPUs. They should be ignored _iff | 569 | * less than the max # of CPUs. They should be ignored _iff |
474 | * they are physically not present. | 570 | * they are physically not present. |
475 | */ | 571 | */ |
476 | if (cpu_index == -1) { | 572 | if (pr->id == -1) { |
477 | if (ACPI_FAILURE | 573 | if (ACPI_FAILURE |
478 | (acpi_processor_hotadd_init(pr->handle, &pr->id))) { | 574 | (acpi_processor_hotadd_init(pr->handle, &pr->id))) { |
479 | return -ENODEV; | 575 | return -ENODEV; |
@@ -895,6 +991,12 @@ static int __init acpi_processor_init(void) | |||
895 | memset(&processors, 0, sizeof(processors)); | 991 | memset(&processors, 0, sizeof(processors)); |
896 | memset(&errata, 0, sizeof(errata)); | 992 | memset(&errata, 0, sizeof(errata)); |
897 | 993 | ||
994 | #ifdef CONFIG_SMP | ||
995 | if (ACPI_FAILURE(acpi_get_table(ACPI_SIG_MADT, 0, | ||
996 | (struct acpi_table_header **)&madt))) | ||
997 | madt = 0; | ||
998 | #endif | ||
999 | |||
898 | acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); | 1000 | acpi_processor_dir = proc_mkdir(ACPI_PROCESSOR_CLASS, acpi_root_dir); |
899 | if (!acpi_processor_dir) | 1001 | if (!acpi_processor_dir) |
900 | return -ENOMEM; | 1002 | return -ENOMEM; |
diff --git a/include/asm-i386/acpi.h b/include/asm-i386/acpi.h index 0fb0c016db73..5e657eb8946c 100644 --- a/include/asm-i386/acpi.h +++ b/include/asm-i386/acpi.h | |||
@@ -39,7 +39,7 @@ | |||
39 | * Calling conventions: | 39 | * Calling conventions: |
40 | * | 40 | * |
41 | * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) | 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 | * ACPI_INTERNAL_XFACE - Internal ACPI interfaces | 43 | * ACPI_INTERNAL_XFACE - Internal ACPI interfaces |
44 | * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces | 44 | * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces |
45 | */ | 45 | */ |
@@ -87,7 +87,7 @@ extern void check_acpi_pci(void); | |||
87 | static inline void check_acpi_pci(void) { } | 87 | static inline void check_acpi_pci(void) { } |
88 | #endif | 88 | #endif |
89 | 89 | ||
90 | #ifdef CONFIG_ACPI | 90 | #ifdef CONFIG_ACPI |
91 | extern int acpi_lapic; | 91 | extern int acpi_lapic; |
92 | extern int acpi_ioapic; | 92 | extern int acpi_ioapic; |
93 | extern int acpi_noirq; | 93 | extern int acpi_noirq; |
@@ -95,9 +95,9 @@ extern int acpi_strict; | |||
95 | extern int acpi_disabled; | 95 | extern int acpi_disabled; |
96 | extern int acpi_ht; | 96 | extern int acpi_ht; |
97 | extern int acpi_pci_disabled; | 97 | extern int acpi_pci_disabled; |
98 | static inline void disable_acpi(void) | 98 | static inline void disable_acpi(void) |
99 | { | 99 | { |
100 | acpi_disabled = 1; | 100 | acpi_disabled = 1; |
101 | acpi_ht = 0; | 101 | acpi_ht = 0; |
102 | acpi_pci_disabled = 1; | 102 | acpi_pci_disabled = 1; |
103 | acpi_noirq = 1; | 103 | acpi_noirq = 1; |
@@ -114,9 +114,9 @@ extern int acpi_use_timer_override; | |||
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | static inline void acpi_noirq_set(void) { acpi_noirq = 1; } | 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 | acpi_noirq_set(); | 120 | acpi_noirq_set(); |
121 | } | 121 | } |
122 | extern int acpi_irq_balance_set(char *str); | 122 | extern int acpi_irq_balance_set(char *str); |
@@ -144,8 +144,6 @@ extern void acpi_reserve_bootmem(void); | |||
144 | 144 | ||
145 | #endif /*CONFIG_ACPI_SLEEP*/ | 145 | #endif /*CONFIG_ACPI_SLEEP*/ |
146 | 146 | ||
147 | extern u8 x86_acpiid_to_apicid[]; | ||
148 | |||
149 | #define ARCH_HAS_POWER_INIT 1 | 147 | #define ARCH_HAS_POWER_INIT 1 |
150 | 148 | ||
151 | #endif /*__KERNEL__*/ | 149 | #endif /*__KERNEL__*/ |
diff --git a/include/asm-ia64/acpi.h b/include/asm-ia64/acpi.h index dba34d5a0920..5d03792d4f65 100644 --- a/include/asm-ia64/acpi.h +++ b/include/asm-ia64/acpi.h | |||
@@ -119,8 +119,6 @@ extern int __devinitdata pxm_to_nid_map[MAX_PXM_DOMAINS]; | |||
119 | extern int __initdata nid_to_pxm_map[MAX_NUMNODES]; | 119 | extern int __initdata nid_to_pxm_map[MAX_NUMNODES]; |
120 | #endif | 120 | #endif |
121 | 121 | ||
122 | extern u16 ia64_acpiid_to_sapicid[]; | ||
123 | |||
124 | /* | 122 | /* |
125 | * Refer Intel ACPI _PDC support document for bit definitions | 123 | * Refer Intel ACPI _PDC support document for bit definitions |
126 | */ | 124 | */ |
diff --git a/include/asm-x86_64/acpi.h b/include/asm-x86_64/acpi.h index 49f92f3cc32d..a29f05087a31 100644 --- a/include/asm-x86_64/acpi.h +++ b/include/asm-x86_64/acpi.h | |||
@@ -37,7 +37,7 @@ | |||
37 | * Calling conventions: | 37 | * Calling conventions: |
38 | * | 38 | * |
39 | * ACPI_SYSTEM_XFACE - Interfaces to host OS (handlers, threads) | 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 | * ACPI_INTERNAL_XFACE - Internal ACPI interfaces | 41 | * ACPI_INTERNAL_XFACE - Internal ACPI interfaces |
42 | * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces | 42 | * ACPI_INTERNAL_VAR_XFACE - Internal variable-parameter list interfaces |
43 | */ | 43 | */ |
@@ -87,10 +87,10 @@ extern int acpi_strict; | |||
87 | extern int acpi_disabled; | 87 | extern int acpi_disabled; |
88 | extern int acpi_pci_disabled; | 88 | extern int acpi_pci_disabled; |
89 | extern int acpi_ht; | 89 | extern int acpi_ht; |
90 | static inline void disable_acpi(void) | 90 | static inline void disable_acpi(void) |
91 | { | 91 | { |
92 | acpi_disabled = 1; | 92 | acpi_disabled = 1; |
93 | acpi_ht = 0; | 93 | acpi_ht = 0; |
94 | acpi_pci_disabled = 1; | 94 | acpi_pci_disabled = 1; |
95 | acpi_noirq = 1; | 95 | acpi_noirq = 1; |
96 | } | 96 | } |
@@ -100,9 +100,9 @@ static inline void disable_acpi(void) | |||
100 | 100 | ||
101 | extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq); | 101 | extern int acpi_gsi_to_irq(u32 gsi, unsigned int *irq); |
102 | static inline void acpi_noirq_set(void) { acpi_noirq = 1; } | 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 | acpi_noirq_set(); | 106 | acpi_noirq_set(); |
107 | } | 107 | } |
108 | extern int acpi_irq_balance_set(char *str); | 108 | extern int acpi_irq_balance_set(char *str); |
@@ -136,8 +136,6 @@ extern void acpi_reserve_bootmem(void); | |||
136 | extern int acpi_disabled; | 136 | extern int acpi_disabled; |
137 | extern int acpi_pci_disabled; | 137 | extern int acpi_pci_disabled; |
138 | 138 | ||
139 | extern u8 x86_acpiid_to_apicid[]; | ||
140 | |||
141 | #define ARCH_HAS_POWER_INIT 1 | 139 | #define ARCH_HAS_POWER_INIT 1 |
142 | 140 | ||
143 | extern int acpi_skip_timer_override; | 141 | extern int acpi_skip_timer_override; |