Duplicate "park disk" code, so that the SUSPEND case can be MI, it is only
authorderaadt <deraadt@openbsd.org>
Thu, 10 Feb 2022 16:41:51 +0000 (16:41 +0000)
committerderaadt <deraadt@openbsd.org>
Thu, 10 Feb 2022 16:41:51 +0000 (16:41 +0000)
HIBERNATE that needs to be in MD code.
ok gkoehler

sys/arch/amd64/amd64/acpi_machdep.c
sys/arch/i386/i386/acpi_machdep.c
sys/kern/subr_suspend.c

index 75c0b5d..c0cd38c 100644 (file)
@@ -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 <tholo@sigmasoft.com>
  *
@@ -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);
index 75c5b9f..bf415cd 100644 (file)
@@ -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 <tholo@sigmasoft.com>
  *
@@ -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);
index f92ee7d..84ea1b7 100644 (file)
@@ -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 <tholo@sigmasoft.com>
  * Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -21,6 +21,7 @@
 #include <sys/buf.h>
 #include <sys/malloc.h>
 #include <sys/pool.h>
+#include <sys/reboot.h>
 #include <sys/proc.h>
 #include <sys/sensors.h>
 #include <sys/sysctl.h>
@@ -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