Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Nov 2009 19:05:05 +0000 (UTC)
From:      Jaakko Heinonen <jh@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r198857 - head/sys/dev/fdc
Message-ID:  <200911031905.nA3J55Wo000741@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jh
Date: Tue Nov  3 19:05:05 2009
New Revision: 198857
URL: http://svn.freebsd.org/changeset/base/198857

Log:
  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)

Modified:
  head/sys/dev/fdc/fdc.c

Modified: head/sys/dev/fdc/fdc.c
==============================================================================
--- head/sys/dev/fdc/fdc.c	Tue Nov  3 18:40:42 2009	(r198856)
+++ head/sys/dev/fdc/fdc.c	Tue Nov  3 19:05:05 2009	(r198857)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911031905.nA3J55Wo000741>