Author: adrian
Date: Sun Mar 15 21:08:24 2015
New Revision: 280097
URL: https://svnweb.freebsd.org/changeset/base/280097

Log:
  Acquire ifq lock when checking / modifying IFF_DRV_OACTIVE flag.
  
  PR:           kern/197143
  Submitted by: Andriy Voskoboinyk <s3er...@gmail.com>

Modified:
  head/sys/dev/wpi/if_wpi.c

Modified: head/sys/dev/wpi/if_wpi.c
==============================================================================
--- head/sys/dev/wpi/if_wpi.c   Sun Mar 15 21:07:43 2015        (r280096)
+++ head/sys/dev/wpi/if_wpi.c   Sun Mar 15 21:08:24 2015        (r280097)
@@ -1967,11 +1967,14 @@ wpi_tx_done(struct wpi_softc *sc, struct
        sc->sc_tx_timer = 0;
        if (--ring->queued < WPI_TX_RING_LOMARK) {
                sc->qfullmsk &= ~(1 << ring->qid);
+               IF_LOCK(&ifp->if_snd);
                if (sc->qfullmsk == 0 &&
                    (ifp->if_drv_flags & IFF_DRV_OACTIVE)) {
                        ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+                       IF_UNLOCK(&ifp->if_snd);
                        ieee80211_runtask(ic, &sc->sc_start_task);
-               }
+               } else
+                       IF_UNLOCK(&ifp->if_snd);
        }
 
        DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END, __func__);
@@ -2871,13 +2874,19 @@ wpi_start_locked(struct ifnet *ifp)
 
        DPRINTF(sc, WPI_DEBUG_XMIT, "%s: called\n", __func__);
 
+       IF_LOCK(&ifp->if_snd);
        if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 ||
-           (ifp->if_drv_flags & IFF_DRV_OACTIVE))
+           (ifp->if_drv_flags & IFF_DRV_OACTIVE)) {
+               IF_UNLOCK(&ifp->if_snd);
                return;
+       }
+       IF_UNLOCK(&ifp->if_snd);
 
        for (;;) {
                if (sc->qfullmsk != 0) {
+                       IF_LOCK(&ifp->if_snd);
                        ifp->if_drv_flags |= IFF_DRV_OACTIVE;
+                       IF_UNLOCK(&ifp->if_snd);
                        break;
                }
                IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
@@ -5222,8 +5231,10 @@ wpi_init(void *arg)
                goto fail;
        }
 
+       IF_LOCK(&ifp->if_snd);
        ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
        ifp->if_drv_flags |= IFF_DRV_RUNNING;
+       IF_UNLOCK(&ifp->if_snd);
 
        callout_reset(&sc->watchdog_to, hz, wpi_watchdog, sc);
 
@@ -5255,7 +5266,10 @@ wpi_stop_locked(struct wpi_softc *sc)
        sc->sc_tx_timer = 0;
        callout_stop(&sc->watchdog_to);
        callout_stop(&sc->calib_to);
+
+       IF_LOCK(&ifp->if_snd);
        ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
+       IF_UNLOCK(&ifp->if_snd);
 
        /* Power OFF hardware. */
        wpi_hw_stop(sc);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to