The wakeup() line from the rev. 1.319 is wrong and reintroduces

a panic race on module unload. The wakeup() is internal to
kproc_exit/kthread_exit. The correct fix is to fix the msleep() in
detach to sleep on fdc->fdc_thread instead of &fdc->fdc_thread.

Noted and reviewed by:	jhb
Pointy hat to:	kib
MFC after:	1 week
This commit is contained in:
kib 2008-01-11 16:50:52 +00:00
parent 8032f44d5f
commit 508466854a

View File

@ -1205,7 +1205,6 @@ fdc_thread(void *arg)
mtx_lock(&fdc->fdc_mtx);
}
fdc->flags &= ~(FDC_KTHREAD_EXIT | FDC_KTHREAD_ALIVE);
wakeup(&fdc->fdc_thread);
mtx_unlock(&fdc->fdc_mtx);
kproc_exit(0);
@ -1721,7 +1720,7 @@ fdc_detach(device_t dev)
fdc->flags |= FDC_KTHREAD_EXIT;
wakeup(&fdc->head);
while ((fdc->flags & FDC_KTHREAD_ALIVE) != 0)
msleep(&fdc->fdc_thread, &fdc->fdc_mtx, PRIBIO, "fdcdet", 0);
msleep(fdc->fdc_thread, &fdc->fdc_mtx, PRIBIO, "fdcdet", 0);
mtx_unlock(&fdc->fdc_mtx);
/* reset controller, turn motor off */