wlan: Let driver holds WLAN serializer for ieee80211_ifattach
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 10 Feb 2015 09:47:21 +0000 (17:47 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Tue, 10 Feb 2015 09:52:42 +0000 (17:52 +0800)
Looks like almost all building drivers (except, ndis(4) and wpi(4))
hold WLAN serializer for ieee80211_ifattach(), so we release the
WLAN serializer in ieee80211_ifattach() before the if_attach().

This reverts 4109d03b12096f353e4036119a0d6357fa1ec67e and
part of a583ece6b440118aa26f3eb162a1df7f2821f923.

Reported-by: marino@
sys/dev/netif/ath/ath/if_ath.c
sys/dev/netif/iwn/if_iwn.c
sys/dev/netif/ndis/if_ndis.c
sys/dev/netif/wpi/if_wpi.c
sys/netproto/802_11/wlan/ieee80211.c

index a664bf4..ad6b956 100644 (file)
@@ -1180,15 +1180,8 @@ ath_attach(u_int16_t devid, struct ath_softc *sc)
 
        /* NB: used to size node table key mapping array */
        ic->ic_max_keyix = sc->sc_keymax;
-       /*
-        * Call MI attach routine.
-        *
-        * WLAN serializer must _not_ be held for ieee80211_ifattach(),
-        * since it could dead-lock the domsg to netisrs.
-        */
-       wlan_serialize_exit();
+       /* Call MI attach routine. */
        ieee80211_ifattach(ic, macaddr);
-       wlan_serialize_enter();
        ic->ic_setregdomain = ath_setregdomain;
        ic->ic_getradiocaps = ath_getradiocaps;
        sc->sc_opmode = HAL_M_STA;
index 94318aa..ee909de 100644 (file)
@@ -670,13 +670,7 @@ iwn_attach(device_t dev)
        IFQ_SET_READY(&ifp->if_snd);
 #endif
 
-       wlan_serialize_exit();
-       /*
-        * WLAN serializer must _not_ be held for ieee80211_ifattach(),
-        * since it could dead-lock the domsg to netisrs.
-        */
        ieee80211_ifattach(ic, macaddr);
-       wlan_serialize_enter();
        ic->ic_vap_create = iwn_vap_create;
        ic->ic_vap_delete = iwn_vap_delete;
        ic->ic_raw_xmit = iwn_raw_xmit;
index d76c8fe..3493801 100644 (file)
@@ -926,7 +926,10 @@ got_crypto:
                if (r == 0)
                        ic->ic_caps |= IEEE80211_C_TXPMGT;
 
+               /* ieee80211_ifattach() assumes that WLAN serializer is held */
+               wlan_serialize_enter();
                ieee80211_ifattach(ic, eaddr);
+               wlan_serialize_exit();
                ic->ic_raw_xmit = ndis_raw_xmit;
                ic->ic_scan_start = ndis_scan_start;
                ic->ic_scan_end = ndis_scan_end;
index e3369da..97ea955 100644 (file)
@@ -687,7 +687,10 @@ wpi_attach(device_t dev)
        IFQ_SET_READY(&ifp->if_snd);
 #endif
 
+       /* ieee80211_ifattach() assumes that WLAN serializer is held */
+       wlan_serialize_enter();
        ieee80211_ifattach(ic, macaddr);
+       wlan_serialize_exit();
        /* override default methods */
        ic->ic_raw_xmit = wpi_raw_xmit;
        ic->ic_wme.wme_update = wpi_wme_update;
index 372cbe4..a533b3e 100644 (file)
@@ -300,12 +300,6 @@ ieee80211_ifattach(struct ieee80211com *ic,
        struct sockaddr_dl *sdl;
        struct ifaddr *ifa;
 
-       /*
-        * This function must _not_ be serialized by the WLAN serializer,
-        * since it could dead-lock the domsg to netisrs in if_attach().
-        */
-       wlan_assert_notserialized();
-
        KASSERT(ifp->if_type == IFT_IEEE80211, ("if_type %d", ifp->if_type));
 
        IEEE80211_LOCK_INIT(ic, ifp->if_xname);
@@ -357,11 +351,17 @@ ieee80211_ifattach(struct ieee80211com *ic,
 
        CURVNET_SET(vnet0);
 
+       /*
+        * This function must _not_ be serialized by the WLAN serializer,
+        * since it could dead-lock the domsg to netisrs in if_attach().
+        */
+       wlan_serialize_exit();
 #if defined(__DragonFly__)
        if_attach(ifp, &wlan_global_serializer);
 #else
        if_attach(ifp);
 #endif
+       wlan_serialize_enter();
 
        ifp->if_mtu = IEEE80211_MTU_MAX;
        ifp->if_broadcastaddr = ieee80211broadcastaddr;