Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 Jun 2007 02:50:14 GMT
From:      Andrew Thompson <thompsa@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 121243 for review
Message-ID:  <200706090250.l592oELI025924@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=121243

Change 121243 by thompsa@thompsa_heff on 2007/06/09 02:49:56

	Use our own callout instead of if_watchdog.

Affected files ...

.. //depot/projects/wifi/sys/dev/iwi/if_iwi.c#41 edit
.. //depot/projects/wifi/sys/dev/iwi/if_iwivar.h#16 edit

Differences ...

==== //depot/projects/wifi/sys/dev/iwi/if_iwi.c#41 (text+ko) ====

@@ -152,7 +152,7 @@
 static int	iwi_tx_start(struct ifnet *, struct mbuf *,
 		    struct ieee80211_node *, int);
 static void	iwi_start(struct ifnet *);
-static void	iwi_watchdog(struct ifnet *);
+static void	iwi_watchdog(void *);
 static int	iwi_ioctl(struct ifnet *, u_long, caddr_t);
 static void	iwi_stop_master(struct iwi_softc *);
 static int	iwi_reset(struct iwi_softc *);
@@ -282,6 +282,7 @@
 	TASK_INIT(&sc->sc_downtask, 0, iwi_down, sc);
 	TASK_INIT(&sc->sc_restarttask, 0, iwi_restart, sc);
 	TASK_INIT(&sc->sc_opstask, 0, iwi_ops, sc);
+	callout_init_mtx(&sc->sc_wdtimer, &sc->sc_mtx, 0);
 
 	if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
 		device_printf(dev, "chip is in D%d power mode "
@@ -356,7 +357,6 @@
 	ifp->if_init = iwi_init;
 	ifp->if_ioctl = iwi_ioctl;
 	ifp->if_start = iwi_start;
-	ifp->if_watchdog = iwi_watchdog;
 	IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
 	ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
 	IFQ_SET_READY(&ifp->if_snd);
@@ -458,6 +458,8 @@
 		bpfdetach(ifp);
 		ieee80211_ifdetach(ic);
 	}
+
+	callout_drain(&sc->sc_wdtimer);
 	iwi_put_firmware(sc);
 	iwi_release_fw_dma(sc);
 
@@ -1954,19 +1956,18 @@
 		}
 
 		sc->sc_tx_timer = 5;
-		ifp->if_timer = 1;
 	}
 
 	IWI_UNLOCK(sc);
 }
 
 static void
-iwi_watchdog(struct ifnet *ifp)
+iwi_watchdog(void *arg)
 {
-	struct iwi_softc *sc = ifp->if_softc;
-	IWI_LOCK_DECL;
+	struct iwi_softc *sc = arg;
+	struct ifnet *ifp = sc->sc_ifp;
 
-	IWI_LOCK(sc);
+	IWI_LOCK_CHECK(sc);
 
 	if (sc->sc_tx_timer > 0) {
 		if (--sc->sc_tx_timer == 0) {
@@ -1997,12 +1998,9 @@
 			}
 		}
 	}
-	if (sc->sc_tx_timer || sc->sc_rfkill_timer || sc->sc_scan_timer)
-		ifp->if_timer = 1;
-	else
-		ifp->if_timer = 0;
 
-	IWI_UNLOCK(sc);
+	if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+		callout_reset(&sc->sc_wdtimer, hz, iwi_watchdog, sc);
 }
 
 static int
@@ -2801,7 +2799,6 @@
 #endif
 	sc->flags |= IWI_FLAG_SCANNING;
 	sc->sc_scan_timer = 3;
-	sc->sc_ifp->if_timer = 1;
 
 	return (iwi_cmd(sc, IWI_CMD_SCAN_EXT, &scan, sizeof scan));
 }
@@ -3181,6 +3178,7 @@
 	} else
 		ieee80211_new_state(ic, IEEE80211_S_RUN, -1);
 
+	callout_reset(&sc->sc_wdtimer, hz, iwi_watchdog, sc);
 	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
 	ifp->if_drv_flags |= IFF_DRV_RUNNING;
 
@@ -3206,6 +3204,7 @@
 		sc->sc_blinking = 0;
 	}
 
+	callout_stop(&sc->sc_wdtimer);
 	iwi_stop_master(sc);
 
 	CSR_WRITE_4(sc, IWI_CSR_RST, IWI_RST_SOFT_RESET);
@@ -3218,7 +3217,6 @@
 	iwi_reset_tx_ring(sc, &sc->txq[3]);
 	iwi_reset_rx_ring(sc, &sc->rxq);
 
-	ifp->if_timer = 0;
 	ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
 
 	sc->sc_tx_timer = 0;
@@ -3267,7 +3265,6 @@
 	device_printf(sc->sc_dev, "radio turned off\n");
 	iwi_stop(sc);
 	sc->sc_rfkill_timer = 2;
-	sc->sc_ifp->if_timer = 1;
 }
 
 static int

==== //depot/projects/wifi/sys/dev/iwi/if_iwivar.h#16 (text+ko) ====

@@ -203,6 +203,7 @@
 	u_int8_t		sc_txrix;
 	u_int16_t		sc_ledoff;	/* off time for current blink */
 	struct callout		sc_ledtimer;	/* led off timer */
+	struct callout		sc_wdtimer;	/* watchdog timer */
 
 	int			sc_tx_timer;
 	int			sc_rfkill_timer;/* poll for rfkill change */



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