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

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'x86-acpi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 acpi fixes from Thomas Gleixner:
"This update deals with the fallout of the recent work to make
cpuid/node mappings persistent.

It turned out that the boot time ACPI based mapping tripped over ACPI
inconsistencies and caused regressions. It's partially reverted and
the fragile part replaced by an implementation which makes the mapping
persistent when a CPU goes online for the first time"

* 'x86-acpi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
acpi/processor: Check for duplicate processor ids at hotplug time
acpi/processor: Implement DEVICE operator for processor enumeration
x86/acpi: Restore the order of CPU IDs
Revert"x86/acpi: Enable MADT APIs to return disabled apicids"
Revert "x86/acpi: Set persistent cpuid <-> nodeid mapping when booting"

+79 -152
+7 -2
arch/x86/kernel/acpi/boot.c
··· 179 179 return -EINVAL; 180 180 } 181 181 182 + if (!enabled) { 183 + ++disabled_cpus; 184 + return -EINVAL; 185 + } 186 + 182 187 if (boot_cpu_physical_apicid != -1U) 183 188 ver = boot_cpu_apic_version; 184 189 185 - cpu = __generic_processor_info(id, ver, enabled); 190 + cpu = generic_processor_info(id, ver); 186 191 if (cpu >= 0) 187 192 early_per_cpu(x86_cpu_to_acpiid, cpu) = acpiid; 188 193 ··· 715 710 #ifdef CONFIG_ACPI_HOTPLUG_CPU 716 711 #include <acpi/processor.h> 717 712 718 - int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) 713 + static int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) 719 714 { 720 715 #ifdef CONFIG_ACPI_NUMA 721 716 int nid;
+7 -19
arch/x86/kernel/apic/apic.c
··· 2063 2063 return nr_logical_cpuids++; 2064 2064 } 2065 2065 2066 - int __generic_processor_info(int apicid, int version, bool enabled) 2066 + int generic_processor_info(int apicid, int version) 2067 2067 { 2068 2068 int cpu, max = nr_cpu_ids; 2069 2069 bool boot_cpu_detected = physid_isset(boot_cpu_physical_apicid, ··· 2121 2121 if (num_processors >= nr_cpu_ids) { 2122 2122 int thiscpu = max + disabled_cpus; 2123 2123 2124 - if (enabled) { 2125 - pr_warning("APIC: NR_CPUS/possible_cpus limit of %i " 2126 - "reached. Processor %d/0x%x ignored.\n", 2127 - max, thiscpu, apicid); 2128 - } 2124 + pr_warning("APIC: NR_CPUS/possible_cpus limit of %i " 2125 + "reached. Processor %d/0x%x ignored.\n", 2126 + max, thiscpu, apicid); 2129 2127 2130 2128 disabled_cpus++; 2131 2129 return -EINVAL; ··· 2175 2177 apic->x86_32_early_logical_apicid(cpu); 2176 2178 #endif 2177 2179 set_cpu_possible(cpu, true); 2178 - 2179 - if (enabled) { 2180 - num_processors++; 2181 - physid_set(apicid, phys_cpu_present_map); 2182 - set_cpu_present(cpu, true); 2183 - } else { 2184 - disabled_cpus++; 2185 - } 2180 + physid_set(apicid, phys_cpu_present_map); 2181 + set_cpu_present(cpu, true); 2182 + num_processors++; 2186 2183 2187 2184 return cpu; 2188 - } 2189 - 2190 - int generic_processor_info(int apicid, int version) 2191 - { 2192 - return __generic_processor_info(apicid, version, true); 2193 2185 } 2194 2186 2195 2187 int hard_smp_processor_id(void)
+42 -15
drivers/acpi/acpi_processor.c
··· 182 182 183 183 void __weak arch_unregister_cpu(int cpu) {} 184 184 185 - int __weak acpi_map_cpu2node(acpi_handle handle, int cpu, int physid) 186 - { 187 - return -ENODEV; 188 - } 189 - 190 185 static int acpi_processor_hotadd_init(struct acpi_processor *pr) 191 186 { 192 187 unsigned long long sta; ··· 278 283 } 279 284 device_declaration = 1; 280 285 pr->acpi_id = value; 286 + } 287 + 288 + if (acpi_duplicate_processor_id(pr->acpi_id)) { 289 + dev_err(&device->dev, 290 + "Failed to get unique processor _UID (0x%x)\n", 291 + pr->acpi_id); 292 + return -ENODEV; 281 293 } 282 294 283 295 pr->phys_id = acpi_get_phys_id(pr->handle, device_declaration, ··· 587 585 static int nr_unique_ids __initdata; 588 586 589 587 /* The number of the duplicate processor IDs */ 590 - static int nr_duplicate_ids __initdata; 588 + static int nr_duplicate_ids; 591 589 592 590 /* Used to store the unique processor IDs */ 593 591 static int unique_processor_ids[] __initdata = { ··· 595 593 }; 596 594 597 595 /* Used to store the duplicate processor IDs */ 598 - static int duplicate_processor_ids[] __initdata = { 596 + static int duplicate_processor_ids[] = { 599 597 [0 ... NR_CPUS - 1] = -1, 600 598 }; 601 599 ··· 640 638 void **rv) 641 639 { 642 640 acpi_status status; 641 + acpi_object_type acpi_type; 642 + unsigned long long uid; 643 643 union acpi_object object = { 0 }; 644 644 struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; 645 645 646 - status = acpi_evaluate_object(handle, NULL, NULL, &buffer); 646 + status = acpi_get_type(handle, &acpi_type); 647 647 if (ACPI_FAILURE(status)) 648 - acpi_handle_info(handle, "Not get the processor object\n"); 649 - else 650 - processor_validated_ids_update(object.processor.proc_id); 648 + return false; 651 649 652 - return AE_OK; 650 + switch (acpi_type) { 651 + case ACPI_TYPE_PROCESSOR: 652 + status = acpi_evaluate_object(handle, NULL, NULL, &buffer); 653 + if (ACPI_FAILURE(status)) 654 + goto err; 655 + uid = object.processor.proc_id; 656 + break; 657 + 658 + case ACPI_TYPE_DEVICE: 659 + status = acpi_evaluate_integer(handle, "_UID", NULL, &uid); 660 + if (ACPI_FAILURE(status)) 661 + goto err; 662 + break; 663 + default: 664 + goto err; 665 + } 666 + 667 + processor_validated_ids_update(uid); 668 + return true; 669 + 670 + err: 671 + acpi_handle_info(handle, "Invalid processor object\n"); 672 + return false; 673 + 653 674 } 654 675 655 - static void __init acpi_processor_check_duplicates(void) 676 + void __init acpi_processor_check_duplicates(void) 656 677 { 657 - /* Search all processor nodes in ACPI namespace */ 678 + /* check the correctness for all processors in ACPI namespace */ 658 679 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, 659 680 ACPI_UINT32_MAX, 660 681 acpi_processor_ids_walk, 661 682 NULL, NULL, NULL); 683 + acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, acpi_processor_ids_walk, 684 + NULL, NULL); 662 685 } 663 686 664 - bool __init acpi_processor_validate_proc_id(int proc_id) 687 + bool acpi_duplicate_processor_id(int proc_id) 665 688 { 666 689 int i; 667 690
-1
drivers/acpi/bus.c
··· 1249 1249 acpi_wakeup_device_init(); 1250 1250 acpi_debugger_init(); 1251 1251 acpi_setup_sb_notify_handler(); 1252 - acpi_set_processor_mapping(); 1253 1252 return 0; 1254 1253 } 1255 1254
+22 -111
drivers/acpi/processor_core.c
··· 32 32 } 33 33 34 34 static int map_lapic_id(struct acpi_subtable_header *entry, 35 - u32 acpi_id, phys_cpuid_t *apic_id, bool ignore_disabled) 35 + u32 acpi_id, phys_cpuid_t *apic_id) 36 36 { 37 37 struct acpi_madt_local_apic *lapic = 38 38 container_of(entry, struct acpi_madt_local_apic, header); 39 39 40 - if (ignore_disabled && !(lapic->lapic_flags & ACPI_MADT_ENABLED)) 40 + if (!(lapic->lapic_flags & ACPI_MADT_ENABLED)) 41 41 return -ENODEV; 42 42 43 43 if (lapic->processor_id != acpi_id) ··· 48 48 } 49 49 50 50 static int map_x2apic_id(struct acpi_subtable_header *entry, 51 - int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id, 52 - bool ignore_disabled) 51 + int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id) 53 52 { 54 53 struct acpi_madt_local_x2apic *apic = 55 54 container_of(entry, struct acpi_madt_local_x2apic, header); 56 55 57 - if (ignore_disabled && !(apic->lapic_flags & ACPI_MADT_ENABLED)) 56 + if (!(apic->lapic_flags & ACPI_MADT_ENABLED)) 58 57 return -ENODEV; 59 58 60 59 if (device_declaration && (apic->uid == acpi_id)) { ··· 65 66 } 66 67 67 68 static int map_lsapic_id(struct acpi_subtable_header *entry, 68 - int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id, 69 - bool ignore_disabled) 69 + int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id) 70 70 { 71 71 struct acpi_madt_local_sapic *lsapic = 72 72 container_of(entry, struct acpi_madt_local_sapic, header); 73 73 74 - if (ignore_disabled && !(lsapic->lapic_flags & ACPI_MADT_ENABLED)) 74 + if (!(lsapic->lapic_flags & ACPI_MADT_ENABLED)) 75 75 return -ENODEV; 76 76 77 77 if (device_declaration) { ··· 87 89 * Retrieve the ARM CPU physical identifier (MPIDR) 88 90 */ 89 91 static int map_gicc_mpidr(struct acpi_subtable_header *entry, 90 - int device_declaration, u32 acpi_id, phys_cpuid_t *mpidr, 91 - bool ignore_disabled) 92 + int device_declaration, u32 acpi_id, phys_cpuid_t *mpidr) 92 93 { 93 94 struct acpi_madt_generic_interrupt *gicc = 94 95 container_of(entry, struct acpi_madt_generic_interrupt, header); 95 96 96 - if (ignore_disabled && !(gicc->flags & ACPI_MADT_ENABLED)) 97 + if (!(gicc->flags & ACPI_MADT_ENABLED)) 97 98 return -ENODEV; 98 99 99 100 /* device_declaration means Device object in DSDT, in the ··· 109 112 } 110 113 111 114 static phys_cpuid_t map_madt_entry(struct acpi_table_madt *madt, 112 - int type, u32 acpi_id, bool ignore_disabled) 115 + int type, u32 acpi_id) 113 116 { 114 117 unsigned long madt_end, entry; 115 118 phys_cpuid_t phys_id = PHYS_CPUID_INVALID; /* CPU hardware ID */ ··· 127 130 struct acpi_subtable_header *header = 128 131 (struct acpi_subtable_header *)entry; 129 132 if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) { 130 - if (!map_lapic_id(header, acpi_id, &phys_id, 131 - ignore_disabled)) 133 + if (!map_lapic_id(header, acpi_id, &phys_id)) 132 134 break; 133 135 } else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) { 134 - if (!map_x2apic_id(header, type, acpi_id, &phys_id, 135 - ignore_disabled)) 136 + if (!map_x2apic_id(header, type, acpi_id, &phys_id)) 136 137 break; 137 138 } else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) { 138 - if (!map_lsapic_id(header, type, acpi_id, &phys_id, 139 - ignore_disabled)) 139 + if (!map_lsapic_id(header, type, acpi_id, &phys_id)) 140 140 break; 141 141 } else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) { 142 - if (!map_gicc_mpidr(header, type, acpi_id, &phys_id, 143 - ignore_disabled)) 142 + if (!map_gicc_mpidr(header, type, acpi_id, &phys_id)) 144 143 break; 145 144 } 146 145 entry += header->length; ··· 154 161 if (!madt) 155 162 return PHYS_CPUID_INVALID; 156 163 157 - rv = map_madt_entry(madt, 1, acpi_id, true); 164 + rv = map_madt_entry(madt, 1, acpi_id); 158 165 159 166 acpi_put_table((struct acpi_table_header *)madt); 160 167 161 168 return rv; 162 169 } 163 170 164 - static phys_cpuid_t map_mat_entry(acpi_handle handle, int type, u32 acpi_id, 165 - bool ignore_disabled) 171 + static phys_cpuid_t map_mat_entry(acpi_handle handle, int type, u32 acpi_id) 166 172 { 167 173 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 168 174 union acpi_object *obj; ··· 182 190 183 191 header = (struct acpi_subtable_header *)obj->buffer.pointer; 184 192 if (header->type == ACPI_MADT_TYPE_LOCAL_APIC) 185 - map_lapic_id(header, acpi_id, &phys_id, ignore_disabled); 193 + map_lapic_id(header, acpi_id, &phys_id); 186 194 else if (header->type == ACPI_MADT_TYPE_LOCAL_SAPIC) 187 - map_lsapic_id(header, type, acpi_id, &phys_id, ignore_disabled); 195 + map_lsapic_id(header, type, acpi_id, &phys_id); 188 196 else if (header->type == ACPI_MADT_TYPE_LOCAL_X2APIC) 189 - map_x2apic_id(header, type, acpi_id, &phys_id, ignore_disabled); 197 + map_x2apic_id(header, type, acpi_id, &phys_id); 190 198 else if (header->type == ACPI_MADT_TYPE_GENERIC_INTERRUPT) 191 - map_gicc_mpidr(header, type, acpi_id, &phys_id, 192 - ignore_disabled); 199 + map_gicc_mpidr(header, type, acpi_id, &phys_id); 193 200 194 201 exit: 195 202 kfree(buffer.pointer); 196 203 return phys_id; 197 204 } 198 205 199 - static phys_cpuid_t __acpi_get_phys_id(acpi_handle handle, int type, 200 - u32 acpi_id, bool ignore_disabled) 206 + phys_cpuid_t acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id) 201 207 { 202 208 phys_cpuid_t phys_id; 203 209 204 - phys_id = map_mat_entry(handle, type, acpi_id, ignore_disabled); 210 + phys_id = map_mat_entry(handle, type, acpi_id); 205 211 if (invalid_phys_cpuid(phys_id)) 206 - phys_id = map_madt_entry(get_madt_table(), type, acpi_id, 207 - ignore_disabled); 212 + phys_id = map_madt_entry(get_madt_table(), type, acpi_id); 208 213 209 214 return phys_id; 210 - } 211 - 212 - phys_cpuid_t acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id) 213 - { 214 - return __acpi_get_phys_id(handle, type, acpi_id, true); 215 215 } 216 216 217 217 int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id) ··· 261 277 return acpi_map_cpuid(phys_id, acpi_id); 262 278 } 263 279 EXPORT_SYMBOL_GPL(acpi_get_cpuid); 264 - 265 - #ifdef CONFIG_ACPI_HOTPLUG_CPU 266 - static bool __init 267 - map_processor(acpi_handle handle, phys_cpuid_t *phys_id, int *cpuid) 268 - { 269 - int type, id; 270 - u32 acpi_id; 271 - acpi_status status; 272 - acpi_object_type acpi_type; 273 - unsigned long long tmp; 274 - union acpi_object object = { 0 }; 275 - struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; 276 - 277 - status = acpi_get_type(handle, &acpi_type); 278 - if (ACPI_FAILURE(status)) 279 - return false; 280 - 281 - switch (acpi_type) { 282 - case ACPI_TYPE_PROCESSOR: 283 - status = acpi_evaluate_object(handle, NULL, NULL, &buffer); 284 - if (ACPI_FAILURE(status)) 285 - return false; 286 - acpi_id = object.processor.proc_id; 287 - 288 - /* validate the acpi_id */ 289 - if(acpi_processor_validate_proc_id(acpi_id)) 290 - return false; 291 - break; 292 - case ACPI_TYPE_DEVICE: 293 - status = acpi_evaluate_integer(handle, "_UID", NULL, &tmp); 294 - if (ACPI_FAILURE(status)) 295 - return false; 296 - acpi_id = tmp; 297 - break; 298 - default: 299 - return false; 300 - } 301 - 302 - type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0; 303 - 304 - *phys_id = __acpi_get_phys_id(handle, type, acpi_id, false); 305 - id = acpi_map_cpuid(*phys_id, acpi_id); 306 - 307 - if (id < 0) 308 - return false; 309 - *cpuid = id; 310 - return true; 311 - } 312 - 313 - static acpi_status __init 314 - set_processor_node_mapping(acpi_handle handle, u32 lvl, void *context, 315 - void **rv) 316 - { 317 - phys_cpuid_t phys_id; 318 - int cpu_id; 319 - 320 - if (!map_processor(handle, &phys_id, &cpu_id)) 321 - return AE_ERROR; 322 - 323 - acpi_map_cpu2node(handle, cpu_id, phys_id); 324 - return AE_OK; 325 - } 326 - 327 - void __init acpi_set_processor_mapping(void) 328 - { 329 - /* Set persistent cpu <-> node mapping for all processors. */ 330 - acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT, 331 - ACPI_UINT32_MAX, set_processor_node_mapping, 332 - NULL, NULL, NULL); 333 - } 334 - #else 335 - void __init acpi_set_processor_mapping(void) {} 336 - #endif /* CONFIG_ACPI_HOTPLUG_CPU */ 337 280 338 281 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC 339 282 static int get_ioapic_id(struct acpi_subtable_header *entry, u32 gsi_base,
+1 -4
include/linux/acpi.h
··· 287 287 } 288 288 289 289 /* Validate the processor object's proc_id */ 290 - bool acpi_processor_validate_proc_id(int proc_id); 290 + bool acpi_duplicate_processor_id(int proc_id); 291 291 292 292 #ifdef CONFIG_ACPI_HOTPLUG_CPU 293 293 /* Arch dependent functions for cpu hotplug support */ 294 294 int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, 295 295 int *pcpu); 296 296 int acpi_unmap_cpu(int cpu); 297 - int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid); 298 297 #endif /* CONFIG_ACPI_HOTPLUG_CPU */ 299 - 300 - void acpi_set_processor_mapping(void); 301 298 302 299 #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC 303 300 int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);