From e7932420b000ab045e8dd1bda25c894055a14679 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Thu, 22 Mar 2018 15:11:53 +0000 Subject: [PATCH] Revert r331298 Normally, shutdown_nice() just signals init. However, sometimes it calls kern_reboot directly. For that case, r331298 dropped the Giant lock before calling it. This turns out to be incorrect for the more common case where init exists and we just signal it. Restore the old behavior. The direct call to kern_reboot() doesn't sync buffers to the disk, so should work with Giant held, so we don't need to drop locks here for that. Noticed by: bde@ Sponsored by: Netflix --- sys/dev/syscons/syscons.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index c5eed2309c9f..2020436d89bf 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -3858,28 +3858,22 @@ scgetc(sc_softc_t *sc, u_int flags, struct sc_cnstate *sp) case RBT: #ifndef SC_DISABLE_REBOOT - if (enable_reboot && !(flags & SCGETC_CN)) { - mtx_unlock(&Giant); + if (enable_reboot && !(flags & SCGETC_CN)) shutdown_nice(0); - } #endif break; case HALT: #ifndef SC_DISABLE_REBOOT - if (enable_reboot && !(flags & SCGETC_CN)) { - mtx_unlock(&Giant); + if (enable_reboot && !(flags & SCGETC_CN)) shutdown_nice(RB_HALT); - } #endif break; case PDWN: #ifndef SC_DISABLE_REBOOT - if (enable_reboot && !(flags & SCGETC_CN)) { - mtx_unlock(&Giant); + if (enable_reboot && !(flags & SCGETC_CN)) shutdown_nice(RB_HALT|RB_POWEROFF); - } #endif break;