From: deraadt Date: Thu, 10 Feb 2022 16:41:51 +0000 (+0000) Subject: Duplicate "park disk" code, so that the SUSPEND case can be MI, it is only X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7f8722a4d0c042401934f19a69408a62d0f71ebd;p=openbsd 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 --- 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