summaryrefslogtreecommitdiffstats
path: root/sys/dev/fdc
diff options
context:
space:
mode:
authorjh <jh@FreeBSD.org>2009-11-03 19:05:05 +0000
committerjh <jh@FreeBSD.org>2009-11-03 19:05:05 +0000
commit0731af5157c9d3fda2dbfe886eb68a9c8e53d73a (patch)
treef58bfce80caf80e224d7c9b3002a90fa00b18920 /sys/dev/fdc
parentb4a2916c56a47abd27492863f5ec8b94caaa6530 (diff)
downloadFreeBSD-src-0731af5157c9d3fda2dbfe886eb68a9c8e53d73a.zip
FreeBSD-src-0731af5157c9d3fda2dbfe886eb68a9c8e53d73a.tar.gz
fdc(4) module unload fixes:
- Tear down the interrupt handler before killing the worker thread. - Do geom withering as GEOM event to avoid acquiring the GEOM topology lock under Giant. PR: kern/104079 Reviewed by: joerg Approved by: trasz (mentor)
Diffstat (limited to 'sys/dev/fdc')
-rw-r--r--sys/dev/fdc/fdc.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c
index 3ff31fd..458c839 100644
--- a/sys/dev/fdc/fdc.c
+++ b/sys/dev/fdc/fdc.c
@@ -1734,6 +1734,10 @@ fdc_detach(device_t dev)
if ((error = bus_generic_detach(dev)))
return (error);
+ if (fdc->fdc_intr)
+ bus_teardown_intr(dev, fdc->res_irq, fdc->fdc_intr);
+ fdc->fdc_intr = NULL;
+
/* kill worker thread */
mtx_lock(&fdc->fdc_mtx);
fdc->flags |= FDC_KTHREAD_EXIT;
@@ -2031,15 +2035,22 @@ fd_attach(device_t dev)
return (0);
}
+static void
+fd_detach_geom(void *arg, int flag)
+{
+ struct fd_data *fd = arg;
+
+ g_topology_assert();
+ g_wither_geom(fd->fd_geom, ENXIO);
+}
+
static int
fd_detach(device_t dev)
{
struct fd_data *fd;
fd = device_get_softc(dev);
- g_topology_lock();
- g_wither_geom(fd->fd_geom, ENXIO);
- g_topology_unlock();
+ g_waitfor_event(fd_detach_geom, fd, M_WAITOK, NULL);
while (device_get_state(dev) == DS_BUSY)
tsleep(fd, PZERO, "fdd", hz/10);
callout_drain(&fd->toffhandle);
OpenPOWER on IntegriCloud