From fdc8cabef5ce3cc46522576f53d1c4ab86bbf7af Mon Sep 17 00:00:00 2001 From: deraadt Date: Thu, 17 Feb 2022 17:17:09 +0000 Subject: [PATCH] If S4 is not available, use S5 for the ACPI-transitions in hibernate support. A bunch of servers work now. Really close to a 3-line diff... ok kettenis --- sys/arch/amd64/amd64/acpi_machdep.c | 4 ++-- sys/arch/i386/i386/acpi_machdep.c | 4 ++-- sys/dev/acpi/acpi_x86.c | 7 +++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/sys/arch/amd64/amd64/acpi_machdep.c b/sys/arch/amd64/amd64/acpi_machdep.c index e119de143f1..9630237171b 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.100 2022/02/13 15:56:55 deraadt Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.101 2022/02/17 17:17:11 deraadt Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * @@ -414,7 +414,7 @@ acpi_sleep_cpu(struct acpi_softc *sc, int state) wbinvd(); #ifdef HIBERNATE - if (state == ACPI_STATE_S4) { + if (state == ACPI_STATE_S4 || state == ACPI_STATE_S5) { if (hibernate_suspend()) { printf("%s: hibernate_suspend failed\n", DEVNAME(sc)); diff --git a/sys/arch/i386/i386/acpi_machdep.c b/sys/arch/i386/i386/acpi_machdep.c index 436a0d0321c..1bb162608f1 100644 --- a/sys/arch/i386/i386/acpi_machdep.c +++ b/sys/arch/i386/i386/acpi_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi_machdep.c,v 1.82 2022/02/13 15:56:55 deraadt Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.83 2022/02/17 17:17:11 deraadt Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * @@ -376,7 +376,7 @@ acpi_sleep_cpu(struct acpi_softc *sc, int state) wbinvd(); #ifdef HIBERNATE - if (state == ACPI_STATE_S4) { + if (state == ACPI_STATE_S4 || state == ACPI_STATE_S5) { if (hibernate_suspend()) { printf("%s: hibernate_suspend failed\n", DEVNAME(sc)); diff --git a/sys/dev/acpi/acpi_x86.c b/sys/dev/acpi/acpi_x86.c index efde7ef28e4..25e09a49504 100644 --- a/sys/dev/acpi/acpi_x86.c +++ b/sys/dev/acpi/acpi_x86.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpi_x86.c,v 1.12 2022/02/17 00:47:47 jsg Exp $ */ +/* $OpenBSD: acpi_x86.c,v 1.13 2022/02/17 17:17:09 deraadt Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * Copyright (c) 2005 Jordan Hargrave @@ -47,7 +47,10 @@ sleep_showstate(void *v, int sleepmode) sc->sc_sleeptype[sc->sc_state].slp_typb == -1) { printf("%s: state S%d unavailable\n", sc->sc_dev.dv_xname, sc->sc_state); - return (EOPNOTSUPP); + if (sc->sc_state == ACPI_STATE_S4) + sc->sc_state = ACPI_STATE_S5; /* No S4, use S5 */ + else + return (EOPNOTSUPP); } /* 1st suspend AML step: _TTS(tostate) */ -- 2.20.1