Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/scsipi Wait in detach if the discovery thread is sti...
details: https://anonhg.NetBSD.org/src/rev/26f00c2eaab8
branches: trunk
changeset: 365003:26f00c2eaab8
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sat Sep 01 07:20:29 2018 +0000
description:
Wait in detach if the discovery thread is still running. Avoids crashes
when a device is attached/detached rapidly.
diffstat:
sys/dev/scsipi/scsiconf.c | 14 +++++++++++---
sys/dev/scsipi/scsipiconf.h | 3 ++-
2 files changed, 13 insertions(+), 4 deletions(-)
diffs (73 lines):
diff -r aefc3d71cd7f -r 26f00c2eaab8 sys/dev/scsipi/scsiconf.c
--- a/sys/dev/scsipi/scsiconf.c Sat Sep 01 07:19:19 2018 +0000
+++ b/sys/dev/scsipi/scsiconf.c Sat Sep 01 07:20:29 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: scsiconf.c,v 1.280 2017/06/17 22:35:50 mlelstv Exp $ */
+/* $NetBSD: scsiconf.c,v 1.281 2018/09/01 07:20:29 mlelstv 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.280 2017/06/17 22:35:50 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.281 2018/09/01 07:20:29 mlelstv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -270,7 +270,7 @@
* Create the discover thread
*/
if (kthread_create(PRI_NONE, 0, NULL, scsibus_discover_thread, sc,
- NULL, "%s-d", chan->chan_name)) {
+ &chan->chan_dthread, "%s-d", chan->chan_name)) {
aprint_error_dev(sc->sc_dev, "unable to create discovery "
"thread for channel %d\n", chan->chan_channel);
return;
@@ -283,6 +283,7 @@
struct scsibus_softc *sc = arg;
scsibus_config(sc);
+ sc->sc_channel->chan_dthread = NULL;
kthread_exit(0);
}
@@ -336,6 +337,12 @@
int error;
/*
+ * Defer while discovery thread is running
+ */
+ while (chan->chan_dthread != NULL)
+ kpause("scsibusdet", false, hz, NULL);
+
+ /*
* Detach all of the periphs.
*/
error = scsipi_target_detach(chan, -1, -1, flags);
@@ -415,6 +422,7 @@
*/
scsipi_set_xfer_mode(chan, target, 1);
}
+
scsipi_adapter_delref(chan->chan_adapter);
ret:
return (error);
diff -r aefc3d71cd7f -r 26f00c2eaab8 sys/dev/scsipi/scsipiconf.h
--- a/sys/dev/scsipi/scsipiconf.h Sat Sep 01 07:19:19 2018 +0000
+++ b/sys/dev/scsipi/scsipiconf.h Sat Sep 01 07:20:29 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: scsipiconf.h,v 1.127 2018/07/04 03:17:01 kamil Exp $ */
+/* $NetBSD: scsipiconf.h,v 1.128 2018/09/01 07:20:29 mlelstv Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2004 The NetBSD Foundation, Inc.
@@ -289,6 +289,7 @@
int chan_defquirks; /* default device's quirks */
+ struct lwp *chan_dthread; /* discovery thread */
struct lwp *chan_thread; /* completion thread */
int chan_tflags; /* flags for the completion thread */
Home |
Main Index |
Thread Index |
Old Index