From owner-p4-projects@FreeBSD.ORG Thu Apr 3 17:09:15 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 759881065672; Thu, 3 Apr 2008 17:09:15 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 381901065670 for ; Thu, 3 Apr 2008 17:09:15 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 22CB78FC19 for ; Thu, 3 Apr 2008 17:09:15 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m33H9F0r096847 for ; Thu, 3 Apr 2008 17:09:15 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m33H9EEj096845 for perforce@freebsd.org; Thu, 3 Apr 2008 17:09:14 GMT (envelope-from sam@freebsd.org) Date: Thu, 3 Apr 2008 17:09:14 GMT Message-Id: <200804031709.m33H9EEj096845@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Cc: Subject: PERFORCE change 139275 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Apr 2008 17:09:15 -0000 http://perforce.freebsd.org/chv.cgi?CH=139275 Change 139275 by sam@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); }