From be4690f32e7fc9ca8ae00f30d3709d74e3ec9638 Mon Sep 17 00:00:00 2001 From: jhb Date: Mon, 3 Jan 2011 18:28:30 +0000 Subject: Add a 'locked' variant of the foo_start() routine and call it directly from interrupt handlers and watchdog routines instead of queueing a task to call foo_start(). Reviewed by: yongari MFC after: 1 month --- sys/dev/nfe/if_nfe.c | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'sys/dev/nfe/if_nfe.c') diff --git a/sys/dev/nfe/if_nfe.c b/sys/dev/nfe/if_nfe.c index 8e816f6..cac32a4 100644 --- a/sys/dev/nfe/if_nfe.c +++ b/sys/dev/nfe/if_nfe.c @@ -99,8 +99,8 @@ static int nfe_jrxeof(struct nfe_softc *, int, int *); static void nfe_txeof(struct nfe_softc *); static int nfe_encap(struct nfe_softc *, struct mbuf **); static void nfe_setmulti(struct nfe_softc *); -static void nfe_tx_task(void *, int); static void nfe_start(struct ifnet *); +static void nfe_start_locked(struct ifnet *); static void nfe_watchdog(struct ifnet *); static void nfe_init(void *); static void nfe_init_locked(void *); @@ -553,7 +553,6 @@ nfe_attach(device_t dev) error = ENOSPC; goto fail; } - TASK_INIT(&sc->nfe_tx_task, 1, nfe_tx_task, ifp); /* * Allocate Tx and Rx rings. @@ -679,7 +678,6 @@ nfe_detach(device_t dev) ifp->if_flags &= ~IFF_UP; NFE_UNLOCK(sc); callout_drain(&sc->nfe_stat_ch); - taskqueue_drain(taskqueue_fast, &sc->nfe_tx_task); ether_ifdetach(ifp); } @@ -1631,7 +1629,7 @@ nfe_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) rx_npkts = nfe_rxeof(sc, count, &rx_npkts); nfe_txeof(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - taskqueue_enqueue_fast(sc->nfe_tq, &sc->nfe_tx_task); + nfe_start_locked(ifp); if (cmd == POLL_AND_CHECK_STATUS) { if ((r = NFE_READ(sc, sc->nfe_irq_status)) == 0) { @@ -1903,7 +1901,7 @@ nfe_int_task(void *arg, int pending) nfe_txeof(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - taskqueue_enqueue_fast(sc->nfe_tq, &sc->nfe_tx_task); + nfe_start_locked(ifp); NFE_UNLOCK(sc); @@ -2599,29 +2597,27 @@ done: static void -nfe_tx_task(void *arg, int pending) +nfe_start(struct ifnet *ifp) { - struct ifnet *ifp; + struct nfe_softc *sc = ifp->if_softc; - ifp = (struct ifnet *)arg; - nfe_start(ifp); + NFE_LOCK(sc); + nfe_start_locked(ifp); + NFE_UNLOCK(sc); } - static void -nfe_start(struct ifnet *ifp) +nfe_start_locked(struct ifnet *ifp) { struct nfe_softc *sc = ifp->if_softc; struct mbuf *m0; int enq; - NFE_LOCK(sc); + NFE_LOCK_ASSERT(sc); if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != - IFF_DRV_RUNNING || sc->nfe_link == 0) { - NFE_UNLOCK(sc); + IFF_DRV_RUNNING || sc->nfe_link == 0) return; - } for (enq = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd);) { IFQ_DRV_DEQUEUE(&ifp->if_snd, m0); @@ -2651,8 +2647,6 @@ nfe_start(struct ifnet *ifp) */ sc->nfe_watchdog_timer = 5; } - - NFE_UNLOCK(sc); } @@ -2670,7 +2664,7 @@ nfe_watchdog(struct ifnet *ifp) if_printf(ifp, "watchdog timeout (missed Tx interrupts) " "-- recovering\n"); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - taskqueue_enqueue_fast(sc->nfe_tq, &sc->nfe_tx_task); + nfe_start_locked(ifp); return; } /* Check if we've lost start Tx command. */ -- cgit v1.1