From owner-p4-projects@FreeBSD.ORG Thu Apr 3 20:18:37 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id EE5D11065670; Thu, 3 Apr 2008 20:18:36 +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 9CA0D106566B for ; Thu, 3 Apr 2008 20:18:36 +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 879C38FC17 for ; Thu, 3 Apr 2008 20:18:36 +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 m33KIasE008288 for ; Thu, 3 Apr 2008 20:18:36 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m33KIaVS008286 for perforce@freebsd.org; Thu, 3 Apr 2008 20:18:36 GMT (envelope-from sam@freebsd.org) Date: Thu, 3 Apr 2008 20:18:36 GMT Message-Id: <200804032018.m33KIaVS008286@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 139287 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 20:18:37 -0000 http://perforce.freebsd.org/chv.cgi?CH=139287 Change 139287 by sam@sam_ebb on 2008/04/03 20:18:32 Use new taskqueue_block/unblock to fix/improve on longstanding issues: o block rx processing during key changes (still a small race but probably acceptable) o bock task q processing on move to INIT state; still have a small race but before we couldn't use taskqueue_drain because we are called with mtx(s) held and that just barfs entirely This still doesn't fix module unload while active on smp machines which may be a different issue (hard to see since the laptop doesn't have a serial port and it just locks up hard). Affected files ... .. //depot/projects/vap/sys/dev/ath/if_ath.c#58 edit Differences ... ==== //depot/projects/vap/sys/dev/ath/if_ath.c#58 (text+ko) ==== @@ -2451,9 +2451,7 @@ struct ath_softc *sc = ifp->if_softc; DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s:\n", __func__); -#if 0 - tasklet_disable(&sc->sc_rxtq); -#endif + taskqueue_block(sc->sc_tq); IF_LOCK(&ifp->if_snd); /* NB: doesn't block mgmt frames */ } @@ -2465,9 +2463,7 @@ DPRINTF(sc, ATH_DEBUG_KEYCACHE, "%s:\n", __func__); IF_UNLOCK(&ifp->if_snd); -#if 0 - tasklet_enable(&sc->sc_rxtq); -#endif + taskqueue_unblock(sc->sc_tq); } /* @@ -5524,10 +5520,12 @@ * Walk the vap list and check if there any vap's in RUN state. */ static int -ath_isanyrunningvaps(const struct ieee80211vap *this) +ath_isanyrunningvaps(struct ieee80211vap *this) { - const struct ieee80211com *ic = this->iv_ic; - const struct ieee80211vap *vap; + struct ieee80211com *ic = this->iv_ic; + struct ieee80211vap *vap; + + IEEE80211_LOCK_ASSERT(ic); TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { if (vap != this && vap->iv_state == IEEE80211_S_RUN) @@ -5568,12 +5566,14 @@ /* * Scanning: turn off beacon miss and don't beacon. * Mark beacon state so when we reach RUN state we'll - * [re]setup beacons. + * [re]setup beacons. Unblock the task q thread so + * deferred interrupt processing is done. */ ath_hal_intrset(ah, sc->sc_imask &~ (HAL_INT_SWBA | HAL_INT_BMISS)); sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS); sc->sc_beacons = 0; + taskqueue_unblock(sc->sc_tq); } ni = vap->iv_bss; @@ -5689,33 +5689,29 @@ sc->sc_halstats.ns_avgrssi = ATH_RSSI_DUMMY_MARKER; sc->sc_halstats.ns_avgtxrssi = ATH_RSSI_DUMMY_MARKER; /* - * Finally, start any timers. + * Finally, start any timers and the task q thread + * (in case we didn't go through SCAN state). */ if (sc->sc_calinterval != 0) { /* start periodic recalibration timer */ callout_reset(&sc->sc_cal_ch, sc->sc_calinterval * hz, ath_calibrate, sc); } + taskqueue_unblock(sc->sc_tq); } else if (nstate == IEEE80211_S_INIT) { /* * If there are no vaps left in RUN state then * shutdown host/driver operation: - * o disable interrupts so we don't rx frames - * o clean any pending items on the task q - * o notify the rate control algorithm + * o disable interrupts + * o disable the task queue thread + * o mark beacon processing as stopped */ if (!ath_isanyrunningvaps(vap)) { sc->sc_imask &= ~(HAL_INT_SWBA | HAL_INT_BMISS); /* disable interrupts */ ath_hal_intrset(ah, sc->sc_imask &~ HAL_INT_GLOBAL); + taskqueue_block(sc->sc_tq); sc->sc_beacons = 0; -#if 0 - /* XXX can't use taskqueue_drain 'cuz we're holding sc_mtx */ - taskqueue_drain(sc->sc_tq, &sc->sc_rxtask); - taskqueue_drain(sc->sc_tq, &sc->sc_rxorntask); - taskqueue_drain(sc->sc_tq, &sc->sc_bmisstask); - taskqueue_drain(sc->sc_tq, &sc->sc_bstucktask); -#endif } } bad: