From 7f8722a4d0c042401934f19a69408a62d0f71ebd Mon Sep 17 00:00:00 2001 From: deraadt Date: Thu, 10 Feb 2022 16:41:51 +0000 Subject: [PATCH] Duplicate "park disk" code, so that the SUSPEND case can be MI, it is only HIBERNATE that needs to be in MD code. ok gkoehler --- sys/arch/amd64/amd64/acpi_machdep.c | 20 ++++++++++---------- sys/arch/i386/i386/acpi_machdep.c | 18 +++++++++--------- sys/kern/subr_suspend.c | 14 +++++++++++++- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/sys/arch/amd64/amd64/acpi_machdep.c b/sys/arch/amd64/amd64/acpi_machdep.c index 75c0b5d0482..c0cd38c7558 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.96 2022/02/09 23:54:32 deraadt Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.97 2022/02/10 16:41:51 deraadt Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * @@ -429,18 +429,18 @@ acpi_sleep_cpu(struct acpi_softc *sc, int state) DEVNAME(sc)); return (ECANCELED); } + + /* + * XXX + * Flag to disk drivers that they should "power down" the disk + * when we get to DVACT_POWERDOWN. + */ + boothowto |= RB_POWERDOWN; + config_suspend_all(DVACT_POWERDOWN); + boothowto &= ~RB_POWERDOWN; } #endif - /* - * XXX - * Flag to disk drivers that they should "power down" the disk - * when we get to DVACT_POWERDOWN. - */ - boothowto |= RB_POWERDOWN; - config_suspend_all(DVACT_POWERDOWN); - boothowto &= ~RB_POWERDOWN; - acpi_sleep_pm(sc, state); printf("%s: acpi_sleep_pm failed", DEVNAME(sc)); return (ECANCELED); diff --git a/sys/arch/i386/i386/acpi_machdep.c b/sys/arch/i386/i386/acpi_machdep.c index 75c5b9f875d..bf415cd46bc 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.78 2022/02/09 23:54:34 deraadt Exp $ */ +/* $OpenBSD: acpi_machdep.c,v 1.79 2022/02/10 16:41:53 deraadt Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * @@ -390,17 +390,17 @@ acpi_sleep_cpu(struct acpi_softc *sc, int state) DEVNAME(sc)); return (ECANCELED); } + + /* XXX + * Flag to disk drivers that they should "power down" the disk + * when we get to DVACT_POWERDOWN. + */ + boothowto |= RB_POWERDOWN; + config_suspend_all(DVACT_POWERDOWN); + boothowto &= ~RB_POWERDOWN; } #endif - /* XXX - * Flag to disk drivers that they should "power down" the disk - * when we get to DVACT_POWERDOWN. - */ - boothowto |= RB_POWERDOWN; - config_suspend_all(DVACT_POWERDOWN); - boothowto &= ~RB_POWERDOWN; - acpi_sleep_pm(sc, state); printf("%s: acpi_sleep_pm failed", DEVNAME(sc)); return (ECANCELED); diff --git a/sys/kern/subr_suspend.c b/sys/kern/subr_suspend.c index f92ee7d399c..84ea1b7412c 100644 --- a/sys/kern/subr_suspend.c +++ b/sys/kern/subr_suspend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_suspend.c,v 1.1 2022/02/08 17:25:12 deraadt Exp $ */ +/* $OpenBSD: subr_suspend.c,v 1.2 2022/02/10 16:41:53 deraadt Exp $ */ /* * Copyright (c) 2005 Thorsten Lockert * Copyright (c) 2005 Jordan Hargrave @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -109,6 +110,17 @@ sleep_state(void *v, int sleepmode) if (sleep_setstate(v)) goto fail_pts; + if (sleepmode == SLEEP_SUSPEND) { + /* + * XXX + * Flag to disk drivers that they should "power down" the disk + * when we get to DVACT_POWERDOWN. + */ + boothowto |= RB_POWERDOWN; + config_suspend_all(DVACT_POWERDOWN); + boothowto &= ~RB_POWERDOWN; + } + gosleep(v); #ifdef HIBERNATE -- 2.20.1