Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Feb 2015 13:02:00 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r278849 - head/sys/dev/vt
Message-ID:  <201502161302.t1GD20Rp017372@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: avg
Date: Mon Feb 16 13:02:00 2015
New Revision: 278849
URL: https://svnweb.freebsd.org/changeset/base/278849

Log:
  vt: move suspend/resume event handlers registration outside of mutex scope
  
  This is to avoid a witness warning about a waiting memory allocation in
  the evnt hanlder registration code.
  
  Reported by:	markj
  MFC after:	3 days
  X-MFC with:	r277795

Modified:
  head/sys/dev/vt/vt_core.c

Modified: head/sys/dev/vt/vt_core.c
==============================================================================
--- head/sys/dev/vt/vt_core.c	Mon Feb 16 12:56:55 2015	(r278848)
+++ head/sys/dev/vt/vt_core.c	Mon Feb 16 13:02:00 2015	(r278849)
@@ -2518,6 +2518,7 @@ vt_upgrade(struct vt_device *vd)
 {
 	struct vt_window *vw;
 	unsigned int i;
+	int register_handlers;
 
 	if (!vty_enabled(VTY_VT))
 		return;
@@ -2546,6 +2547,7 @@ vt_upgrade(struct vt_device *vd)
 	if (vd->vd_curwindow == NULL)
 		vd->vd_curwindow = vd->vd_windows[VT_CONSWINDOW];
 
+	register_handlers = 0;
 	if (!(vd->vd_flags & VDF_ASYNC)) {
 		/* Attach keyboard. */
 		vt_allocate_keyboard(vd);
@@ -2557,18 +2559,21 @@ vt_upgrade(struct vt_device *vd)
 		vd->vd_flags |= VDF_ASYNC;
 		callout_reset(&vd->vd_timer, hz / VT_TIMERFREQ, vt_timer, vd);
 		vd->vd_timer_armed = 1;
+		register_handlers = 1;
+	}
+
+	VT_UNLOCK(vd);
+
+	/* Refill settings with new sizes. */
+	vt_resize(vd);
 
+	if (register_handlers) {
 		/* Register suspend/resume handlers. */
 		EVENTHANDLER_REGISTER(power_suspend_early, vt_suspend_handler,
 		    vd, EVENTHANDLER_PRI_ANY);
 		EVENTHANDLER_REGISTER(power_resume, vt_resume_handler, vd,
 		    EVENTHANDLER_PRI_ANY);
 	}
-
-	VT_UNLOCK(vd);
-
-	/* Refill settings with new sizes. */
-	vt_resize(vd);
 }
 
 static void



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