From owner-svn-src-head@FreeBSD.ORG Sun Mar 15 21:19:16 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 95310719; Sun, 15 Mar 2015 21:19:16 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 80C318B6; Sun, 15 Mar 2015 21:19:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t2FLJGD9085938; Sun, 15 Mar 2015 21:19:16 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t2FLJGgB085936; Sun, 15 Mar 2015 21:19:16 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201503152119.t2FLJGgB085936@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Sun, 15 Mar 2015 21:19:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r280106 - head/sys/dev/wpi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Mar 2015 21:19:16 -0000 Author: adrian Date: Sun Mar 15 21:19:15 2015 New Revision: 280106 URL: https://svnweb.freebsd.org/changeset/base/280106 Log: Split TX and scan timeouts; use a callout now for the scan timeout. PR: kern/197143 Submitted by: Andriy Voskoboinyk Modified: head/sys/dev/wpi/if_wpi.c head/sys/dev/wpi/if_wpivar.h Modified: head/sys/dev/wpi/if_wpi.c ============================================================================== --- head/sys/dev/wpi/if_wpi.c Sun Mar 15 21:18:18 2015 (r280105) +++ head/sys/dev/wpi/if_wpi.c Sun Mar 15 21:19:15 2015 (r280106) @@ -200,6 +200,7 @@ static int wpi_raw_xmit(struct ieee80211 static void wpi_start(struct ifnet *); static void wpi_start_task(void *, int); static void wpi_watchdog_rfkill(void *); +static void wpi_scan_timeout(void *); static void wpi_watchdog(void *); static int wpi_ioctl(struct ifnet *, u_long, caddr_t); static int wpi_cmd(struct wpi_softc *, int, const void *, size_t, int); @@ -520,6 +521,7 @@ wpi_attach(device_t dev) wpi_radiotap_attach(sc); callout_init_mtx(&sc->calib_to, &sc->sc_mtx, 0); + callout_init_mtx(&sc->scan_timeout, &sc->sc_mtx, 0); callout_init_mtx(&sc->watchdog_to, &sc->sc_mtx, 0); callout_init_mtx(&sc->watchdog_rfkill, &sc->sc_mtx, 0); TASK_INIT(&sc->sc_reinittask, 0, wpi_hw_reset, sc); @@ -683,8 +685,9 @@ wpi_detach(device_t dev) wpi_stop(sc); - callout_drain(&sc->watchdog_to); callout_drain(&sc->watchdog_rfkill); + callout_drain(&sc->watchdog_to); + callout_drain(&sc->scan_timeout); callout_drain(&sc->calib_to); ieee80211_ifdetach(ic); } @@ -2163,7 +2166,7 @@ wpi_notif_intr(struct wpi_softc *sc) "scan finished nchan=%d status=%d chan=%d\n", scan->nchan, scan->status, scan->chan); #endif - sc->sc_scan_timer = 0; + callout_stop(&sc->scan_timeout); WPI_UNLOCK(sc); ieee80211_scan_next(vap); WPI_LOCK(sc); @@ -2925,6 +2928,17 @@ wpi_watchdog_rfkill(void *arg) ieee80211_runtask(ic, &sc->sc_radioon_task); } +static void +wpi_scan_timeout(void *arg) +{ + struct wpi_softc *sc = arg; + struct ifnet *ifp = sc->sc_ifp; + struct ieee80211com *ic = ifp->if_l2com; + + if_printf(ifp, "scan timeout\n"); + ieee80211_runtask(ic, &sc->sc_reinittask); +} + /** * Called every second, wpi_watchdog used by the watch dog timer * to check that the card is still alive @@ -2946,15 +2960,6 @@ wpi_watchdog(void *arg) } } - if (sc->sc_scan_timer > 0) { - struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps); - if (--sc->sc_scan_timer == 0 && vap != NULL) { - if_printf(ifp, "scan timeout\n"); - ieee80211_cancel_scan(vap); - ieee80211_runtask(ic, &sc->sc_reinittask); - } - } - if (ifp->if_drv_flags & IFF_DRV_RUNNING) callout_reset(&sc->watchdog_to, hz, wpi_watchdog, sc); } @@ -3873,7 +3878,7 @@ wpi_scan(struct wpi_softc *sc, struct ie * We are absolutely not allowed to send a scan command when another * scan command is pending. */ - if (sc->sc_scan_timer) { + if (callout_pending(&sc->scan_timeout)) { device_printf(sc->sc_dev, "%s: called whilst scanning!\n", __func__); @@ -4016,7 +4021,7 @@ wpi_scan(struct wpi_softc *sc, struct ie if (error != 0) goto fail; - sc->sc_scan_timer = 5; + callout_reset(&sc->scan_timeout, 5*hz, wpi_scan_timeout, sc); DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END, __func__); @@ -5270,9 +5275,9 @@ wpi_stop_locked(struct wpi_softc *sc) sc->txq_active = 0; WPI_TXQ_UNLOCK(sc); - sc->sc_scan_timer = 0; sc->sc_tx_timer = 0; callout_stop(&sc->watchdog_to); + callout_stop(&sc->scan_timeout); callout_stop(&sc->calib_to); IF_LOCK(&ifp->if_snd); @@ -5404,6 +5409,9 @@ wpi_hw_reset(void *arg, int pending) DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_DOING, __func__); + if (vap != NULL && (ic->ic_flags & IEEE80211_F_SCAN)) + ieee80211_cancel_scan(vap); + wpi_stop(sc); if (vap != NULL) ieee80211_stop(vap); Modified: head/sys/dev/wpi/if_wpivar.h ============================================================================== --- head/sys/dev/wpi/if_wpivar.h Sun Mar 15 21:18:18 2015 (r280105) +++ head/sys/dev/wpi/if_wpivar.h Sun Mar 15 21:19:15 2015 (r280106) @@ -180,6 +180,8 @@ struct wpi_softc { struct callout calib_to; int calib_cnt; + struct callout scan_timeout; + /* Watch dog timers. */ struct callout watchdog_to; struct callout watchdog_rfkill; @@ -204,7 +206,6 @@ struct wpi_softc { struct mtx nt_mtx; int sc_tx_timer; - int sc_scan_timer; void (*sc_node_free)(struct ieee80211_node *); void (*sc_scan_curchan)(struct ieee80211_scan_state *,