x86/acpi: Use new APIC registration functions
authorThomas Gleixner <tglx@linutronix.de>
Tue, 13 Feb 2024 21:05:37 +0000 (22:05 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 15 Feb 2024 21:07:42 +0000 (22:07 +0100)
Use the new topology registration functions and make the early boot code
path __init. No functional change intended.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Michael Kelley <mhklinux@outlook.com>
Tested-by: Sohil Mehta <sohil.mehta@intel.com>
Link: https://lore.kernel.org/r/20240213210251.664738831@linutronix.de
arch/x86/kernel/acpi/boot.c

index 85a3ce2a3666adf09af6c063d0cf0191ff427e01..42799d5d38764fa1908b04a05053148eff3cbf1d 100644 (file)
@@ -164,33 +164,9 @@ static int __init acpi_parse_madt(struct acpi_table_header *table)
        return 0;
 }
 
-/**
- * acpi_register_lapic - register a local apic and generates a logic cpu number
- * @id: local apic id to register
- * @acpiid: ACPI id to register
- * @enabled: this cpu is enabled or not
- *
- * Returns the logic cpu number which maps to the local apic
- */
-static int acpi_register_lapic(int id, u32 acpiid, u8 enabled)
+static __init void acpi_register_lapic(u32 apic_id, u32 acpi_id, bool present)
 {
-       int cpu;
-
-       if (id >= MAX_LOCAL_APIC) {
-               pr_info("skipped apicid that is too big\n");
-               return -EINVAL;
-       }
-
-       if (!enabled) {
-               ++disabled_cpus;
-               return -EINVAL;
-       }
-
-       cpu = generic_processor_info(id);
-       if (cpu >= 0)
-               early_per_cpu(x86_cpu_to_acpiid, cpu) = acpiid;
-
-       return cpu;
+       topology_register_apic(apic_id, acpi_id, present);
 }
 
 static bool __init acpi_is_processor_usable(u32 lapic_flags)
@@ -844,12 +820,10 @@ static int acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
        return 0;
 }
 
-int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id,
-                int *pcpu)
+int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, int *pcpu)
 {
-       int cpu;
+       int cpu = topology_hotplug_apic(physid, acpi_id);
 
-       cpu = acpi_register_lapic(physid, acpi_id, ACPI_MADT_ENABLED);
        if (cpu < 0) {
                pr_info("Unable to map lapic to logical cpu number\n");
                return cpu;
@@ -868,15 +842,11 @@ int acpi_unmap_cpu(int cpu)
 #ifdef CONFIG_ACPI_NUMA
        set_apicid_to_node(per_cpu(x86_cpu_to_apicid, cpu), NUMA_NO_NODE);
 #endif
-
-       per_cpu(x86_cpu_to_apicid, cpu) = BAD_APICID;
-       set_cpu_present(cpu, false);
-       num_processors--;
-
-       return (0);
+       topology_hotunplug_apic(cpu);
+       return 0;
 }
 EXPORT_SYMBOL(acpi_unmap_cpu);
-#endif                         /* CONFIG_ACPI_HOTPLUG_CPU */
+#endif /* CONFIG_ACPI_HOTPLUG_CPU */
 
 int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
 {