Skip to contentSkip to conversation

ACPICA: Add support for MADT online enabled bit

PATCH In review Mario Limonciello 2 participants 4 messages Sep 8, 2021 – Sep 13, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 ACPICA: Add support for MADT online enabled bit

The online enabled bit on newer ACPI implmentations will indicate whether the CPU is hotpluggable.

---
 include/acpi/actbl2.h | 1 +
 1 file changed, 1 insertion(+)

Changes from v2:
* Split into a separate patch from the acpica pull request

include/acpi/actbl2.h +1 -0
index 2069ac38a4e2..fae45e383987 100644
@@ -808,6 +808,7 @@ struct acpi_madt_multiproc_wakeup_mailbox {
 /* MADT Local APIC flags */
 
 #define ACPI_MADT_ENABLED           (1)	/* 00: Processor is usable if set */
+#define ACPI_MADT_ONLINE_CAPABLE    (2)	/* 01: System HW supports enabling processor at runtime */
 
 /* MADT MPS INTI flags (inti_flags) */
 
Signature · 1 line
2.25.1
#1 lore raw

PATCH v3 2/2 x86/acpi: Don't add CPUs that are not online capable

A number of systems are showing "hotplug capable" CPUs when they are not really hotpluggable. This is because the MADT has extra CPU entries to support different CPUs that may be inserted into the socket with different numbers of cores.

Starting with ACPI 6.3 the spec has an Online Capable bit in the MADT used to determine whether or not a CPU is hotplug capable when the enabled bit is not set.

---
 arch/x86/kernel/acpi/boot.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Changes from v1 -> v2:
* Make the change only apply on ACPI 6.3 or later
Changes from v2 -> v3:
* Make acpi_support_online_capable static and only valid if CONFIG_X86_LOCAL_APIC is defined

arch/x86/kernel/acpi/boot.c +9 -0
index e55e0c1fad8c..d915f01b582b 100644
@@ -62,6 +62,7 @@ int acpi_fix_pin2_polarity __initdata;
 
 #ifdef CONFIG_X86_LOCAL_APIC
 static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
+static bool acpi_support_online_capable;
 #endif
 
 #ifdef CONFIG_X86_IO_APIC
@@ -138,6 +139,8 @@ static int __init acpi_parse_madt(struct acpi_table_header *table)
 
 		pr_debug("Local APIC address 0x%08x\n", madt->address);
 	}
+	if (madt->header.revision >= 5)
+		acpi_support_online_capable = true;
 
 	default_acpi_madt_oem_check(madt->header.oem_id,
 				    madt->header.oem_table_id);
@@ -239,6 +242,12 @@ acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)
 	if (processor->id == 0xff)
 		return 0;
 
