-/* $OpenBSD: subr_suspend.c,v 1.9 2022/02/16 06:47:28 deraadt Exp $ */
+/* $OpenBSD: subr_suspend.c,v 1.10 2022/02/16 16:44:17 deraadt Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
if (sleep_showstate(v, sleepmode))
return EOPNOTSUPP;
-
#if NWSDISPLAY > 0
wsdisplay_suspend();
#endif
-
stop_periodic_resettodr();
#ifdef HIBERNATE
if (hibernate_alloc()) {
printf("failed to allocate hibernate memory\n");
sleep_abort(v);
- goto fail_alloc;
+ error = ENOMEM;
+ goto fail_hiballoc;
}
}
#endif /* HIBERNATE */
sensor_quiesce();
if (config_suspend_all(DVACT_QUIESCE)) {
sleep_abort(v);
+ error = EIO;
goto fail_quiesce;
}
sr_quiesce();
#endif
bufq_quiesce();
-
-
#ifdef MULTIPROCESSOR
sched_stop_secondary_cpus();
KASSERT(CPU_IS_PRIMARY(curcpu()));
if (config_suspend_all(DVACT_SUSPEND) != 0) {
sleep_abort(v);
+ error = EDEADLK;
goto fail_suspend;
}
-
suspend_randomness();
-
if (sleep_setstate(v)) {
sleep_abort(v);
+ error = ENOTBLK;
goto fail_pts;
}
splx(s);
inittodr(gettime());
-
sleep_resume(v);
-
- /* force RNG upper level reseed */
resume_randomness(rndbuf, rndbuflen);
-
#ifdef MULTIPROCESSOR
resume_mp();
sched_start_secondary_cpus();
#endif
-
vfs_stall(curproc, 0);
bufq_restart();
#ifdef HIBERNATE
if (sleepmode == SLEEP_HIBERNATE) {
hibernate_free();
-fail_alloc:
+fail_hiballoc:
hibernate_resume_bufcache();
}
#endif /* HIBERNATE */
start_periodic_resettodr();
-
#if NWSDISPLAY > 0
wsdisplay_resume();
#endif
sys_sync(curproc, NULL, NULL);
-
- /* Restore hw.setperf */
if (cpu_setperf != NULL)
- cpu_setperf(perflevel);
-
+ cpu_setperf(perflevel); /* Restore hw.setperf */
if (suspend_finish(v) == EAGAIN)
goto top;
-
return (error);
}