Skip to content

Commit 8cdddd1

Browse files
vittyvkrafaeljw
authored andcommitted
ACPI: processor: Fix CPU0 wakeup in acpi_idle_play_dead()
Commit 496121c ("ACPI: processor: idle: Allow probing on platforms with one ACPI C-state") broke CPU0 hotplug on certain systems, e.g. I'm observing the following on AWS Nitro (e.g r5b.xlarge but other instance types are affected as well): # echo 0 > /sys/devices/system/cpu/cpu0/online # echo 1 > /sys/devices/system/cpu/cpu0/online <10 seconds delay> -bash: echo: write error: Input/output error In fact, the above mentioned commit only revealed the problem and did not introduce it. On x86, to wakeup CPU an NMI is being used and hlt_play_dead()/mwait_play_dead() loops are prepared to handle it: /* * If NMI wants to wake up CPU0, start CPU0. */ if (wakeup_cpu0()) start_cpu0(); cpuidle_play_dead() -> acpi_idle_play_dead() (which is now being called on systems where it wasn't called before the above mentioned commit) serves the same purpose but it doesn't have a path for CPU0. What happens now on wakeup is: - NMI is sent to CPU0 - wakeup_cpu0_nmi() works as expected - we get back to while (1) loop in acpi_idle_play_dead() - safe_halt() puts CPU0 to sleep again. The straightforward/minimal fix is add the special handling for CPU0 on x86 and that's what the patch is doing. Fixes: 496121c ("ACPI: processor: idle: Allow probing on platforms with one ACPI C-state") Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> Cc: 5.10+ <stable@vger.kernel.org> # 5.10+ Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent a5e13c6 commit 8cdddd1

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

arch/x86/include/asm/smp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ void native_play_dead(void);
132132
void play_dead_common(void);
133133
void wbinvd_on_cpu(int cpu);
134134
int wbinvd_on_all_cpus(void);
135+
bool wakeup_cpu0(void);
135136

136137
void native_smp_send_reschedule(int cpu);
137138
void native_send_call_func_ipi(const struct cpumask *mask);

arch/x86/kernel/smpboot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1659,7 +1659,7 @@ void play_dead_common(void)
16591659
local_irq_disable();
16601660
}
16611661

1662-
static bool wakeup_cpu0(void)
1662+
bool wakeup_cpu0(void)
16631663
{
16641664
if (smp_processor_id() == 0 && enable_start_cpu0)
16651665
return true;

drivers/acpi/processor_idle.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
*/
3030
#ifdef CONFIG_X86
3131
#include <asm/apic.h>
32+
#include <asm/cpu.h>
3233
#endif
3334

3435
#define _COMPONENT ACPI_PROCESSOR_COMPONENT
@@ -541,6 +542,12 @@ static int acpi_idle_play_dead(struct cpuidle_device *dev, int index)
541542
wait_for_freeze();
542543
} else
543544
return -ENODEV;
545+
546+
#if defined(CONFIG_X86) && defined(CONFIG_HOTPLUG_CPU)
547+
/* If NMI wants to wake up CPU0, start CPU0. */
548+
if (wakeup_cpu0())
549+
start_cpu0();
550+
#endif
544551
}
545552

546553
/* Never reached */

0 commit comments

Comments
 (0)