summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2022-02-15 16:54:49 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2022-02-15 16:54:49 +0000
commit7fb5e3d155483e17aacda51785d7d3772b207912 (patch)
tree2764c96148c2f88fe65b9157c09b89a9e39c1a95 /sys
parentd0d3e322b42c97fea6d68d70518a306421eabca0 (diff)
when the MI suspend code encounters problems, we need a way to
reset the MD state before bailing out. New MD function sleep_abort() does that.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/arm64/dev/apm.c7
-rw-r--r--sys/arch/macppc/dev/apm.c7
-rw-r--r--sys/dev/acpi/acpi_x86.c10
-rw-r--r--sys/kern/subr_suspend.c15
-rw-r--r--sys/sys/device.h3
5 files changed, 34 insertions, 8 deletions
diff --git a/sys/arch/arm64/dev/apm.c b/sys/arch/arm64/dev/apm.c
index f50aef6e0b4..4b65791ff8f 100644
--- a/sys/arch/arm64/dev/apm.c
+++ b/sys/arch/arm64/dev/apm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apm.c,v 1.13 2022/02/15 02:38:16 deraadt Exp $ */
+/* $OpenBSD: apm.c,v 1.14 2022/02/15 16:54:48 deraadt Exp $ */
/*-
* Copyright (c) 2001 Alexander Guy. All rights reserved.
@@ -382,6 +382,11 @@ gosleep(void *v)
// XXX
}
+void
+sleep_abort(void *v)
+{
+}
+
int
sleep_resume(void *v)
{
diff --git a/sys/arch/macppc/dev/apm.c b/sys/arch/macppc/dev/apm.c
index ea912dd81d4..302f46e9336 100644
--- a/sys/arch/macppc/dev/apm.c
+++ b/sys/arch/macppc/dev/apm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apm.c,v 1.29 2022/02/15 02:38:17 deraadt Exp $ */
+/* $OpenBSD: apm.c,v 1.30 2022/02/15 16:54:48 deraadt Exp $ */
/*-
* Copyright (c) 2001 Alexander Guy. All rights reserved.
@@ -369,6 +369,11 @@ sleep_setstate(void *v)
return 0;
}
+void
+sleep_abort(void *v)
+{
+}
+
int
sleep_resume(void *v)
{
diff --git a/sys/dev/acpi/acpi_x86.c b/sys/dev/acpi/acpi_x86.c
index de9a7373210..c7756823abb 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.5 2022/02/15 02:38:17 deraadt Exp $ */
+/* $OpenBSD: acpi_x86.c,v 1.6 2022/02/15 16:54:48 deraadt Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -135,6 +135,14 @@ gosleep(void *v)
sc->sc_state = ACPI_STATE_S0;
}
+void
+sleep_abort(void *v)
+{
+ struct acpi_softc *sc = v;
+
+ sc->sc_state = ACPI_STATE_S0;
+}
+
int
sleep_resume(void *v)
{
diff --git a/sys/kern/subr_suspend.c b/sys/kern/subr_suspend.c
index 6c34b27df89..c8c95573784 100644
--- a/sys/kern/subr_suspend.c
+++ b/sys/kern/subr_suspend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_suspend.c,v 1.5 2022/02/15 02:38:18 deraadt Exp $ */
+/* $OpenBSD: subr_suspend.c,v 1.6 2022/02/15 16:54:48 deraadt Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -63,14 +63,17 @@ sleep_state(void *v, int sleepmode)
uvmpd_hibernate();
if (hibernate_alloc()) {
printf("failed to allocate hibernate memory\n");
+ sleep_abort(v);
goto fail_alloc;
}
}
#endif /* HIBERNATE */
sensor_quiesce();
- if (config_suspend_all(DVACT_QUIESCE))
+ if (config_suspend_all(DVACT_QUIESCE)) {
+ sleep_abort(v);
goto fail_quiesce;
+ }
vfs_stall(curproc, 1);
#if NSOFTRAID > 0
@@ -103,13 +106,17 @@ sleep_state(void *v, int sleepmode)
intr_disable(); /* PSL_I for resume; PIC/APIC broken until repair */
cold = 2; /* Force other code to delay() instead of tsleep() */
- if (config_suspend_all(DVACT_SUSPEND) != 0)
+ if (config_suspend_all(DVACT_SUSPEND) != 0) {
+ sleep_abort(v);
goto fail_suspend;
+ }
suspend_randomness();
- if (sleep_setstate(v))
+ if (sleep_setstate(v)) {
+ sleep_abort(v);
goto fail_pts;
+ }
if (sleepmode == SLEEP_SUSPEND) {
/*
diff --git a/sys/sys/device.h b/sys/sys/device.h
index a0d5a7d629f..bdae174cd4d 100644
--- a/sys/sys/device.h
+++ b/sys/sys/device.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: device.h,v 1.59 2022/02/15 02:38:18 deraadt Exp $ */
+/* $OpenBSD: device.h,v 1.60 2022/02/15 16:54:48 deraadt Exp $ */
/* $NetBSD: device.h,v 1.15 1996/04/09 20:55:24 cgd Exp $ */
/*
@@ -207,6 +207,7 @@ void resume_mp(void);
int sleep_showstate(void *v, int sleepmode);
int sleep_setstate(void *v);
int sleep_resume(void *v);
+void sleep_abort(void *v);
void gosleep(void *v);
void display_suspend(void *v);
void display_resume(void *v);