Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Jan 2017 17:12:15 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r311798 - stable/11/sys/dev/usb
Message-ID:  <201701091712.v09HCFiR084366@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Mon Jan  9 17:12:15 2017
New Revision: 311798
URL: https://svnweb.freebsd.org/changeset/base/311798

Log:
  MFC r310242:
  Defer USB enumeration until the SI_SUB_KICK_SCHEDULER is executed to avoid
  boot panics in conjunction with the recently added EARLY_AP_STARTUP feature.
  The panics happen due to using kernel facilities like callouts too early.
  
  Tested by:	jhb @

Modified:
  stable/11/sys/dev/usb/usb_hub.c
  stable/11/sys/dev/usb/usb_process.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/usb/usb_hub.c
==============================================================================
--- stable/11/sys/dev/usb/usb_hub.c	Mon Jan  9 17:10:50 2017	(r311797)
+++ stable/11/sys/dev/usb/usb_hub.c	Mon Jan  9 17:12:15 2017	(r311798)
@@ -2261,6 +2261,11 @@ usb_needs_explore(struct usb_bus *bus, u
 
 	DPRINTF("\n");
 
+	if (cold != 0) {
+		DPRINTF("Cold\n");
+		return;
+	}
+
 	if (bus == NULL) {
 		DPRINTF("No bus pointer!\n");
 		return;
@@ -2326,6 +2331,26 @@ usb_needs_explore_all(void)
 }
 
 /*------------------------------------------------------------------------*
+ *	usb_needs_explore_init
+ *
+ * This function will ensure that the USB controllers are not enumerated
+ * until the "cold" variable is cleared.
+ *------------------------------------------------------------------------*/
+static void
+usb_needs_explore_init(void *arg)
+{
+	/*
+	 * The cold variable should be cleared prior to this function
+	 * being called:
+	 */
+	if (cold == 0)
+		usb_needs_explore_all();
+	else
+		DPRINTFN(-1, "Cold variable is still set!\n");
+}
+SYSINIT(usb_needs_explore_init, SI_SUB_KICK_SCHEDULER, SI_ORDER_SECOND, usb_needs_explore_init, NULL);
+
+/*------------------------------------------------------------------------*
  *	usb_bus_power_update
  *
  * This function will ensure that all USB devices on the given bus are

Modified: stable/11/sys/dev/usb/usb_process.c
==============================================================================
--- stable/11/sys/dev/usb/usb_process.c	Mon Jan  9 17:10:50 2017	(r311797)
+++ stable/11/sys/dev/usb/usb_process.c	Mon Jan  9 17:12:15 2017	(r311798)
@@ -454,14 +454,15 @@ usb_proc_drain(struct usb_process *up)
 			up->up_csleep = 0;
 			cv_signal(&up->up_cv);
 		}
+#ifndef EARLY_AP_STARTUP
 		/* Check if we are still cold booted */
-
 		if (cold) {
 			USB_THREAD_SUSPEND(up->up_ptr);
 			printf("WARNING: A USB process has "
 			    "been left suspended\n");
 			break;
 		}
+#endif
 		cv_wait(&up->up_cv, up->up_mtx);
 	}
 	/* Check if someone is waiting - should not happen */



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