From 11a4679ee173a19a92d57cafe3e251dedc8ca742 Mon Sep 17 00:00:00 2001 From: kettenis Date: Fri, 10 Apr 2026 16:23:32 +0000 Subject: [PATCH] Apparently we shouldn't touch the RTC immediately after restarting the i8254 clock either when coming out of S3 suspend. So move the code that checks whether the RTC alarm went off and clears it all the way to the end of acpi_cpu_resume. This fixes a lockup seen on the x220. Figured out by mlarkin@ who write the initial diff; I just tweaked it. ok mlarkin@, deraadt@ --- sys/arch/amd64/amd64/acpi_machdep.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/sys/arch/amd64/amd64/acpi_machdep.c b/sys/arch/amd64/amd64/acpi_machdep.c index 6e1f3363f5c..884530b2b65 100644 --- a/sys/arch/amd64/amd64/acpi_machdep.c +++ b/sys/arch/amd64/amd64/acpi_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi_machdep.c,v 1.114 2026/03/15 11:16:36 kettenis Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.115 2026/04/10 16:23:32 kettenis Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * @@ -476,15 +476,8 @@ acpi_sleep_cpu(struct acpi_softc *sc, int state) void acpi_resume_cpu(struct acpi_softc *sc, int state) { - if (sc->sc_fadt->flags & FADT_USE_PLATFORM_CLOCK) { - if (rtcalarm_fired()) - sc->sc_wakegpe = WAKEGPE_RTC; - } - - if (state == ACPI_STATE_S0) { - rtcalarm_resume(); - return; - } + if (state == ACPI_STATE_S0) + goto rtc_check; cpu_init_msrs(&cpu_info_primary); cpu_fix_msrs(&cpu_info_primary); @@ -504,7 +497,6 @@ acpi_resume_cpu(struct acpi_softc *sc, int state) #endif i8254_startclock(); - rtcalarm_resume(); /* i8254 must be running */ if (initclock_func == i8254_initclocks) rtcstart(); /* in i8254 mode, rtc is profclock */ @@ -518,6 +510,13 @@ acpi_resume_cpu(struct acpi_softc *sc, int state) /* Re-initialise memory range handling on BSP */ if (mem_range_softc.mr_op != NULL) mem_range_softc.mr_op->initAP(&mem_range_softc); + +rtc_check: + if (sc->sc_fadt->flags & FADT_USE_PLATFORM_CLOCK) { + if (rtcalarm_fired()) + sc->sc_wakegpe = WAKEGPE_RTC; + } + rtcalarm_resume(); } #ifdef MULTIPROCESSOR