From owner-p4-projects@FreeBSD.ORG Fri Jan 5 04:49:08 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1E3C916A412; Fri, 5 Jan 2007 04:49:08 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id ED92616A407 for ; Fri, 5 Jan 2007 04:49:07 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id D4D0B13C43E for ; Fri, 5 Jan 2007 04:49:07 +0000 (UTC) (envelope-from kmacy@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id l054n7wh032323 for ; Fri, 5 Jan 2007 04:49:07 GMT (envelope-from kmacy@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id l054n760032320 for perforce@freebsd.org; Fri, 5 Jan 2007 04:49:07 GMT (envelope-from kmacy@freebsd.org) Date: Fri, 5 Jan 2007 04:49:07 GMT Message-Id: <200701050449.l054n760032320@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to kmacy@freebsd.org using -f From: Kip Macy To: Perforce Change Reviews Cc: Subject: PERFORCE change 112526 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: Fri, 05 Jan 2007 04:49:08 -0000 http://perforce.freebsd.org/chv.cgi?CH=112526 Change 112526 by kmacy@kmacy_serendipity:sam_wifi on 2007/01/05 04:48:57 - move locking soft lock acquisition into rt2560_stop - fixing hangs when the card was removed - only call newstate to transition to INIT if the driver is currently running - fixing a panic in ieee80211_cancel_scan with mtx_lock of destroyed mutex Affected files ... .. //depot/projects/wifi/sys/dev/ral/rt2560.c#10 edit Differences ... ==== //depot/projects/wifi/sys/dev/ral/rt2560.c#10 (text) ==== @@ -350,9 +350,7 @@ struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = ic->ic_ifp; - RAL_LOCK(sc); rt2560_stop(sc); - RAL_UNLOCK(sc); callout_stop(&sc->watchdog_ch); callout_stop(&sc->rssadapt_ch); @@ -2080,17 +2078,18 @@ switch (cmd) { case SIOCSIFFLAGS: - RAL_LOCK(sc); if (ifp->if_flags & IFF_UP) { + RAL_LOCK(sc); if (ifp->if_drv_flags & IFF_DRV_RUNNING) rt2560_update_promisc(sc); else rt2560_init(sc); + RAL_UNLOCK(sc); } else { if (ifp->if_drv_flags & IFF_DRV_RUNNING) rt2560_stop(sc); } - RAL_UNLOCK(sc); + break; default: @@ -2652,10 +2651,11 @@ uint32_t tmp; int i; - RAL_LOCK(sc); + rt2560_stop(sc); + RAL_LOCK(sc); /* setup tx rings */ tmp = RT2560_PRIO_RING_COUNT << 24 | RT2560_ATIM_RING_COUNT << 16 | @@ -2738,41 +2738,44 @@ } void -rt2560_stop(void *priv) +rt2560_stop(void *arg) { - struct rt2560_softc *sc = priv; + struct rt2560_softc *sc = arg; struct ieee80211com *ic = &sc->sc_ic; struct ifnet *ifp = ic->ic_ifp; volatile int *flags = &sc->sc_flags; while (*flags & RAL_INPUT_RUNNING) { - msleep(sc, &sc->sc_mtx, 0, "ralrunning", hz/10); + tsleep(sc, 0, "ralrunning", hz/10); } - - sc->sc_tx_timer = 0; - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); - ieee80211_new_state(ic, IEEE80211_S_INIT, -1); + RAL_LOCK(sc); + if (ifp->if_drv_flags & IFF_DRV_RUNNING) { + ieee80211_new_state(ic, IEEE80211_S_INIT, -1); + sc->sc_tx_timer = 0; + ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); - /* abort Tx */ - RAL_WRITE(sc, RT2560_TXCSR0, RT2560_ABORT_TX); + /* abort Tx */ + RAL_WRITE(sc, RT2560_TXCSR0, RT2560_ABORT_TX); + + /* disable Rx */ + RAL_WRITE(sc, RT2560_RXCSR0, RT2560_DISABLE_RX); - /* disable Rx */ - RAL_WRITE(sc, RT2560_RXCSR0, RT2560_DISABLE_RX); + /* reset ASIC (imply reset BBP) */ + RAL_WRITE(sc, RT2560_CSR1, RT2560_RESET_ASIC); + RAL_WRITE(sc, RT2560_CSR1, 0); - /* reset ASIC (imply reset BBP) */ - RAL_WRITE(sc, RT2560_CSR1, RT2560_RESET_ASIC); - RAL_WRITE(sc, RT2560_CSR1, 0); - - /* disable interrupts */ - RAL_WRITE(sc, RT2560_CSR8, 0xffffffff); - - /* reset Tx and Rx rings */ - rt2560_reset_tx_ring(sc, &sc->txq); - rt2560_reset_tx_ring(sc, &sc->atimq); - rt2560_reset_tx_ring(sc, &sc->prioq); - rt2560_reset_tx_ring(sc, &sc->bcnq); - rt2560_reset_rx_ring(sc, &sc->rxq); + /* disable interrupts */ + RAL_WRITE(sc, RT2560_CSR8, 0xffffffff); + + /* reset Tx and Rx rings */ + rt2560_reset_tx_ring(sc, &sc->txq); + rt2560_reset_tx_ring(sc, &sc->atimq); + rt2560_reset_tx_ring(sc, &sc->prioq); + rt2560_reset_tx_ring(sc, &sc->bcnq); + rt2560_reset_rx_ring(sc, &sc->rxq); + } + RAL_UNLOCK(sc); } static int @@ -2828,3 +2831,4 @@ RAL_UNLOCK(sc); return EIO; /* XXX */ } +