Module Name: src
Committed By: riz
Date: Mon Mar 19 23:14:00 UTC 2012
Modified Files:
src/sys/dev/ic [netbsd-6]: ncr53c9x.c ninjascsi32.c
src/sys/dev/scsipi [netbsd-6]: scsiconf.c
src/sys/dev/usb [netbsd-6]: uhub.c
Log Message:
Pull up following revision(s) (requested by mrg in ticket #125):
sys/dev/scsipi/scsiconf.c: revision 1.263
sys/dev/scsipi/scsiconf.c: revision 1.264
sys/dev/ic/ncr53c9x.c: revision 1.144
sys/dev/ic/ninjascsi32.c: revision 1.22
sys/dev/usb/uhub.c: revision 1.117
take the kernel lock in functions called from attach*().
scsidevdetached ioctl path enters scsipi code without kernel lock
and this upsets the newer kasserts. take kernel lock here.
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.143 -r1.143.8.1 src/sys/dev/ic/ncr53c9x.c
cvs rdiff -u -r1.21 -r1.21.14.1 src/sys/dev/ic/ninjascsi32.c
cvs rdiff -u -r1.262 -r1.262.10.1 src/sys/dev/scsipi/scsiconf.c
cvs rdiff -u -r1.114 -r1.114.10.1 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/ic/ncr53c9x.c
diff -u src/sys/dev/ic/ncr53c9x.c:1.143 src/sys/dev/ic/ncr53c9x.c:1.143.8.1
--- src/sys/dev/ic/ncr53c9x.c:1.143 Sun Jul 31 18:39:00 2011
+++ src/sys/dev/ic/ncr53c9x.c Mon Mar 19 23:13:59 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: ncr53c9x.c,v 1.143 2011/07/31 18:39:00 jakllsch Exp $ */
+/* $NetBSD: ncr53c9x.c,v 1.143.8.1 2012/03/19 23:13:59 riz Exp $ */
/*-
* Copyright (c) 1998, 2002 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ncr53c9x.c,v 1.143 2011/07/31 18:39:00 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ncr53c9x.c,v 1.143.8.1 2012/03/19 23:13:59 riz Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -530,6 +530,9 @@ ncr53c9x_init(struct ncr53c9x_softc *sc,
sc->sc_msgpriq = sc->sc_msgout = sc->sc_msgoutq = 0;
sc->sc_phase = sc->sc_prevphase = INVALID_PHASE;
+ /* XXXSMP scsipi */
+ KERNEL_LOCK(1, curlwp);
+
for (r = 0; r < sc->sc_ntarg; r++) {
struct ncr53c9x_tinfo *ti = &sc->sc_tinfo[r];
/* XXX - config flags per target: low bits: no reselect; high bits: no synch */
@@ -559,6 +562,9 @@ ncr53c9x_init(struct ncr53c9x_softc *sc,
/* Notify upper layer */
scsipi_async_event(&sc->sc_channel, ASYNC_EVENT_RESET, NULL);
+
+ /* XXXSMP scsipi */
+ KERNEL_UNLOCK_ONE(curlwp);
}
/*
Index: src/sys/dev/ic/ninjascsi32.c
diff -u src/sys/dev/ic/ninjascsi32.c:1.21 src/sys/dev/ic/ninjascsi32.c:1.21.14.1
--- src/sys/dev/ic/ninjascsi32.c:1.21 Sat Nov 13 13:52:01 2010
+++ src/sys/dev/ic/ninjascsi32.c Mon Mar 19 23:13:59 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: ninjascsi32.c,v 1.21 2010/11/13 13:52:01 uebayasi Exp $ */
+/* $NetBSD: ninjascsi32.c,v 1.21.14.1 2012/03/19 23:13:59 riz Exp $ */
/*-
* Copyright (c) 2004, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ninjascsi32.c,v 1.21 2010/11/13 13:52:01 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ninjascsi32.c,v 1.21.14.1 2012/03/19 23:13:59 riz Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1399,9 +1399,13 @@ njsc32_reset_bus(struct njsc32_softc *sc
/* initialize target structure */
njsc32_init_targets(sc);
+ /* XXXSMP scsipi */
+ KERNEL_LOCK(1, curlwp);
s = splbio();
scsipi_async_event(&sc->sc_channel, ASYNC_EVENT_RESET, NULL);
splx(s);
+ /* XXXSMP scsipi */
+ KERNEL_UNLOCK_ONE(curlwp);
/* release SCSI bus reset */
njsc32_write_1(sc, NJSC32_REG_SCSI_BUS_CONTROL, 0);
Index: src/sys/dev/scsipi/scsiconf.c
diff -u src/sys/dev/scsipi/scsiconf.c:1.262 src/sys/dev/scsipi/scsiconf.c:1.262.10.1
--- src/sys/dev/scsipi/scsiconf.c:1.262 Tue Apr 26 07:41:18 2011
+++ src/sys/dev/scsipi/scsiconf.c Mon Mar 19 23:13:59 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: scsiconf.c,v 1.262 2011/04/26 07:41:18 hannken Exp $ */
+/* $NetBSD: scsiconf.c,v 1.262.10.1 2012/03/19 23:13:59 riz 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.262 2011/04/26 07:41:18 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.262.10.1 2012/03/19 23:13:59 riz 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;
}
@@ -378,11 +389,17 @@ scsidevdetached(device_t self, device_t
target = device_locator(child, SCSIBUSCF_TARGET);
lun = device_locator(child, SCSIBUSCF_LUN);
+ /* XXXSMP scsipi */
+ KERNEL_LOCK(1, curlwp);
+
periph = scsipi_lookup_periph(chan, target, lun);
KASSERT(periph->periph_dev == child);
scsipi_remove_periph(chan, periph);
free(periph, M_DEVBUF);
+
+ /* XXXSMP scsipi */
+ KERNEL_UNLOCK_ONE(curlwp);
}
/*
Index: src/sys/dev/usb/uhub.c
diff -u src/sys/dev/usb/uhub.c:1.114 src/sys/dev/usb/uhub.c:1.114.10.1
--- src/sys/dev/usb/uhub.c:1.114 Thu Jun 9 19:08:32 2011
+++ src/sys/dev/usb/uhub.c Mon Mar 19 23:13:59 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: uhub.c,v 1.114 2011/06/09 19:08:32 matt Exp $ */
+/* $NetBSD: uhub.c,v 1.114.10.1 2012/03/19 23:13:59 riz 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.114 2011/06/09 19:08:32 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.114.10.1 2012/03/19 23:13:59 riz Exp $");
#include "opt_usb.h"
@@ -593,13 +593,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);
@@ -619,6 +626,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);
}