Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 May 2016 11:12:36 +0000 (UTC)
From:      Andriy Voskoboinyk <avos@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r300732 - head/sys/dev/iwn
Message-ID:  <201605261112.u4QBCark003377@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605261112.u4QBCark003377>