From owner-p4-projects@FreeBSD.ORG  Sat Jun  9 02:50:15 2007
Return-Path: <owner-p4-projects@FreeBSD.ORG>
X-Original-To: p4-projects@freebsd.org
Delivered-To: p4-projects@freebsd.org
Received: by hub.freebsd.org (Postfix, from userid 32767)
	id 48AFE16A47D; Sat,  9 Jun 2007 02:50:15 +0000 (UTC)
X-Original-To: perforce@freebsd.org
Delivered-To: perforce@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id 16BE216A468
	for <perforce@freebsd.org>; Sat,  9 Jun 2007 02:50:15 +0000 (UTC)
	(envelope-from thompsa@freebsd.org)
Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41])
	by mx1.freebsd.org (Postfix) with ESMTP id 02FA813C48C
	for <perforce@freebsd.org>; Sat,  9 Jun 2007 02:50:15 +0000 (UTC)
	(envelope-from thompsa@freebsd.org)
Received: from repoman.freebsd.org (localhost [127.0.0.1])
	by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l592oEq5025933
	for <perforce@freebsd.org>; Sat, 9 Jun 2007 02:50:14 GMT
	(envelope-from thompsa@freebsd.org)
Received: (from perforce@localhost)
	by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l592oELI025924
	for perforce@freebsd.org; Sat, 9 Jun 2007 02:50:14 GMT
	(envelope-from thompsa@freebsd.org)
Date: Sat, 9 Jun 2007 02:50:14 GMT
Message-Id: <200706090250.l592oELI025924@repoman.freebsd.org>
X-Authentication-Warning: repoman.freebsd.org: perforce set sender to
	thompsa@freebsd.org using -f
From: Andrew Thompson <thompsa@FreeBSD.org>
To: Perforce Change Reviews <perforce@freebsd.org>
Cc: 
Subject: PERFORCE change 121243 for review
X-BeenThere: p4-projects@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: p4 projects tree changes <p4-projects.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/p4-projects>,
	<mailto:p4-projects-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/p4-projects>
List-Post: <mailto:p4-projects@freebsd.org>
List-Help: <mailto:p4-projects-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/p4-projects>,
	<mailto:p4-projects-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sat, 09 Jun 2007 02:50:15 -0000

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 */