diff options
author | jhb <jhb@FreeBSD.org> | 2011-01-03 18:28:30 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2011-01-03 18:28:30 +0000 |
commit | be4690f32e7fc9ca8ae00f30d3709d74e3ec9638 (patch) | |
tree | 1793e62d0fbc4c9b2b994466658eb4f1f58e4793 /sys/dev/alc | |
parent | 4c78089710b5ccf0a0c579c50abd36518cd0921d (diff) | |
download | FreeBSD-src-be4690f32e7fc9ca8ae00f30d3709d74e3ec9638.zip FreeBSD-src-be4690f32e7fc9ca8ae00f30d3709d74e3ec9638.tar.gz |
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
Diffstat (limited to 'sys/dev/alc')
-rw-r--r-- | sys/dev/alc/if_alc.c | 28 | ||||
-rw-r--r-- | sys/dev/alc/if_alcvar.h | 1 |
2 files changed, 12 insertions, 17 deletions
diff --git a/sys/dev/alc/if_alc.c b/sys/dev/alc/if_alc.c index dac8d90..9f06921 100644 --- a/sys/dev/alc/if_alc.c +++ b/sys/dev/alc/if_alc.c @@ -159,6 +159,7 @@ static void alc_setlinkspeed(struct alc_softc *); static void alc_setwol(struct alc_softc *); static int alc_shutdown(device_t); static void alc_start(struct ifnet *); +static void alc_start_locked(struct ifnet *); static void alc_start_queue(struct alc_softc *); static void alc_stats_clear(struct alc_softc *); static void alc_stats_update(struct alc_softc *); @@ -168,7 +169,6 @@ static void alc_stop_queue(struct alc_softc *); static int alc_suspend(device_t); static void alc_sysctl_node(struct alc_softc *); static void alc_tick(void *); -static void alc_tx_task(void *, int); static void alc_txeof(struct alc_softc *); static void alc_watchdog(struct alc_softc *); static int sysctl_int_range(SYSCTL_HANDLER_ARGS, int, int); @@ -1002,7 +1002,6 @@ alc_attach(device_t dev) ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); /* Create local taskq. */ - TASK_INIT(&sc->alc_tx_task, 1, alc_tx_task, ifp); sc->alc_tq = taskqueue_create_fast("alc_taskq", M_WAITOK, taskqueue_thread_enqueue, &sc->alc_tq); if (sc->alc_tq == NULL) { @@ -1059,7 +1058,6 @@ alc_detach(device_t dev) ALC_UNLOCK(sc); callout_drain(&sc->alc_tick_ch); taskqueue_drain(sc->alc_tq, &sc->alc_int_task); - taskqueue_drain(sc->alc_tq, &sc->alc_tx_task); ether_ifdetach(ifp); } @@ -2237,16 +2235,18 @@ alc_encap(struct alc_softc *sc, struct mbuf **m_head) } static void -alc_tx_task(void *arg, int pending) +alc_start(struct ifnet *ifp) { - struct ifnet *ifp; + struct alc_softc *sc; - ifp = (struct ifnet *)arg; - alc_start(ifp); + sc = ifp->if_softc; + ALC_LOCK(sc); + alc_start_locked(ifp); + ALC_UNLOCK(sc); } static void -alc_start(struct ifnet *ifp) +alc_start_locked(struct ifnet *ifp) { struct alc_softc *sc; struct mbuf *m_head; @@ -2254,17 +2254,15 @@ alc_start(struct ifnet *ifp) sc = ifp->if_softc; - ALC_LOCK(sc); + ALC_LOCK_ASSERT(sc); /* Reclaim transmitted frames. */ if (sc->alc_cdata.alc_tx_cnt >= ALC_TX_DESC_HIWAT) alc_txeof(sc); if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != - IFF_DRV_RUNNING || (sc->alc_flags & ALC_FLAG_LINK) == 0) { - ALC_UNLOCK(sc); + IFF_DRV_RUNNING || (sc->alc_flags & ALC_FLAG_LINK) == 0) return; - } for (enq = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd); ) { IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head); @@ -2303,8 +2301,6 @@ alc_start(struct ifnet *ifp) /* Set a timeout in case the chip goes out to lunch. */ sc->alc_watchdog_timer = ALC_TX_TIMEOUT; } - - ALC_UNLOCK(sc); } static void @@ -2330,7 +2326,7 @@ alc_watchdog(struct alc_softc *sc) ifp->if_drv_flags &= ~IFF_DRV_RUNNING; alc_init_locked(sc); if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - taskqueue_enqueue(sc->alc_tq, &sc->alc_tx_task); + alc_start_locked(ifp); } static int @@ -2710,7 +2706,7 @@ alc_int_task(void *arg, int pending) } if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0 && !IFQ_DRV_IS_EMPTY(&ifp->if_snd)) - taskqueue_enqueue(sc->alc_tq, &sc->alc_tx_task); + alc_start_locked(ifp); } if (more == EAGAIN || diff --git a/sys/dev/alc/if_alcvar.h b/sys/dev/alc/if_alcvar.h index 7280ca3..3215cef 100644 --- a/sys/dev/alc/if_alcvar.h +++ b/sys/dev/alc/if_alcvar.h @@ -246,7 +246,6 @@ struct alc_softc { int alc_buf_size; struct task alc_int_task; - struct task alc_tx_task; struct taskqueue *alc_tq; struct mtx alc_mtx; }; |