+	/* don't register processors that can not be onlined */
+	if (acpi_support_online_capable &&
+	    !(processor->lapic_flags & ACPI_MADT_ENABLED) &&
+	    !(processor->lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
+		return 0;
+
 	/*
 	 * We need to register disabled CPU as well to permit
 	 * counting disabled CPUs. This allows us to size
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v3 2/2] x86/acpi: Don't add CPUs that are not online capable

Quoted 6 lines · Mario Limonciello

A number of systems are showing "hotplug capable" CPUs when they are not really hotpluggable. This is because the MADT has extra CPU entries to support different CPUs that may be inserted into the socket with different numbers of cores.

Quoted 6 lines

Starting with ACPI 6.3 the spec has an Online Capable bit in the MADT used to determine whether or not a CPU is hotplug capable when the enabled bit is not set.

I've added the patches in this series to my queue, but given what this one does, I think that it's a bit risky, because it exposes the kernel to a new category of possible platform firmware bugs.

For this reason, I'd rather queue it up as 5.16 material (and of course x86 reviewer comments are welcome).

Quoted 45 lines
---
 arch/x86/kernel/acpi/boot.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Changes from v1 -> v2:
* Make the change only apply on ACPI 6.3 or later
Changes from v2 -> v3:
* Make acpi_support_online_capable static and only valid if CONFIG_X86_LOCAL_APIC is defined

arch/x86/kernel/acpi/boot.c +9 -1
index e55e0c1fad8c..d915f01b582b 100644
@@ -62,6 +62,7 @@ int acpi_fix_pin2_polarity __initdata;
 
 #ifdef CONFIG_X86_LOCAL_APIC
 static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
+static bool acpi_support_online_capable;
 #endif
 
 #ifdef CONFIG_X86_IO_APIC
@@ -138,6 +139,8 @@ static int __init acpi_parse_madt(struct acpi_table_header *table)
 
                pr_debug("Local APIC address 0x%08x\n", madt->address);
        }
+       if (madt->header.revision >= 5)
+               acpi_support_online_capable = true;
 
        default_acpi_madt_oem_check(madt->header.oem_id,
                                    madt->header.oem_table_id);
@@ -239,6 +242,12 @@ acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)
        if (processor->id == 0xff)
                return 0;
 
+       /* don't register processors that can not be onlined */
+       if (acpi_support_online_capable &&
+           !(processor->lapic_flags & ACPI_MADT_ENABLED) &&
+           !(processor->lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
+               return 0;
+
        /*
         * We need to register disabled CPU as well to permit
         * counting disabled CPUs. This allows us to size
--

2.25.1

#3 lore raw

Re: [PATCH v3 2/2] x86/acpi: Don't add CPUs that are not online capable

Quoted 12 lines · Rafael J. Wysocki
Quoted 10 lines · Mario Limonciello

A number of systems are showing "hotplug capable" CPUs when they are not really hotpluggable. This is because the MADT has extra CPU entries to support different CPUs that may be inserted into the socket with different numbers of cores.

Starting with ACPI 6.3 the spec has an Online Capable bit in the MADT used to determine whether or not a CPU is hotplug capable when the enabled bit is not set.

Quoted 7 lines
Quoted 2 lines

I've added the patches in this series to my queue, but given what this one does, I think that it's a bit risky, because it exposes the kernel to a new category of possible platform firmware bugs.

Sounds good, appreciate the diligence.

Quoted 48 lines

For this reason, I'd rather queue it up as 5.16 material (and of course x86 reviewer comments are welcome).

Quoted 45 lines
---
  arch/x86/kernel/acpi/boot.c | 9 +++++++++
  1 file changed, 9 insertions(+)

Changes from v1 -> v2:
* Make the change only apply on ACPI 6.3 or later
Changes from v2 -> v3:
* Make acpi_support_online_capable static and only valid if CONFIG_X86_LOCAL_APIC is defined

arch/x86/kernel/acpi/boot.c +9 -1
index e55e0c1fad8c..d915f01b582b 100644
@@ -62,6 +62,7 @@ int acpi_fix_pin2_polarity __initdata;
 
  #ifdef CONFIG_X86_LOCAL_APIC
  static u64 acpi_lapic_addr __initdata = APIC_DEFAULT_PHYS_BASE;
+static bool acpi_support_online_capable;
  #endif
 
  #ifdef CONFIG_X86_IO_APIC
@@ -138,6 +139,8 @@ static int __init acpi_parse_madt(struct acpi_table_header *table)
 
                 pr_debug("Local APIC address 0x%08x\n", madt->address);
         }
+       if (madt->header.revision >= 5)
+               acpi_support_online_capable = true;
 
         default_acpi_madt_oem_check(madt->header.oem_id,
                                     madt->header.oem_table_id);
@@ -239,6 +242,12 @@ acpi_parse_lapic(union acpi_subtable_headers * header, const unsigned long end)
         if (processor->id == 0xff)
                 return 0;
 
+       /* don't register processors that can not be onlined */
+       if (acpi_support_online_capable &&
+           !(processor->lapic_flags & ACPI_MADT_ENABLED) &&
+           !(processor->lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
+               return 0;
+
         /*
          * We need to register disabled CPU as well to permit
          * counting disabled CPUs. This allows us to size
--

2.25.1