svn commit: r303765 - head/sys/dev/usb/input

Hans Petter Selasky hselasky at FreeBSD.org
Fri Aug 5 08:58:02 UTC 2016


Author: hselasky
Date: Fri Aug  5 08:58:00 2016
New Revision: 303765
URL: https://svnweb.freebsd.org/changeset/base/303765

Log:
  Keep a reference count on USB keyboard polling to allow recursive
  cngrab() during a panic for example, similar to what the AT-keyboard
  driver is doing.
  
  Found by:	Bruce Evans <brde at optusnet.com.au>
  MFC after:	1 week

Modified:
  head/sys/dev/usb/input/ukbd.c

Modified: head/sys/dev/usb/input/ukbd.c
==============================================================================
--- head/sys/dev/usb/input/ukbd.c	Fri Aug  5 08:57:51 2016	(r303764)
+++ head/sys/dev/usb/input/ukbd.c	Fri Aug  5 08:58:00 2016	(r303765)
@@ -198,6 +198,7 @@ struct ukbd_softc {
 	int	sc_mode;		/* input mode (K_XLATE,K_RAW,K_CODE) */
 	int	sc_state;		/* shift/lock key state */
 	int	sc_accents;		/* accent key index (> 0) */
+	int	sc_polling;		/* polling recursion count */
 	int	sc_led_size;
 	int	sc_kbd_size;
 
@@ -1983,7 +1984,16 @@ ukbd_poll(keyboard_t *kbd, int on)
 	struct ukbd_softc *sc = kbd->kb_data;
 
 	UKBD_LOCK();
-	if (on) {
+	/*
+	 * Keep a reference count on polling to allow recursive
+	 * cngrab() during a panic for example.
+	 */
+	if (on)
+		sc->sc_polling++;
+	else
+		sc->sc_polling--;
+
+	if (sc->sc_polling != 0) {
 		sc->sc_flags |= UKBD_FLAG_POLLING;
 		sc->sc_poll_thread = curthread;
 	} else {


More information about the svn-src-all mailing list