[patch 25/53] x86/acpi: Use new APIC registration functions

Thomas Gleixner posted 53 patches 2 years, 4 months ago
[patch 25/53] x86/acpi: Use new APIC registration functions
Posted by Thomas Gleixner 2 years, 4 months ago
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>
---
 arch/x86/kernel/acpi/boot.c |   44 +++++++-------------------------------------
 1 file changed, 7 insertions(+), 37 deletions(-)

--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -159,33 +159,9 @@ static int __init acpi_parse_madt(struct
 	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)
@@ -827,12 +803,10 @@ static int acpi_map_cpu2node(acpi_handle
 	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;
@@ -851,15 +825,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)
 {
Re: [patch 25/53] x86/acpi: Use new APIC registration functions
Posted by Peter Zijlstra 2 years, 4 months ago
On Mon, Aug 07, 2023 at 03:53:12PM +0200, Thomas Gleixner wrote:
> +static __init void acpi_register_lapic(u32 apic_id, u32 acpi_id, bool present)

just stating on the record what I said during review last week: whoever
caused these APIC and ACPI names to go together was a sadist.

Same 4 letters but permuted differently :-/ this is so very hard to keep
straight.
Re: [patch 25/53] x86/acpi: Use new APIC registration functions
Posted by Thomas Gleixner 2 years, 4 months ago
On Mon, Aug 07 2023 at 17:27, Peter Zijlstra wrote:

> On Mon, Aug 07, 2023 at 03:53:12PM +0200, Thomas Gleixner wrote:
>> +static __init void acpi_register_lapic(u32 apic_id, u32 acpi_id, bool present)
>
> just stating on the record what I said during review last week: whoever
> caused these APIC and ACPI names to go together was a sadist.
>
> Same 4 letters but permuted differently :-/ this is so very hard to keep
> straight.

Good thing that the kernel has no use for Atmospheric Pressure Chemical
Ionization otherwise we'd have APCI right next to it.
Re: [patch 25/53] x86/acpi: Use new APIC registration functions
Posted by Andrew Cooper 2 years, 4 months ago
On 07/08/2023 4:27 pm, Peter Zijlstra wrote:
> On Mon, Aug 07, 2023 at 03:53:12PM +0200, Thomas Gleixner wrote:
>> +static __init void acpi_register_lapic(u32 apic_id, u32 acpi_id, bool present)
> just stating on the record what I said during review last week: whoever
> caused these APIC and ACPI names to go together was a sadist.

My feedback was surprisingly similar.

I still look at that and think it ought to fail to compile.

~Andrew