The branch main has been updated by obiwac: URL: https://cgit.FreeBSD.org/src/commit/?id=d2ad1c3ffe67d7994a409956b6344dd458170d04
commit d2ad1c3ffe67d7994a409956b6344dd458170d04 Author: Devin Teske <[email protected]> AuthorDate: 2026-09-16 12:40:45 +0000 Commit: Aymeric Wibo <[email protected]> CommitDate: 2026-09-16 12:40:52 +0000 acpi: Increase length of time (1s -> 5s) for quirk The ACPI quirk on Framework Laptop 12 firmware was previously clocked at ~620 ms for a Notify 0x80 replayed on power-button press to wake. However, when KMS is not loaded, that very same notification comes in past the 1s we previously allowed. Use the already-defined ACPI_MINIMUM_AWAKETIME (5) seconds as our new boundary so that we can successfully come out of S3 on this hardware. Introduce new tunable hw.acpi.button_replay_window Reviewed by: obiwac, olce Differential Revision: https://reviews.freebsd.org/D59583 --- sys/dev/acpica/acpi.c | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 8b897defe6ce..7f9e637c25f9 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -271,6 +271,24 @@ static struct rman acpi_rman_io, acpi_rman_mem; #define ACPI_MINIMUM_AWAKETIME 5 +/* + * Grace window after wakeup during which a power/sleep button press for suspend + * is ignored. Some firmware wrongly reports the depress that caused the wakeup + * as an "S0 Power/Sleep Button Pressed" notify (value 0x80) instead of the + * spec-required "Device Wake" notify (0x02); honoring it re-enters sleep + * immediately after resume. On the Framework Laptop 12 the replayed event + * arrives within ~620 ms of the recorded resume time when i915kms is loaded, + * so a one-second window was chosen originally; without KMS the same notify + * can arrive after that one-second mark (and is then held until + * acpi_sleep_disabled clears), so the default was widened to + * ACPI_MINIMUM_AWAKETIME seconds (the same bound already used since + * ece50487e935 to ignore sleep requests for a period after wakeup on some + * Toshiba and ThinkPad machines). Override with hw.acpi.button_replay_window + * (seconds; 0 disables; default ACPI_MINIMUM_AWAKETIME). See + * https://bugs.freebsd.org/296243 for the traces, timing data, and analysis. + */ +static int acpi_button_replay_secs = ACPI_MINIMUM_AWAKETIME; + /* Holds the description of the acpi0 device. */ static char acpi_desc[ACPI_OEM_ID_SIZE + ACPI_OEM_TABLE_ID_SIZE + 2]; @@ -763,6 +781,11 @@ acpi_attach(device_t dev) SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), OID_AUTO, "sleep_delay", CTLFLAG_RW, &sc->acpi_sleep_delay, 0, "sleep delay in seconds"); + SYSCTL_ADD_INT(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), + OID_AUTO, "button_replay_window", CTLFLAG_RWTUN, + &acpi_button_replay_secs, 0, + "Seconds after resume to ignore firmware-replayed power/sleep " + "button presses (0 disables)"); SYSCTL_ADD_BOOL(&sc->acpi_sysctl_ctx, SYSCTL_CHILDREN(sc->acpi_sysctl_tree), OID_AUTO, "s4bios_supported", CTLFLAG_RD, &sc->acpi_s4bios_supported, 0, "Whether firmware supports saving/restoring the machine state (S4BIOS)."); @@ -3769,7 +3792,7 @@ backout: /* * Record the resume time so a spurious power/sleep button press can be * ignored for a grace period afterward (see the comment before - * ACPI_BUTTON_REPLAY_WINDOW). This must be taken before + * acpi_button_replay_secs). This must be taken before * DEVICE_RESUME(), which re-initializes the EC that replays the press. */ sc->acpi_resume_sbt = getsbinuptime(); @@ -4163,27 +4186,20 @@ acpi_system_eventhandler_wakeup(struct acpi_softc *const sc, return_VOID; } -/* - * Grace window after wakeup during which a power/sleep button press for suspend - * is ignored. Some firmware wrongly reports the depress that caused the wakeup - * as an "S0 Power/Sleep Button Pressed" notify (value 0x80) instead of the - * spec-required "Device Wake" notify (0x02); honoring it re-enters sleep - * immediately after resume. On the Framework Laptop 12 the replayed event - * arrives within ~620 ms of the recorded resume time, so a one-second window - * was chosen. See https://bugs.freebsd.org/296243 for the traces, timing - * data, and analysis. - */ -#define ACPI_BUTTON_REPLAY_WINDOW SBT_1S - static bool acpi_button_resume_replay(struct acpi_softc *sc, const char *which) { - sbintime_t elapsed; + sbintime_t elapsed, window; + int secs; if (sc->acpi_resume_sbt == 0) return (false); + secs = acpi_button_replay_secs; + if (secs <= 0) + return (false); + window = SBT_1S * secs; elapsed = getsbinuptime() - sc->acpi_resume_sbt; - if (elapsed < 0 || elapsed >= ACPI_BUTTON_REPLAY_WINDOW) + if (elapsed < 0 || elapsed >= window) return (false); if (bootverbose) { device_printf(sc->acpi_dev,
