From owner-svn-src-head@freebsd.org Thu May 26 11:12:37 2016 Return-Path: Delivered-To: svn-src-head@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 74120B4B796; Thu, 26 May 2016 11:12:37 +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 371AA12D7; Thu, 26 May 2016 11:12:37 +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 u4QBCa8M003380; Thu, 26 May 2016 11:12:36 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4QBCark003377; Thu, 26 May 2016 11:12:36 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201605261112.u4QBCark003377@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Thu, 26 May 2016 11:12:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300732 - head/sys/dev/iwn 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.22 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: Thu, 26 May 2016 11:12:37 -0000 Author: avos Date: Thu May 26 11:12:36 2016 New Revision: 300732 URL: https://svnweb.freebsd.org/changeset/base/300732 Log: iwn: add watchdog for scanning. Restart device if scanning was not done in time. Tested by: david@catwhisker.org PR: 209198 Differential Revision: https://reviews.freebsd.org/D6176 Modified: head/sys/dev/iwn/if_iwn.c head/sys/dev/iwn/if_iwnvar.h Modified: head/sys/dev/iwn/if_iwn.c ============================================================================== --- head/sys/dev/iwn/if_iwn.c Thu May 26 11:10:31 2016 (r300731) +++ head/sys/dev/iwn/if_iwn.c Thu May 26 11:12:36 2016 (r300732) @@ -235,6 +235,7 @@ static void iwn_xmit_task(void *arg0, in static int iwn_raw_xmit(struct ieee80211_node *, struct mbuf *, const struct ieee80211_bpf_params *); static int iwn_transmit(struct ieee80211com *, struct mbuf *); +static void iwn_scan_timeout(void *); static void iwn_watchdog(void *); static int iwn_ioctl(struct ieee80211com *, u_long , void *); static void iwn_parent(struct ieee80211com *); @@ -675,6 +676,7 @@ iwn_attach(device_t dev) iwn_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); TASK_INIT(&sc->sc_radioon_task, 0, iwn_radio_on, sc); TASK_INIT(&sc->sc_radiooff_task, 0, iwn_radio_off, sc); @@ -1406,6 +1408,7 @@ iwn_detach(device_t dev) taskqueue_free(sc->sc_tq); callout_drain(&sc->watchdog_to); + callout_drain(&sc->scan_timeout); callout_drain(&sc->calib_to); ieee80211_ifdetach(&sc->sc_ic); } @@ -3937,6 +3940,7 @@ iwn_notif_intr(struct iwn_softc *sc) scan->nchan, scan->status, scan->chan); #endif sc->sc_is_scanning = 0; + callout_stop(&sc->scan_timeout); IWN_UNLOCK(sc); ieee80211_scan_next(vap); IWN_LOCK(sc); @@ -4955,6 +4959,16 @@ iwn_transmit(struct ieee80211com *ic, st } static void +iwn_scan_timeout(void *arg) +{ + struct iwn_softc *sc = arg; + struct ieee80211com *ic = &sc->sc_ic; + + ic_printf(ic, "scan timeout\n"); + ieee80211_restart_all(ic); +} + +static void iwn_watchdog(void *arg) { struct iwn_softc *sc = arg; @@ -6972,6 +6986,8 @@ iwn_scan(struct iwn_softc *sc, struct ie hdr->nchan); error = iwn_cmd(sc, IWN_CMD_SCAN, buf, buflen, 1); free(buf, M_DEVBUF); + if (error == 0) + callout_reset(&sc->scan_timeout, 5*hz, iwn_scan_timeout, sc); DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); Modified: head/sys/dev/iwn/if_iwnvar.h ============================================================================== --- head/sys/dev/iwn/if_iwnvar.h Thu May 26 11:10:31 2016 (r300731) +++ head/sys/dev/iwn/if_iwnvar.h Thu May 26 11:12:36 2016 (r300732) @@ -317,6 +317,7 @@ struct iwn_softc { int calib_cnt; struct iwn_calib_state calib; int last_calib_ticks; + struct callout scan_timeout; struct callout watchdog_to; struct iwn_fw_info fw; struct iwn_calib_info calibcmd[IWN5000_PHY_CALIB_MAX_RESULT]; @@ -378,7 +379,6 @@ struct iwn_softc { uint8_t chainmask; int sc_tx_timer; - int sc_scan_timer; /* Are we doing a scan? */ int sc_is_scanning;