From 42d82ebc3137dd89464ad067ce321c263a28ac88 Mon Sep 17 00:00:00 2001 From: kettenis Date: Mon, 29 Jul 2024 18:43:11 +0000 Subject: [PATCH] Set the target ACPI to S5 when we're powering down the machine. Prevents us from trying to put devices into the D3 power state which some hardware doesn't appreciate. ok ratchov@, deraadt@ --- sys/arch/amd64/amd64/machdep.c | 8 +++++++- sys/arch/i386/i386/machdep.c | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 66cdafb5e54..0569461b97b 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.295 2024/06/26 01:40:49 jsg Exp $ */ +/* $OpenBSD: machdep.c,v 1.296 2024/07/29 18:43:11 kettenis Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -116,6 +116,7 @@ extern int db_console; #include "acpi.h" #if NACPI > 0 +#include #include #endif @@ -881,6 +882,11 @@ struct pcb dumppcb; __dead void boot(int howto) { +#if NACPI > 0 + if ((howto & RB_POWERDOWN) != 0 && acpi_softc) + acpi_softc->sc_state = ACPI_STATE_S5; +#endif + if ((howto & RB_POWERDOWN) != 0) lid_action = 0; diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index a15b37a78af..cc766289fad 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.673 2024/07/09 07:28:12 mlarkin Exp $ */ +/* $OpenBSD: machdep.c,v 1.674 2024/07/29 18:43:11 kettenis Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -115,6 +115,7 @@ #include "acpi.h" #if NACPI > 0 +#include #include #endif @@ -2598,6 +2599,11 @@ struct pcb dumppcb; __dead void boot(int howto) { +#if NACPI > 0 + if ((howto & RB_POWERDOWN) != 0 && acpi_softc) + acpi_softc->sc_state = ACPI_STATE_S5; +#endif + if ((howto & RB_POWERDOWN) != 0) lid_action = 0; -- 2.20.1