From 3593f855442b4c99d0bb2e5e2240edc25e4a9de9 Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 19 Nov 2009 22:14:23 +0000 Subject: - Hook into the existing stat timer to drive the transmit watchdog instead of using if_watchdog and if_timer. - Reorder detach to call ether_ifdetach() before anything else in tl(4) and wb(4). --- sys/dev/wb/if_wb.c | 29 ++++++++++++++--------------- sys/dev/wb/if_wbreg.h | 1 + 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'sys/dev/wb') diff --git a/sys/dev/wb/if_wb.c b/sys/dev/wb/if_wb.c index 9c2f468..cb4f3bb 100644 --- a/sys/dev/wb/if_wb.c +++ b/sys/dev/wb/if_wb.c @@ -158,7 +158,7 @@ static int wb_ioctl(struct ifnet *, u_long, caddr_t); static void wb_init(void *); static void wb_init_locked(struct wb_softc *); static void wb_stop(struct wb_softc *); -static void wb_watchdog(struct ifnet *); +static void wb_watchdog(struct wb_softc *); static int wb_shutdown(device_t); static int wb_ifmedia_upd(struct ifnet *); static void wb_ifmedia_sts(struct ifnet *, struct ifmediareq *); @@ -849,7 +849,6 @@ wb_attach(dev) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_ioctl = wb_ioctl; ifp->if_start = wb_start; - ifp->if_watchdog = wb_watchdog; ifp->if_init = wb_init; ifp->if_snd.ifq_maxlen = WB_TX_LIST_CNT - 1; @@ -907,11 +906,11 @@ wb_detach(dev) * This should only be done if attach succeeded. */ if (device_is_attached(dev)) { + ether_ifdetach(ifp); WB_LOCK(sc); wb_stop(sc); WB_UNLOCK(sc); callout_drain(&sc->wb_stat_callout); - ether_ifdetach(ifp); } if (sc->wb_miibus) device_delete_child(dev, sc->wb_miibus); @@ -1157,7 +1156,7 @@ wb_txeof(sc) ifp = sc->wb_ifp; /* Clear the timeout timer. */ - ifp->if_timer = 0; + sc->wb_timer = 0; if (sc->wb_cdata.wb_tx_head == NULL) return; @@ -1212,7 +1211,7 @@ wb_txeoc(sc) ifp = sc->wb_ifp; - ifp->if_timer = 0; + sc->wb_timer = 0; if (sc->wb_cdata.wb_tx_head == NULL) { ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; @@ -1220,7 +1219,7 @@ wb_txeoc(sc) } else { if (WB_TXOWN(sc->wb_cdata.wb_tx_head) == WB_UNSENT) { WB_TXOWN(sc->wb_cdata.wb_tx_head) = WB_TXSTAT_OWN; - ifp->if_timer = 5; + sc->wb_timer = 5; CSR_WRITE_4(sc, WB_TXSTART, 0xFFFFFFFF); } } @@ -1329,6 +1328,8 @@ wb_tick(xsc) mii_tick(mii); + if (sc->wb_timer > 0 && --sc->wb_timer == 0) + wb_watchdog(sc); callout_reset(&sc->wb_stat_callout, hz, wb_tick, sc); return; @@ -1529,7 +1530,7 @@ wb_start_locked(ifp) /* * Set a timeout in case the chip goes out to lunch. */ - ifp->if_timer = 5; + sc->wb_timer = 5; return; } @@ -1748,14 +1749,13 @@ wb_ioctl(ifp, command, data) } static void -wb_watchdog(ifp) - struct ifnet *ifp; -{ +wb_watchdog(sc) struct wb_softc *sc; +{ + struct ifnet *ifp; - sc = ifp->if_softc; - - WB_LOCK(sc); + WB_LOCK_ASSERT(sc); + ifp = sc->wb_ifp; ifp->if_oerrors++; if_printf(ifp, "watchdog timeout\n"); #ifdef foo @@ -1768,7 +1768,6 @@ wb_watchdog(ifp) if (ifp->if_snd.ifq_head != NULL) wb_start_locked(ifp); - WB_UNLOCK(sc); return; } @@ -1786,7 +1785,7 @@ wb_stop(sc) WB_LOCK_ASSERT(sc); ifp = sc->wb_ifp; - ifp->if_timer = 0; + sc->wb_timer = 0; callout_stop(&sc->wb_stat_callout); diff --git a/sys/dev/wb/if_wbreg.h b/sys/dev/wb/if_wbreg.h index ce7f46a..95d0a8e 100644 --- a/sys/dev/wb/if_wbreg.h +++ b/sys/dev/wb/if_wbreg.h @@ -372,6 +372,7 @@ struct wb_softc { u_int8_t wb_type; u_int16_t wb_txthresh; int wb_cachesize; + int wb_timer; caddr_t wb_ldata_ptr; struct wb_list_data *wb_ldata; struct wb_chain_data wb_cdata; -- cgit v1.1