Slightly chance the order of interrupt handling. First hook the
authorJoerg Sonnenberger <joerg@dragonflybsd.org>
Sun, 3 Jul 2005 16:47:20 +0000 (16:47 +0000)
committerJoerg Sonnenberger <joerg@dragonflybsd.org>
Sun, 3 Jul 2005 16:47:20 +0000 (16:47 +0000)
interrupt up last and keep the critical section in detach.
This is a prequirement for the elimination of wi_gone.

sys/dev/netif/wi/if_wi.c

index 5b6823a..afe9331 100644 (file)
@@ -32,7 +32,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/wi/if_wi.c,v 1.166 2004/04/01 00:38:45 sam Exp $
- * $DragonFly: src/sys/dev/netif/wi/if_wi.c,v 1.28 2005/06/30 17:11:28 joerg Exp $
+ * $DragonFly: src/sys/dev/netif/wi/if_wi.c,v 1.29 2005/07/03 16:47:20 joerg Exp $
  */
 
 /*
@@ -249,17 +249,6 @@ wi_attach(device_t dev)
        ifp->if_softc = sc;
        if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 
-       /*
-        * NB: no locking is needed here; don't put it here
-        *     unless you can prove it!
-        */
-       error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE,
-                              wi_intr, sc, &sc->wi_intrhand, NULL);
-       if (error) {
-               device_printf(dev, "bus_setup_intr() failed! (%d)\n", error);
-               goto fail;
-       }
-
        sc->wi_cmd_count = 500;
        /* Reset the NIC. */
        error = wi_reset(sc);
@@ -492,6 +481,14 @@ wi_attach(device_t dev)
        sc->sc_rx_th.wr_ihdr.it_present = htole32(WI_RX_RADIOTAP_PRESENT);
 
 
+       error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET | INTR_MPSAFE,
+                              wi_intr, sc, &sc->wi_intrhand, NULL);
+       if (error) {
+               ieee80211_ifdetach(ifp);
+               device_printf(dev, "bus_setup_intr() failed! (%d)\n", error);
+               goto fail;
+       }
+
        return(0);
 
 fail:
@@ -514,8 +511,8 @@ wi_detach(device_t dev)
        wi_stop(ifp, 0);
 
        ieee80211_ifdetach(ifp);
-       WI_UNLOCK(sc);
        wi_free(dev);
+       WI_UNLOCK(sc);
        return (0);
 }