Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Aug 2016 14:28:17 +0000 (UTC)
From:      Bruce Evans <bde@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r304161 - head/sys/dev/syscons
Message-ID:  <201608151428.u7FESH7F084304@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bde
Date: Mon Aug 15 14:28:16 2016
New Revision: 304161
URL: https://svnweb.freebsd.org/changeset/base/304161

Log:
  Change all uses of 'debugger' to kdb_active and remove this variable.  This
  restores avoidance of doing dangerous things like calling wakeup() and
  callouts while in ddb.
  
  Initialization of 'debugger' was broken by removing the cndbctl() console
  method that was used mainly in this driver to initialize 'debugger' and
  switch to the console screen on entry to ddb.  The screen switch was
  restored using the cngrab() method, but cngrab() is more general so it
  should not initialize 'debugger' and never did.  'debugger' was just
  an over-engineered alias for kdb_active anyway.  It existed because
  kdb_active (when it was named ddb_active) was considered as a private
  kdb variable, and there are ordering problems initializing the variables
  atomically with the state that they represent, but an extra variable and
  method to set it increased these problems.
  
  The bug caused LORs, but WITNESS is normally misconfigured with
  WITNESS_SKIPSIN so it doesn't check the spinlocks used by wakeup() and
  callouts.

Modified:
  head/sys/dev/syscons/syscons.c

Modified: head/sys/dev/syscons/syscons.c
==============================================================================
--- head/sys/dev/syscons/syscons.c	Mon Aug 15 14:28:08 2016	(r304160)
+++ head/sys/dev/syscons/syscons.c	Mon Aug 15 14:28:16 2016	(r304161)
@@ -172,8 +172,6 @@ SYSCTL_INT(_machdep, OID_AUTO, enable_pa
 
 #define VTY_WCHAN(sc, vty) (&SC_DEV(sc, vty))
 
-static	int		debugger;
-
 /* prototypes */
 static int sc_allocate_keyboard(sc_softc_t *sc, int unit);
 static int scvidprobe(int unit, int flags, int cons);
@@ -1815,7 +1813,7 @@ sccnupdate(scr_stat *scp)
     if (suspend_in_progress || scp->sc->font_loading_in_progress)
 	return;
 
-    if (debugger > 0 || panicstr || shutdown_in_progress) {
+    if (kdb_active || panicstr || shutdown_in_progress) {
 	sc_touch_scrn_saver();
     } else if (scp != scp->sc->cur_scp) {
 	return;
@@ -1884,7 +1882,7 @@ scrn_timer(void *arg)
 #endif /* PC98 */
 
     /* should we stop the screen saver? */
-    if (debugger > 0 || panicstr || shutdown_in_progress)
+    if (kdb_active || panicstr || shutdown_in_progress)
 	sc_touch_scrn_saver();
     if (run_scrn_saver) {
 	if (time_uptime > sc->scrn_time_stamp + scrn_blank_time)
@@ -2279,7 +2277,7 @@ stop_scrn_saver(sc_softc_t *sc, void (*s
     mark_all(sc->cur_scp);
     if (sc->delayed_next_scr)
 	sc_switch_scr(sc, sc->delayed_next_scr - 1);
-    if (debugger == 0)
+    if (!kdb_active)
 	wakeup(&scrn_blanked);
 }
 
@@ -2474,7 +2472,7 @@ sc_switch_scr(sc_softc_t *sc, u_int next
 	    DPRINTF(5, ("error 2, requested vty isn't open!\n"));
 	    return EINVAL;
 	}
-	if ((debugger > 0) && (SC_STAT(tp)->smode.mode == VT_PROCESS)) {
+	if (kdb_active && SC_STAT(tp)->smode.mode == VT_PROCESS) {
 	    splx(s);
 	    DPRINTF(5, ("error 3, requested vty is in the VT_PROCESS mode\n"));
 	    return EINVAL;
@@ -2495,7 +2493,7 @@ sc_switch_scr(sc_softc_t *sc, u_int next
 	 * is supposed to be locked by splhigh(), but the debugger may
 	 * be invoked at splhigh().
 	 */
-	if (debugger == 0)
+	if (!kdb_active)
 	    wakeup(VTY_WCHAN(sc,next_scr));
 	splx(s);
 	DPRINTF(5, ("switch done (new == old)\n"));
@@ -2518,7 +2516,7 @@ sc_switch_scr(sc_softc_t *sc, u_int next
     s = spltty();
 
     /* wake up processes waiting for this vty */
-    if (debugger == 0)
+    if (!kdb_active)
 	wakeup(VTY_WCHAN(sc,next_scr));
 
     /* wait for the controlling process to acknowledge, if necessary */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201608151428.u7FESH7F084304>