From owner-svn-src-all@freebsd.org Tue Jan 26 16:51:01 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 16394A6EB97; Tue, 26 Jan 2016 16:51:01 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CD99D39E; Tue, 26 Jan 2016 16:51:00 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u0QGoxjf086768; Tue, 26 Jan 2016 16:50:59 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u0QGoxjx086767; Tue, 26 Jan 2016 16:50:59 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201601261650.u0QGoxjx086767@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Tue, 26 Jan 2016 16:50:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r294842 - head/sys/dev/rtwn X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2016 16:51:01 -0000 Author: avos Date: Tue Jan 26 16:50:59 2016 New Revision: 294842 URL: https://svnweb.freebsd.org/changeset/base/294842 Log: rtwn: do not start vap when initialization fails - Start vap(s) (via ieee80211_start_all()) only when initialization succeeds; stop the first vap otherwise (via ieee80211_stop()); - Do not try to stop a device multiple times (move (sc->sc_flags & RTWN_RUNNING) check to urtwn_stop_locked()). Tested by: kevlo Reviewed by: kevlo Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D5058 Modified: head/sys/dev/rtwn/if_rtwn.c Modified: head/sys/dev/rtwn/if_rtwn.c ============================================================================== --- head/sys/dev/rtwn/if_rtwn.c Tue Jan 26 16:34:27 2016 (r294841) +++ head/sys/dev/rtwn/if_rtwn.c Tue Jan 26 16:50:59 2016 (r294842) @@ -185,7 +185,7 @@ static void rtwn_iq_calib_write_results( static void rtwn_iq_calib(struct rtwn_softc *); static void rtwn_lc_calib(struct rtwn_softc *); static void rtwn_temp_calib(struct rtwn_softc *); -static void rtwn_init_locked(struct rtwn_softc *); +static int rtwn_init(struct rtwn_softc *); static void rtwn_stop_locked(struct rtwn_softc *); static void rtwn_stop(struct rtwn_softc *); static void rtwn_intr(void *); @@ -1845,19 +1845,15 @@ static void rtwn_parent(struct ieee80211com *ic) { struct rtwn_softc *sc = ic->ic_softc; - int startall = 0; + struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); - RTWN_LOCK(sc); - if (ic->ic_nrunning> 0) { - if (!(sc->sc_flags & RTWN_RUNNING)) { - rtwn_init_locked(sc); - startall = 1; - } - } else if (sc->sc_flags & RTWN_RUNNING) - rtwn_stop_locked(sc); - RTWN_UNLOCK(sc); - if (startall) - ieee80211_start_all(ic); + if (ic->ic_nrunning > 0) { + if (rtwn_init(sc) == 0) + ieee80211_start_all(ic); + else + ieee80211_stop(vap); + } else + rtwn_stop(sc); } static void @@ -3218,8 +3214,8 @@ rtwn_temp_calib(struct rtwn_softc *sc) } } -static void -rtwn_init_locked(struct rtwn_softc *sc) +static int +rtwn_init(struct rtwn_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); @@ -3227,7 +3223,13 @@ rtwn_init_locked(struct rtwn_softc *sc) uint8_t macaddr[IEEE80211_ADDR_LEN]; int i, error; - RTWN_LOCK_ASSERT(sc); + RTWN_LOCK(sc); + + if (sc->sc_flags & RTWN_RUNNING) { + RTWN_UNLOCK(sc); + return 0; + } + sc->sc_flags |= RTWN_RUNNING; /* Init firmware commands ring. */ sc->fwcur = 0; @@ -3347,13 +3349,15 @@ rtwn_init_locked(struct rtwn_softc *sc) /* Enable interrupts. */ rtwn_write_4(sc, R92C_HIMR, RTWN_INT_ENABLE); - sc->sc_flags |= RTWN_RUNNING; - callout_reset(&sc->watchdog_to, hz, rtwn_watchdog, sc); - return; fail: - rtwn_stop_locked(sc); + if (error != 0) + rtwn_stop_locked(sc); + + RTWN_UNLOCK(sc); + + return error; } static void @@ -3364,6 +3368,9 @@ rtwn_stop_locked(struct rtwn_softc *sc) RTWN_LOCK_ASSERT(sc); + if (!(sc->sc_flags & RTWN_RUNNING)) + return; + sc->sc_tx_timer = 0; callout_stop(&sc->watchdog_to); callout_stop(&sc->calib_to);