git: ffdfca5982b6 - main - acpi: Factor out the power off code into acpi_poweroff()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 19 Feb 2026 10:29:39 UTC
The branch main has been updated by olce:
URL: https://cgit.FreeBSD.org/src/commit/?id=ffdfca5982b60cb4145a53f965b8c51600d2f323
commit ffdfca5982b60cb4145a53f965b8c51600d2f323
Author: Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2026-01-28 16:40:51 +0000
Commit: Olivier Certner <olce@FreeBSD.org>
CommitDate: 2026-02-19 10:29:07 +0000
acpi: Factor out the power off code into acpi_poweroff()
While here, make it print that we are trying to power off upfront, not
really treating differently power off preparation via
acpi_EnterSleepStatePrep() and actual power off via
AcpiEnterSleepState(), which the user does not care about.
While here, capitalize the messages.
Reviewed by: obiwac
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55226
---
sys/dev/acpica/acpi.c | 47 ++++++++++++++++++++++++++++-------------------
1 file changed, 28 insertions(+), 19 deletions(-)
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index bbcf6ba34666..f903f265f9fa 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -2610,11 +2610,37 @@ acpi_EnterSleepStatePrep(device_t acpi_dev, UINT8 SleepState)
return (status);
}
+/* Return from this function indicates failure. */
+static void
+acpi_poweroff(device_t acpi_dev)
+{
+ register_t intr;
+ ACPI_STATUS status;
+
+ device_printf(acpi_dev, "Powering system off...\n");
+ status = acpi_EnterSleepStatePrep(acpi_dev, ACPI_STATE_S5);
+ if (ACPI_FAILURE(status)) {
+ device_printf(acpi_dev, "Power-off preparation failed! - %s\n",
+ AcpiFormatException(status));
+ return;
+ }
+ intr = intr_disable();
+ status = AcpiEnterSleepState(ACPI_STATE_S5);
+ if (ACPI_FAILURE(status)) {
+ intr_restore(intr);
+ device_printf(acpi_dev, "Power-off failed! - %s\n",
+ AcpiFormatException(status));
+ } else {
+ DELAY(1000000);
+ intr_restore(intr);
+ device_printf(acpi_dev, "Power-off failed! - timeout\n");
+ }
+}
+
static void
acpi_shutdown_final(void *arg, int howto)
{
struct acpi_softc *sc = (struct acpi_softc *)arg;
- register_t intr;
ACPI_STATUS status;
/*
@@ -2623,24 +2649,7 @@ acpi_shutdown_final(void *arg, int howto)
* an AP.
*/
if ((howto & RB_POWEROFF) != 0) {
- status = acpi_EnterSleepStatePrep(sc->acpi_dev, ACPI_STATE_S5);
- if (ACPI_FAILURE(status)) {
- device_printf(sc->acpi_dev, "Power-off preparation failed! - %s\n",
- AcpiFormatException(status));
- return;
- }
- device_printf(sc->acpi_dev, "Powering system off\n");
- intr = intr_disable();
- status = AcpiEnterSleepState(ACPI_STATE_S5);
- if (ACPI_FAILURE(status)) {
- intr_restore(intr);
- device_printf(sc->acpi_dev, "power-off failed - %s\n",
- AcpiFormatException(status));
- } else {
- DELAY(1000000);
- intr_restore(intr);
- device_printf(sc->acpi_dev, "power-off failed - timeout\n");
- }
+ acpi_poweroff(sc->acpi_dev);
} else if ((howto & RB_HALT) == 0 && sc->acpi_handle_reboot) {
/* Reboot using the reset register. */
status = AcpiReset();