Module Name:    src
Committed By:   mrg
Date:           Mon Mar 12 02:44:17 UTC 2012

Modified Files:
        src/sys/dev/scsipi: scsiconf.c
        src/sys/dev/usb: uhub.c

Log Message:
take the kernel lock a few more places when doing detach, to avoid
triggering KERNEL_LOCK_P() asserts in both scsi and usb code.

with this and other recent fixes i can now "drvctl -d ehci0".


To generate a diff of this commit:
cvs rdiff -u -r1.263 -r1.264 src/sys/dev/scsipi/scsiconf.c
cvs rdiff -u -r1.116 -r1.117 src/sys/dev/usb/uhub.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/scsipi/scsiconf.c
diff -u src/sys/dev/scsipi/scsiconf.c:1.263 src/sys/dev/scsipi/scsiconf.c:1.264
--- src/sys/dev/scsipi/scsiconf.c:1.263	Sun Mar 11 02:16:55 2012
+++ src/sys/dev/scsipi/scsiconf.c	Mon Mar 12 02:44:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsiconf.c,v 1.263 2012/03/11 02:16:55 mrg Exp $	*/
+/*	$NetBSD: scsiconf.c,v 1.264 2012/03/12 02:44:16 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.263 2012/03/11 02:16:55 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.264 2012/03/12 02:44:16 mrg Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -256,11 +256,18 @@ scsibusdetach(device_t self, int flags)
 	struct scsipi_xfer *xs;
 	int error;
 
+	/* XXXSMP scsipi */
+	KERNEL_LOCK(1, curlwp);
+
 	/*
 	 * Detach all of the periphs.
 	 */
-	if ((error = scsipi_target_detach(chan, -1, -1, flags)) != 0)
+	if ((error = scsipi_target_detach(chan, -1, -1, flags)) != 0) {
+		/* XXXSMP scsipi */
+		KERNEL_UNLOCK_ONE(curlwp);
+
 		return error;
+	}
 
 	pmf_device_deregister(self);
 
@@ -290,6 +297,10 @@ scsibusdetach(device_t self, int flags)
 	 * Now shut down the channel.
 	 */
 	scsipi_channel_shutdown(chan);
+
+	/* XXXSMP scsipi */
+	KERNEL_UNLOCK_ONE(curlwp);
+
 	return 0;
 }
 

Index: src/sys/dev/usb/uhub.c
diff -u src/sys/dev/usb/uhub.c:1.116 src/sys/dev/usb/uhub.c:1.117
--- src/sys/dev/usb/uhub.c:1.116	Fri Mar  9 00:12:10 2012
+++ src/sys/dev/usb/uhub.c	Mon Mar 12 02:44:17 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: uhub.c,v 1.116 2012/03/09 00:12:10 jakllsch Exp $	*/
+/*	$NetBSD: uhub.c,v 1.117 2012/03/12 02:44:17 mrg Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $	*/
 
 /*
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.116 2012/03/09 00:12:10 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.117 2012/03/12 02:44:17 mrg Exp $");
 
 #include "opt_usb.h"
 
@@ -597,13 +597,20 @@ uhub_detach(device_t self, int flags)
 	if (hub == NULL)		/* Must be partially working */
 		return (0);
 
+	/* XXXSMP usb */
+	KERNEL_LOCK(1, curlwp);
+
 	nports = hub->hubdesc.bNbrPorts;
 	for(port = 0; port < nports; port++) {
 		rup = &hub->ports[port];
 		if (rup->device == NULL)
 			continue;
-		if ((rc = usb_disconnect_port(rup, self, flags)) != 0)
+		if ((rc = usb_disconnect_port(rup, self, flags)) != 0) {
+			/* XXXSMP usb */
+			KERNEL_UNLOCK_ONE(curlwp);
+
 			return rc;
+		}
 	}
 
 	pmf_device_deregister(self);
@@ -623,6 +630,9 @@ uhub_detach(device_t self, int flags)
 	if (sc->sc_statusbuf)
 		free(sc->sc_statusbuf, M_USBDEV);
 
+	/* XXXSMP usb */
+	KERNEL_UNLOCK_ONE(curlwp);
+
 	return (0);
 }
 

Reply via email to