summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2007-05-16 19:53:49 +0000
committerimp <imp@FreeBSD.org>2007-05-16 19:53:49 +0000
commit8a64d31f40c6db30413402f2a9ae43144e7f9501 (patch)
tree82dd25c0e65fd0ff336b15d3943b2abb269847e0 /sys
parent02c57cc5852f76ff37122ff16789ef541790e5ba (diff)
downloadFreeBSD-src-8a64d31f40c6db30413402f2a9ae43144e7f9501.zip
FreeBSD-src-8a64d31f40c6db30413402f2a9ae43144e7f9501.tar.gz
o Don't hold lock over bus_teardown_intr when we're waiting for the
thread to die, since that can cause deadlock with the ISR (in theory). o Minor cleanup o comment nit
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pccbb/pccbb.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/sys/dev/pccbb/pccbb.c b/sys/dev/pccbb/pccbb.c
index 2e14811..339bf13 100644
--- a/sys/dev/pccbb/pccbb.c
+++ b/sys/dev/pccbb/pccbb.c
@@ -332,13 +332,13 @@ cbb_detach(device_t brdev)
/*
* Wait for the thread to die. kthread_exit will do a wakeup
* on the event thread's struct thread * so that we know it is
- * save to proceed. IF the thread is running, set the please
+ * safe to proceed. IF the thread is running, set the please
* die flag and wait for it to comply. Since the wakeup on
* the event thread happens only in kthread_exit, we don't
* need to loop here.
*/
- mtx_lock(&sc->mtx);
bus_teardown_intr(brdev, sc->irq_res, sc->intrhand);
+ mtx_lock(&sc->mtx);
sc->flags |= CBB_KTHREAD_DONE;
while (sc->flags & CBB_KTHREAD_RUNNING) {
DEVPRINTF((sc->dev, "Waiting for thread to die\n"));
@@ -469,8 +469,8 @@ cbb_event_thread(void *arg)
mtx_lock(&sc->mtx);
sc->flags |= CBB_KTHREAD_RUNNING;
- mtx_unlock(&sc->mtx);
while ((sc->flags & CBB_KTHREAD_DONE) == 0) {
+ mtx_unlock(&sc->mtx);
/*
* We take out Giant here because we need it deep,
* down in the bowels of the vm system for mapping the
@@ -527,10 +527,8 @@ cbb_event_thread(void *arg)
while (err != EWOULDBLOCK &&
(sc->flags & CBB_KTHREAD_DONE) == 0)
err = cv_timedwait(&sc->cv, &sc->mtx, hz / 4);
- mtx_unlock(&sc->mtx);
}
DEVPRINTF((sc->dev, "Thread terminating\n"));
- mtx_lock(&sc->mtx);
sc->flags &= ~CBB_KTHREAD_RUNNING;
mtx_unlock(&sc->mtx);
kthread_exit(0);
OpenPOWER on IntegriCloud