Date: Sat, 9 Jun 2007 02:57:23 GMT From: Andrew Thompson <thompsa@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 121244 for review Message-ID: <200706090257.l592vNRA032365@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=121244 Change 121244 by thompsa@thompsa_heff on 2007/06/09 02:56:50 Use a proper mtx_assert instead of a debug printf and improve the locking. Affected files ... .. //depot/projects/wifi/sys/dev/iwi/if_iwi.c#42 edit .. //depot/projects/wifi/sys/dev/iwi/if_iwivar.h#17 edit Differences ... ==== //depot/projects/wifi/sys/dev/iwi/if_iwi.c#42 (text+ko) ==== @@ -452,9 +452,12 @@ struct iwi_softc *sc = device_get_softc(dev); struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = ic->ic_ifp; + IWI_LOCK_DECL; if (ifp != NULL) { + IWI_LOCK(sc); iwi_stop(sc); + IWI_UNLOCK(sc); bpfdetach(ifp); ieee80211_ifdetach(ic); } @@ -794,8 +797,11 @@ iwi_shutdown(device_t dev) { struct iwi_softc *sc = device_get_softc(dev); + IWI_LOCK_DECL; + IWI_LOCK(sc); iwi_stop(sc); + IWI_UNLOCK(sc); iwi_put_firmware(sc); /* ??? XXX */ return 0; @@ -805,8 +811,11 @@ iwi_suspend(device_t dev) { struct iwi_softc *sc = device_get_softc(dev); + IWI_LOCK_DECL; + IWI_LOCK(sc); iwi_stop(sc); + IWI_UNLOCK(sc); return 0; } @@ -938,7 +947,7 @@ struct iwi_softc *sc = ifp->if_softc; int error = 0; - IWI_LOCK_CHECK(sc); + IWI_LOCK_ASSERT(sc); DPRINTF(("%s: %s -> %s flags 0x%x\n", __func__, ieee80211_state_name[ic->ic_state], ieee80211_state_name[nstate], sc->flags)); @@ -1661,7 +1670,7 @@ { struct iwi_cmd_desc *desc; - IWI_LOCK_CHECK(sc); + IWI_LOCK_ASSERT(sc); if (sc->flags & IWI_FLAG_BUSY) { device_printf(sc->sc_dev, "%s: cmd %d not sent, busy\n", @@ -1725,7 +1734,7 @@ int error, nsegs, hdrlen, i; int ismcast, flags, xflags, staid; - IWI_LOCK_CHECK(sc); + IWI_LOCK_ASSERT(sc); wh = mtod(m0, const struct ieee80211_frame *); /* NB: only data frames use this path */ hdrlen = ieee80211_hdrsize(wh); @@ -1967,7 +1976,7 @@ struct iwi_softc *sc = arg; struct ifnet *ifp = sc->sc_ifp; - IWI_LOCK_CHECK(sc); + IWI_LOCK_ASSERT(sc); if (sc->sc_tx_timer > 0) { if (--sc->sc_tx_timer == 0) { @@ -2062,8 +2071,6 @@ uint32_t tmp; int ntries; - IWI_LOCK_CHECK(sc); - /* disable interrupts */ CSR_WRITE_4(sc, IWI_CSR_INTR_MASK, 0); @@ -2330,7 +2337,7 @@ size_t size = fw->size; int i, ntries, error; - IWI_LOCK_CHECK(sc); + IWI_LOCK_ASSERT(sc); error = 0; CSR_WRITE_4(sc, IWI_CSR_RST, CSR_READ_4(sc, IWI_CSR_RST) | IWI_RST_STOP_MASTER); @@ -2403,7 +2410,7 @@ uint32_t sentinel, ctl, src, dst, sum, len, mlen, tmp; int ntries, error; - IWI_LOCK_CHECK(sc); + IWI_LOCK_ASSERT(sc); /* copy firmware image to DMA memory */ memcpy(sc->fw_virtaddr, fw->data, fw->size); @@ -2545,7 +2552,7 @@ struct iwi_txpower power; uint32_t data; int error, i; - IWI_LOCK_CHECK(sc); + IWI_LOCK_ASSERT(sc); IEEE80211_ADDR_COPY(ic->ic_myaddr, IF_LLADDR(ifp)); DPRINTF(("Setting MAC address to %6D\n", ic->ic_myaddr, ":")); @@ -2694,7 +2701,7 @@ struct iwi_scan_ext scan; int error = 0; - IWI_LOCK_CHECK(sc); + IWI_LOCK_ASSERT(sc); if (sc->flags & IWI_FLAG_SCANNING) { /* * This should not happen as we only trigger scan_next after @@ -2828,10 +2835,9 @@ int error; IWI_LOCK_DECL; - IWI_LOCK_CHECK(sc); + IWI_LOCK_ASSERT(sc); error = 0; - IWI_LOCK(sc); if (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan)) { memset(&config, 0, sizeof config); config.bluetooth_coexistence = sc->bluetooth; @@ -3079,7 +3085,7 @@ int i; IWI_LOCK_DECL; - IWI_LOCK_CHECK(sc); + IWI_LOCK_ASSERT(sc); if (sc->flags & IWI_FLAG_FW_LOADING) { device_printf(sc->sc_dev, "%s: already loading\n", __func__); return; /* XXX: condvar? */ @@ -3198,7 +3204,7 @@ struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = ic->ic_ifp; - IWI_LOCK_CHECK(sc); /* XXX: pretty sure this triggers */ + IWI_LOCK_ASSERT(sc); if (sc->sc_softled) { callout_stop(&sc->sc_ledtimer); sc->sc_blinking = 0; @@ -3261,10 +3267,13 @@ iwi_radio_off(void *arg, int pending) { struct iwi_softc *sc = arg; + IWI_LOCK_DECL; device_printf(sc->sc_dev, "radio turned off\n"); + IWI_LOCK(sc); iwi_stop(sc); sc->sc_rfkill_timer = 2; + IWI_UNLOCK(sc); } static int ==== //depot/projects/wifi/sys/dev/iwi/if_iwivar.h#17 (text+ko) ==== @@ -246,10 +246,7 @@ MTX_NETWORK_LOCK, MTX_DEF) #define IWI_LOCK_DESTROY(sc) mtx_destroy(&(sc)->sc_mtx) #define IWI_LOCK_DECL int __waslocked = 0 -#define IWI_LOCK_CHECK(sc) do { \ - if (!mtx_owned(&(sc)->sc_mtx)) \ - DPRINTF(("%s iwi_lock not held\n", __func__)); \ -} while (0) +#define IWI_LOCK_ASSERT(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED) #define IWI_LOCK(sc) do { \ if (!(__waslocked = mtx_owned(&(sc)->sc_mtx))) \ mtx_lock(&(sc)->sc_mtx); \
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706090257.l592vNRA032365>