The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=781c9b0a595f9af501ad836a120aedba91c13a0b
commit 781c9b0a595f9af501ad836a120aedba91c13a0b Author: Olivier Certner <[email protected]> AuthorDate: 2026-01-28 16:06:30 +0000 Commit: Olivier Certner <[email protected]> CommitDate: 2026-02-19 10:29:07 +0000 acpi: Factor out message printing on failure of AcpiEnterSleepStatePrep() To this end, create a small wrapper, acpi_EnterSleepStatePrep(), which itself prints the failure message. While here, when trying to power down (acpi_shutdown_final()), and AcpiEnterSleepStatePrep() failed, print an additional message more explicit about the power down request having failed. Reviewed by: obiwac MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55225 --- sys/dev/acpica/acpi.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index 59ae4624f407..bbcf6ba34666 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -2593,6 +2593,23 @@ acpi_fake_objhandler(ACPI_HANDLE h, void *data) { } +/* + * Simple wrapper around AcpiEnterSleepStatePrep() printing diagnostic on error. + */ +static ACPI_STATUS +acpi_EnterSleepStatePrep(device_t acpi_dev, UINT8 SleepState) +{ + ACPI_STATUS status; + + status = AcpiEnterSleepStatePrep(SleepState); + if (ACPI_FAILURE(status)) + device_printf(acpi_dev, + "AcpiEnterSleepStatePrep(%u) failed - %s\n", + SleepState, + AcpiFormatException(status)); + return (status); +} + static void acpi_shutdown_final(void *arg, int howto) { @@ -2606,9 +2623,9 @@ acpi_shutdown_final(void *arg, int howto) * an AP. */ if ((howto & RB_POWEROFF) != 0) { - status = AcpiEnterSleepStatePrep(ACPI_STATE_S5); + status = acpi_EnterSleepStatePrep(sc->acpi_dev, ACPI_STATE_S5); if (ACPI_FAILURE(status)) { - device_printf(sc->acpi_dev, "AcpiEnterSleepStatePrep failed - %s\n", + device_printf(sc->acpi_dev, "Power-off preparation failed! - %s\n", AcpiFormatException(status)); return; } @@ -3659,12 +3676,9 @@ acpi_EnterSleepState(struct acpi_softc *sc, enum power_stype stype) slp_state |= ACPI_SS_DEV_SUSPEND; if (stype != POWER_STYPE_SUSPEND_TO_IDLE) { - status = AcpiEnterSleepStatePrep(acpi_sstate); - if (ACPI_FAILURE(status)) { - device_printf(sc->acpi_dev, "AcpiEnterSleepStatePrep failed - %s\n", - AcpiFormatException(status)); + status = acpi_EnterSleepStatePrep(sc->acpi_dev, acpi_sstate); + if (ACPI_FAILURE(status)) goto backout; - } slp_state |= ACPI_SS_SLP_PREP; }
