PERFORCE change 139275 for review

Sam Leffler sam at FreeBSD.org
Thu Apr 3 17:09:15 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=139275

Change 139275 by sam at sam_ebb on 2008/04/03 17:08:20

	eliminate recursive locking through if_start

Affected files ...

.. //depot/projects/vap/sys/dev/ral/rt2560.c#22 edit
.. //depot/projects/vap/sys/dev/ral/rt2560var.h#14 edit
.. //depot/projects/vap/sys/dev/ral/rt2661.c#19 edit

Differences ...

==== //depot/projects/vap/sys/dev/ral/rt2560.c#22 (text) ====

@@ -130,6 +130,7 @@
 			    struct ieee80211_node *);
 static int		rt2560_tx_data(struct rt2560_softc *, struct mbuf *,
 			    struct ieee80211_node *);
+static void		rt2560_start_locked(struct ifnet *);
 static void		rt2560_start(struct ifnet *);
 static void		rt2560_watchdog(void *);
 static int		rt2560_ioctl(struct ifnet *, u_long, caddr_t);
@@ -1045,7 +1046,7 @@
 		if ((sc->sc_flags &
 		     (RT2560_F_DATA_OACTIVE | RT2560_F_PRIO_OACTIVE)) == 0)
 			ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
-		rt2560_start(ifp);
+		rt2560_start_locked(ifp);
 	}
 }
 
@@ -1130,7 +1131,7 @@
 		if ((sc->sc_flags &
 		     (RT2560_F_DATA_OACTIVE | RT2560_F_PRIO_OACTIVE)) == 0)
 			ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
-		rt2560_start(ifp);
+		rt2560_start_locked(ifp);
 	}
 }
 
@@ -1923,13 +1924,13 @@
 }
 
 static void
-rt2560_start(struct ifnet *ifp)
+rt2560_start_locked(struct ifnet *ifp)
 {
 	struct rt2560_softc *sc = ifp->if_softc;
 	struct mbuf *m;
 	struct ieee80211_node *ni;
 
-	RAL_LOCK(sc);
+	RAL_LOCK_ASSERT(sc);
 
 	for (;;) {
 		IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
@@ -1958,7 +1959,15 @@
 
 		sc->sc_tx_timer = 5;
 	}
+}
+
+static void
+rt2560_start(struct ifnet *ifp)
+{
+	struct rt2560_softc *sc = ifp->if_softc;
 
+	RAL_LOCK(sc);
+	rt2560_start_locked(ifp);
 	RAL_UNLOCK(sc);
 }
 

==== //depot/projects/vap/sys/dev/ral/rt2560var.h#14 (text) ====

@@ -171,5 +171,6 @@
 void	rt2560_resume(void *);
 void	rt2560_intr(void *);
 
-#define RAL_LOCK(sc)	mtx_lock(&(sc)->sc_mtx)
-#define RAL_UNLOCK(sc)	mtx_unlock(&(sc)->sc_mtx)
+#define RAL_LOCK(sc)		mtx_lock(&(sc)->sc_mtx)
+#define RAL_LOCK_ASSERT(sc)	mtx_assert(&(sc)->sc_mtx, MA_OWNED)
+#define RAL_UNLOCK(sc)		mtx_unlock(&(sc)->sc_mtx)

==== //depot/projects/vap/sys/dev/ral/rt2661.c#19 (text) ====

@@ -124,6 +124,7 @@
 			    struct ieee80211_node *, int);
 static int		rt2661_tx_mgt(struct rt2661_softc *, struct mbuf *,
 			    struct ieee80211_node *);
+static void		rt2661_start_locked(struct ifnet *);
 static void		rt2661_start(struct ifnet *);
 static int		rt2661_raw_xmit(struct ieee80211_node *, struct mbuf *,
 			    const struct ieee80211_bpf_params *);
@@ -977,7 +978,8 @@
 
 	sc->sc_tx_timer = 0;
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
-	rt2661_start(ifp);
+
+	rt2661_start_locked(ifp);
 }
 
 static void
@@ -1614,20 +1616,18 @@
 }
 
 static void
-rt2661_start(struct ifnet *ifp)
+rt2661_start_locked(struct ifnet *ifp)
 {
 	struct rt2661_softc *sc = ifp->if_softc;
 	struct mbuf *m;
 	struct ieee80211_node *ni;
 	int ac;
 
-	RAL_LOCK(sc);
+	RAL_LOCK_ASSERT(sc);
 
 	/* prevent management frames from being sent if we're not ready */
-	if (!(ifp->if_drv_flags & IFF_DRV_RUNNING) || sc->sc_invalid) {
-		RAL_UNLOCK(sc);
+	if (!(ifp->if_drv_flags & IFF_DRV_RUNNING) || sc->sc_invalid)
 		return;
-	}
 
 	for (;;) {
 		IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
@@ -1659,7 +1659,15 @@
 		sc->sc_tx_timer = 5;
 		callout_reset(&sc->watchdog_ch, hz, rt2661_watchdog, sc);
 	}
+}
+
+static void
+rt2661_start(struct ifnet *ifp)
+{
+	struct rt2661_softc *sc = ifp->if_softc;
 
+	RAL_LOCK(sc);
+	rt2661_start_locked(ifp);
 	RAL_UNLOCK(sc);
 }
 


More information about the p4-projects mailing list