Module Name: src Committed By: knakahara Date: Tue Oct 13 08:11:31 UTC 2015
Modified Files: src/sys/dev/pci: if_wm.c Log Message: separete TX, RX queue mutex from wm_softc and rearrange WM_BOTH_LOCK. ok by msaitoh@n.o To generate a diff of this commit: cvs rdiff -u -r1.356 -r1.357 src/sys/dev/pci/if_wm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.356 src/sys/dev/pci/if_wm.c:1.357 --- src/sys/dev/pci/if_wm.c:1.356 Tue Oct 13 08:08:03 2015 +++ src/sys/dev/pci/if_wm.c Tue Oct 13 08:11:31 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.356 2015/10/13 08:08:03 knakahara Exp $ */ +/* $NetBSD: if_wm.c,v 1.357 2015/10/13 08:11:31 knakahara Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -83,7 +83,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.356 2015/10/13 08:08:03 knakahara Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.357 2015/10/13 08:11:31 knakahara Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -265,7 +265,7 @@ static const uint32_t wm_82580_rxpbs_tab struct wm_softc; struct wm_txqueue { - /* XXX should move tx_lock here. */ + kmutex_t *txq_lock; /* lock for tx operations */ struct wm_softc *txq_sc; @@ -303,7 +303,7 @@ struct wm_txqueue { }; struct wm_rxqueue { - /* XXX should move rx_lock here. */ + kmutex_t *rxq_lock; /* lock for rx operations */ struct wm_softc *rxq_sc; @@ -449,19 +449,18 @@ struct wm_softc { krndsource_t rnd_source; /* random source */ - kmutex_t *sc_tx_lock; /* lock for tx operations */ - kmutex_t *sc_rx_lock; /* lock for rx operations */ + kmutex_t *sc_core_lock; /* lock for softc operations */ }; -#define WM_TX_LOCK(_sc) if ((_sc)->sc_tx_lock) mutex_enter((_sc)->sc_tx_lock) -#define WM_TX_UNLOCK(_sc) if ((_sc)->sc_tx_lock) mutex_exit((_sc)->sc_tx_lock) -#define WM_TX_LOCKED(_sc) (!(_sc)->sc_tx_lock || mutex_owned((_sc)->sc_tx_lock)) -#define WM_RX_LOCK(_sc) if ((_sc)->sc_rx_lock) mutex_enter((_sc)->sc_rx_lock) -#define WM_RX_UNLOCK(_sc) if ((_sc)->sc_rx_lock) mutex_exit((_sc)->sc_rx_lock) -#define WM_RX_LOCKED(_sc) (!(_sc)->sc_rx_lock || mutex_owned((_sc)->sc_rx_lock)) -#define WM_BOTH_LOCK(_sc) do {WM_TX_LOCK(_sc); WM_RX_LOCK(_sc);} while (0) -#define WM_BOTH_UNLOCK(_sc) do {WM_RX_UNLOCK(_sc); WM_TX_UNLOCK(_sc);} while (0) -#define WM_BOTH_LOCKED(_sc) (WM_TX_LOCKED(_sc) && WM_RX_LOCKED(_sc)) +#define WM_TX_LOCK(_txq) if ((_txq)->txq_lock) mutex_enter((_txq)->txq_lock) +#define WM_TX_UNLOCK(_txq) if ((_txq)->txq_lock) mutex_exit((_txq)->txq_lock) +#define WM_TX_LOCKED(_txq) (!(_txq)->txq_lock || mutex_owned((_txq)->txq_lock)) +#define WM_RX_LOCK(_rxq) if ((_rxq)->rxq_lock) mutex_enter((_rxq)->rxq_lock) +#define WM_RX_UNLOCK(_rxq) if ((_rxq)->rxq_lock) mutex_exit((_rxq)->rxq_lock) +#define WM_RX_LOCKED(_rxq) (!(_rxq)->rxq_lock || mutex_owned((_rxq)->rxq_lock)) +#define WM_CORE_LOCK(_sc) if ((_sc)->sc_core_lock) mutex_enter((_sc)->sc_core_lock) +#define WM_CORE_UNLOCK(_sc) if ((_sc)->sc_core_lock) mutex_exit((_sc)->sc_core_lock) +#define WM_CORE_LOCKED(_sc) (!(_sc)->sc_core_lock || mutex_owned((_sc)->sc_core_lock)) #ifdef WM_MPSAFE #define CALLOUT_FLAGS CALLOUT_MPSAFE @@ -2546,11 +2545,9 @@ alloc_retry: } #ifdef WM_MPSAFE - sc->sc_tx_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET); - sc->sc_rx_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET); + sc->sc_core_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET); #else - sc->sc_tx_lock = NULL; - sc->sc_rx_lock = NULL; + sc->sc_core_lock = NULL; #endif /* Attach the interface. */ @@ -2635,6 +2632,7 @@ static int wm_detach(device_t self, int flags __unused) { struct wm_softc *sc = device_private(self); + struct wm_rxqueue *rxq = sc->sc_rxq; struct ifnet *ifp = &sc->sc_ethercom.ec_if; int i; #ifndef WM_MPSAFE @@ -2657,10 +2655,10 @@ wm_detach(device_t self, int flags __unu pmf_device_deregister(self); /* Tell the firmware about the release */ - WM_BOTH_LOCK(sc); + WM_CORE_LOCK(sc); wm_release_manageability(sc); wm_release_hw_control(sc); - WM_BOTH_UNLOCK(sc); + WM_CORE_UNLOCK(sc); mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY); @@ -2672,9 +2670,9 @@ wm_detach(device_t self, int flags __unu /* Unload RX dmamaps and free mbufs */ - WM_RX_LOCK(sc); + WM_RX_LOCK(rxq); wm_rxdrain(sc); - WM_RX_UNLOCK(sc); + WM_RX_UNLOCK(rxq); /* Must unlock here */ wm_free_txrx_queues(sc); @@ -2704,10 +2702,8 @@ wm_detach(device_t self, int flags __unu sc->sc_flashs = 0; } - if (sc->sc_tx_lock) - mutex_obj_free(sc->sc_tx_lock); - if (sc->sc_rx_lock) - mutex_obj_free(sc->sc_rx_lock); + if (sc->sc_core_lock) + mutex_obj_free(sc->sc_core_lock); return 0; } @@ -2751,9 +2747,9 @@ wm_watchdog(struct ifnet *ifp) * Since we're using delayed interrupts, sweep up * before we report an error. */ - WM_TX_LOCK(sc); + WM_TX_LOCK(txq); wm_txeof(sc); - WM_TX_UNLOCK(sc); + WM_TX_UNLOCK(txq); if (txq->txq_free != WM_NTXDESC(txq)) { #ifdef WM_DEBUG @@ -2808,7 +2804,7 @@ wm_tick(void *arg) s = splnet(); #endif - WM_TX_LOCK(sc); + WM_CORE_LOCK(sc); if (sc->sc_stopping) goto out; @@ -2841,7 +2837,7 @@ wm_tick(void *arg) wm_tbi_tick(sc); out: - WM_TX_UNLOCK(sc); + WM_CORE_UNLOCK(sc); #ifndef WM_MPSAFE splx(s); #endif @@ -2858,7 +2854,7 @@ wm_ifflags_cb(struct ethercom *ec) int change = ifp->if_flags ^ sc->sc_if_flags; int rc = 0; - WM_BOTH_LOCK(sc); + WM_CORE_LOCK(sc); if (change != 0) sc->sc_if_flags = ifp->if_flags; @@ -2874,7 +2870,7 @@ wm_ifflags_cb(struct ethercom *ec) wm_set_vlan(sc); out: - WM_BOTH_UNLOCK(sc); + WM_CORE_UNLOCK(sc); return rc; } @@ -2899,7 +2895,7 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, switch (cmd) { case SIOCSIFMEDIA: case SIOCGIFMEDIA: - WM_BOTH_LOCK(sc); + WM_CORE_LOCK(sc); /* Flow control requires full-duplex mode. */ if (IFM_SUBTYPE(ifr->ifr_media) == IFM_AUTO || (ifr->ifr_media & IFM_FDX) == 0) @@ -2912,7 +2908,7 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, } sc->sc_flowflags = ifr->ifr_media & IFM_ETH_FMASK; } - WM_BOTH_UNLOCK(sc); + WM_CORE_UNLOCK(sc); #ifdef WM_MPSAFE s = splnet(); #endif @@ -2922,7 +2918,7 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, #endif break; case SIOCINITIFADDR: - WM_BOTH_LOCK(sc); + WM_CORE_LOCK(sc); if (ifa->ifa_addr->sa_family == AF_LINK) { sdl = satosdl(ifp->if_dl->ifa_addr); (void)sockaddr_dl_setaddr(sdl, sdl->sdl_len, @@ -2930,10 +2926,10 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, /* unicast address is first multicast entry */ wm_set_filter(sc); error = 0; - WM_BOTH_UNLOCK(sc); + WM_CORE_UNLOCK(sc); break; } - WM_BOTH_UNLOCK(sc); + WM_CORE_UNLOCK(sc); /*FALLTHROUGH*/ default: #ifdef WM_MPSAFE @@ -2958,9 +2954,9 @@ wm_ioctl(struct ifnet *ifp, u_long cmd, * Multicast list has changed; set the hardware filter * accordingly. */ - WM_BOTH_LOCK(sc); + WM_CORE_LOCK(sc); wm_set_filter(sc); - WM_BOTH_UNLOCK(sc); + WM_CORE_UNLOCK(sc); } break; } @@ -4043,7 +4039,7 @@ wm_add_rxbuf(struct wm_softc *sc, int id struct mbuf *m; int error; - KASSERT(WM_RX_LOCKED(sc)); + KASSERT(WM_RX_LOCKED(rxq)); MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) @@ -4095,7 +4091,7 @@ wm_rxdrain(struct wm_softc *sc) struct wm_rxsoft *rxs; int i; - KASSERT(WM_RX_LOCKED(sc)); + KASSERT(WM_RX_LOCKED(rxq)); for (i = 0; i < WM_NRXDESC; i++) { rxs = &rxq->rxq_soft[i]; @@ -4118,9 +4114,9 @@ wm_init(struct ifnet *ifp) struct wm_softc *sc = ifp->if_softc; int ret; - WM_BOTH_LOCK(sc); + WM_CORE_LOCK(sc); ret = wm_init_locked(ifp); - WM_BOTH_UNLOCK(sc); + WM_CORE_UNLOCK(sc); return ret; } @@ -4132,7 +4128,7 @@ wm_init_locked(struct ifnet *ifp) int i, j, trynum, error = 0; uint32_t reg; - KASSERT(WM_BOTH_LOCKED(sc)); + KASSERT(WM_CORE_LOCKED(sc)); /* * *_HDR_ALIGNED_P is constant 1 if __NO_STRICT_ALIGMENT is set. * There is a small but measurable benefit to avoiding the adjusment @@ -4612,9 +4608,9 @@ wm_stop(struct ifnet *ifp, int disable) { struct wm_softc *sc = ifp->if_softc; - WM_BOTH_LOCK(sc); + WM_CORE_LOCK(sc); wm_stop_locked(ifp, disable); - WM_BOTH_UNLOCK(sc); + WM_CORE_UNLOCK(sc); } static void @@ -4622,10 +4618,11 @@ wm_stop_locked(struct ifnet *ifp, int di { struct wm_softc *sc = ifp->if_softc; struct wm_txqueue *txq = sc->sc_txq; + struct wm_rxqueue *rxq = sc->sc_rxq; struct wm_txsoft *txs; int i; - KASSERT(WM_BOTH_LOCKED(sc)); + KASSERT(WM_CORE_LOCKED(sc)); sc->sc_stopping = true; @@ -4668,6 +4665,7 @@ wm_stop_locked(struct ifnet *ifp, int di } /* Release any queued transmit buffers. */ + WM_TX_LOCK(txq); for (i = 0; i < WM_TXQUEUELEN(txq); i++) { txs = &txq->txq_soft[i]; if (txs->txs_mbuf != NULL) { @@ -4676,13 +4674,17 @@ wm_stop_locked(struct ifnet *ifp, int di txs->txs_mbuf = NULL; } } + WM_TX_UNLOCK(txq); /* Mark the interface as down and cancel the watchdog timer. */ ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); ifp->if_timer = 0; - if (disable) + if (disable) { + WM_RX_LOCK(rxq); wm_rxdrain(sc); + WM_RX_UNLOCK(rxq); + } #if 0 /* notyet */ if (sc->sc_type >= WM_T_82544) @@ -4917,7 +4919,7 @@ wm_82547_txfifo_stall(void *arg) s = splnet(); #endif - WM_TX_LOCK(sc); + WM_TX_LOCK(txq); if (sc->sc_stopping) goto out; @@ -4953,7 +4955,7 @@ wm_82547_txfifo_stall(void *arg) } out: - WM_TX_UNLOCK(sc); + WM_TX_UNLOCK(txq); #ifndef WM_MPSAFE splx(s); #endif @@ -5265,6 +5267,12 @@ wm_alloc_txrx_queues(struct wm_softc *sc error = ENOMEM; goto fail_0; } +#ifdef WM_MPSAFE + sc->sc_txq->txq_lock = + mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET); +#else + sc->sc_txq->txq_lock = NULL; +#endif error = wm_alloc_tx_descs(sc); if (error) @@ -5277,13 +5285,19 @@ wm_alloc_txrx_queues(struct wm_softc *sc /* * For recieve */ - sc->sc_rxq = kmem_zalloc(sizeof(struct wm_txqueue) * sc->sc_nrxqueues, + sc->sc_rxq = kmem_zalloc(sizeof(struct wm_rxqueue) * sc->sc_nrxqueues, KM_SLEEP); if (sc->sc_rxq == NULL) { aprint_error_dev(sc->sc_dev, "unable to allocate wm_rxqueue\n"); error = ENOMEM; goto fail_3; } +#ifdef WM_MPSAFE + sc->sc_rxq->rxq_lock = + mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET); +#else + sc->sc_rxq->rxq_lock = NULL; +#endif error = wm_alloc_rx_descs(sc); if (error) @@ -5298,6 +5312,8 @@ wm_alloc_txrx_queues(struct wm_softc *sc fail_5: wm_free_rx_descs(sc); fail_4: + if (sc->sc_rxq->rxq_lock) + mutex_obj_free(sc->sc_rxq->rxq_lock); kmem_free(sc->sc_rxq, sizeof(struct wm_rxqueue) * sc->sc_nrxqueues); fail_3: @@ -5305,6 +5321,8 @@ wm_alloc_txrx_queues(struct wm_softc *sc fail_2: wm_free_tx_descs(sc); fail_1: + if (sc->sc_txq->txq_lock) + mutex_obj_free(sc->sc_txq->txq_lock); kmem_free(sc->sc_txq, sizeof(struct wm_txqueue) * sc->sc_ntxqueues); fail_0: @@ -5321,11 +5339,15 @@ wm_free_txrx_queues(struct wm_softc *sc) wm_free_rx_buffer(sc); wm_free_rx_descs(sc); + if (sc->sc_rxq->rxq_lock) + mutex_obj_free(sc->sc_rxq->rxq_lock); kmem_free(sc->sc_rxq, sizeof(struct wm_rxqueue) * sc->sc_nrxqueues); wm_free_tx_buffer(sc); wm_free_tx_descs(sc); + if (sc->sc_txq->txq_lock) + mutex_obj_free(sc->sc_txq->txq_lock); kmem_free(sc->sc_txq, sizeof(struct wm_txqueue) * sc->sc_ntxqueues); } @@ -5335,7 +5357,7 @@ wm_init_tx_descs(struct wm_softc *sc) { struct wm_txqueue *txq = sc->sc_txq; - KASSERT(WM_TX_LOCKED(sc)); + KASSERT(WM_TX_LOCKED(txq)); /* Initialize the transmit descriptor ring. */ memset(txq->txq_descs, 0, WM_TXDESCSIZE(txq)); @@ -5388,7 +5410,7 @@ wm_init_tx_buffer(struct wm_softc *sc) struct wm_txqueue *txq = sc->sc_txq; int i; - KASSERT(WM_TX_LOCKED(sc)); + KASSERT(WM_TX_LOCKED(txq)); /* Initialize the transmit job descriptors. */ for (i = 0; i < WM_TXQUEUELEN(txq); i++) @@ -5403,7 +5425,7 @@ wm_init_tx_queue(struct wm_softc *sc) { struct wm_txqueue *txq = sc->sc_txq; - KASSERT(WM_TX_LOCKED(sc)); + KASSERT(WM_TX_LOCKED(txq)); /* * Set up some register offsets that are different between @@ -5424,7 +5446,7 @@ wm_init_rx_descs(struct wm_softc *sc) { struct wm_rxqueue *rxq = sc->sc_rxq; - KASSERT(WM_RX_LOCKED(sc)); + KASSERT(WM_RX_LOCKED(rxq)); /* * Initialize the receive descriptor and receive job @@ -5475,7 +5497,7 @@ wm_init_rx_buffer(struct wm_softc *sc) struct wm_rxsoft *rxs; int error, i; - KASSERT(WM_RX_LOCKED(sc)); + KASSERT(WM_RX_LOCKED(rxq)); for (i = 0; i < WM_NRXDESC; i++) { rxs = &rxq->rxq_soft[i]; @@ -5513,7 +5535,7 @@ wm_init_rx_queue(struct wm_softc *sc) { struct wm_rxqueue *rxq = sc->sc_rxq; - KASSERT(WM_RX_LOCKED(sc)); + KASSERT(WM_RX_LOCKED(rxq)); /* * Set up some register offsets that are different between @@ -5536,12 +5558,17 @@ wm_init_rx_queue(struct wm_softc *sc) static int wm_init_txrx_queues(struct wm_softc *sc) { + struct wm_txqueue *txq = sc->sc_txq; + struct wm_rxqueue *rxq = sc->sc_rxq; int error; - KASSERT(WM_BOTH_LOCKED(sc)); - + WM_TX_LOCK(txq); wm_init_tx_queue(sc); + WM_TX_UNLOCK(txq); + + WM_RX_LOCK(rxq); error = wm_init_rx_queue(sc); + WM_RX_UNLOCK(rxq); return error; } @@ -5555,11 +5582,12 @@ static void wm_start(struct ifnet *ifp) { struct wm_softc *sc = ifp->if_softc; + struct wm_txqueue *txq = sc->sc_txq; - WM_TX_LOCK(sc); + WM_TX_LOCK(txq); if (!sc->sc_stopping) wm_start_locked(ifp); - WM_TX_UNLOCK(sc); + WM_TX_UNLOCK(txq); } static void @@ -5577,7 +5605,7 @@ wm_start_locked(struct ifnet *ifp) uint32_t cksumcmd; uint8_t cksumfields; - KASSERT(WM_TX_LOCKED(sc)); + KASSERT(WM_TX_LOCKED(txq)); if ((ifp->if_flags & (IFF_RUNNING|IFF_OACTIVE)) != IFF_RUNNING) return; @@ -6073,11 +6101,12 @@ static void wm_nq_start(struct ifnet *ifp) { struct wm_softc *sc = ifp->if_softc; + struct wm_txqueue *txq = sc->sc_txq; - WM_TX_LOCK(sc); + WM_TX_LOCK(txq); if (!sc->sc_stopping) wm_nq_start_locked(ifp); - WM_TX_UNLOCK(sc); + WM_TX_UNLOCK(txq); } static void @@ -6092,7 +6121,7 @@ wm_nq_start_locked(struct ifnet *ifp) int error, nexttx, lasttx = -1, seg, segs_needed; bool do_csum, sent; - KASSERT(WM_TX_LOCKED(sc)); + KASSERT(WM_TX_LOCKED(txq)); if ((ifp->if_flags & (IFF_RUNNING|IFF_OACTIVE)) != IFF_RUNNING) return; @@ -6648,7 +6677,7 @@ wm_rxeof(struct wm_softc *sc) ifp->if_ipackets++; - WM_RX_UNLOCK(sc); + WM_RX_UNLOCK(rxq); /* Pass this up to any BPF listeners. */ bpf_mtap(ifp, m); @@ -6656,7 +6685,7 @@ wm_rxeof(struct wm_softc *sc) /* Pass it on. */ (*ifp->if_input)(ifp, m); - WM_RX_LOCK(sc); + WM_RX_LOCK(rxq); if (sc->sc_stopping) break; @@ -6680,7 +6709,7 @@ static void wm_linkintr_gmii(struct wm_softc *sc, uint32_t icr) { - KASSERT(WM_TX_LOCKED(sc)); + KASSERT(WM_CORE_LOCKED(sc)); DPRINTF(WM_DEBUG_LINK, ("%s: %s:\n", device_xname(sc->sc_dev), __func__)); @@ -6891,6 +6920,8 @@ static void wm_linkintr(struct wm_softc *sc, uint32_t icr) { + KASSERT(WM_CORE_LOCKED(sc)); + if (sc->sc_flags & WM_F_HAS_MII) wm_linkintr_gmii(sc, icr); else if ((sc->sc_mediatype == WM_MEDIATYPE_SERDES) @@ -6909,6 +6940,8 @@ static int wm_intr_legacy(void *arg) { struct wm_softc *sc = arg; + struct wm_txqueue *txq = sc->sc_txq; + struct wm_rxqueue *rxq = sc->sc_rxq; struct ifnet *ifp = &sc->sc_ethercom.ec_if; uint32_t icr, rndval = 0; int handled = 0; @@ -6922,10 +6955,10 @@ wm_intr_legacy(void *arg) if (rndval == 0) rndval = icr; - WM_RX_LOCK(sc); + WM_RX_LOCK(rxq); if (sc->sc_stopping) { - WM_RX_UNLOCK(sc); + WM_RX_UNLOCK(rxq); break; } @@ -6942,8 +6975,8 @@ wm_intr_legacy(void *arg) #endif wm_rxeof(sc); - WM_RX_UNLOCK(sc); - WM_TX_LOCK(sc); + WM_RX_UNLOCK(rxq); + WM_TX_LOCK(txq); #if defined(WM_DEBUG) || defined(WM_EVENT_COUNTERS) if (icr & ICR_TXDW) { @@ -6955,12 +6988,15 @@ wm_intr_legacy(void *arg) #endif wm_txeof(sc); + WM_TX_UNLOCK(txq); + WM_CORE_LOCK(sc); + if (icr & (ICR_LSC|ICR_RXSEQ)) { WM_EVCNT_INCR(&sc->sc_ev_linkintr); wm_linkintr(sc, icr); } - WM_TX_UNLOCK(sc); + WM_CORE_UNLOCK(sc); if (icr & ICR_RXO) { #if defined(WM_DEBUG) @@ -6990,6 +7026,7 @@ static int wm_txintr_msix(void *arg) { struct wm_softc *sc = arg; + struct wm_txqueue *txq = sc->sc_txq; struct ifnet *ifp = &sc->sc_ethercom.ec_if; int handled = 0; @@ -7003,7 +7040,7 @@ wm_txintr_msix(void *arg) else CSR_WRITE(sc, WMREG_EIMC, 1 << WM_MSIX_TXINTR_IDX); - WM_TX_LOCK(sc); + WM_TX_LOCK(txq); if (sc->sc_stopping) goto out; @@ -7012,7 +7049,7 @@ wm_txintr_msix(void *arg) handled = wm_txeof(sc); out: - WM_TX_UNLOCK(sc); + WM_TX_UNLOCK(txq); if (sc->sc_type == WM_T_82574) CSR_WRITE(sc, WMREG_IMS, ICR_TXQ0); /* 82574 only */ @@ -7038,6 +7075,7 @@ static int wm_rxintr_msix(void *arg) { struct wm_softc *sc = arg; + struct wm_rxqueue *rxq = sc->sc_rxq; DPRINTF(WM_DEBUG_TX, ("%s: RX: got Rx intr\n", device_xname(sc->sc_dev))); @@ -7049,7 +7087,7 @@ wm_rxintr_msix(void *arg) else CSR_WRITE(sc, WMREG_EIMC, 1 << WM_MSIX_RXINTR_IDX); - WM_RX_LOCK(sc); + WM_RX_LOCK(rxq); if (sc->sc_stopping) goto out; @@ -7058,7 +7096,7 @@ wm_rxintr_msix(void *arg) wm_rxeof(sc); out: - WM_RX_UNLOCK(sc); + WM_RX_UNLOCK(rxq); if (sc->sc_type == WM_T_82574) CSR_WRITE(sc, WMREG_IMS, ICR_RXQ0); @@ -7085,7 +7123,7 @@ wm_linkintr_msix(void *arg) ("%s: LINK: got link intr\n", device_xname(sc->sc_dev))); reg = CSR_READ(sc, WMREG_ICR); - WM_TX_LOCK(sc); + WM_CORE_LOCK(sc); if ((sc->sc_stopping) || ((reg & ICR_LSC) == 0)) goto out; @@ -7093,7 +7131,7 @@ wm_linkintr_msix(void *arg) wm_linkintr(sc, ICR_LSC); out: - WM_TX_UNLOCK(sc); + WM_CORE_UNLOCK(sc); if (sc->sc_type == WM_T_82574) CSR_WRITE(sc, WMREG_IMS, ICR_OTHER | ICR_LSC); /* 82574 only */ @@ -8879,11 +8917,12 @@ wm_check_for_link(struct wm_softc *sc) static void wm_tbi_tick(struct wm_softc *sc) { + struct wm_txqueue *txq = sc->sc_txq; struct mii_data *mii = &sc->sc_mii; struct ifmedia_entry *ife = mii->mii_media.ifm_cur; uint32_t status; - KASSERT(WM_TX_LOCKED(sc)); + KASSERT(WM_TX_LOCKED(txq)); status = CSR_READ(sc, WMREG_STATUS); @@ -9086,12 +9125,13 @@ setled: static void wm_serdes_tick(struct wm_softc *sc) { + struct wm_txqueue *txq = sc->sc_txq; struct ifnet *ifp = &sc->sc_ethercom.ec_if; struct mii_data *mii = &sc->sc_mii; struct ifmedia_entry *ife = mii->mii_media.ifm_cur; uint32_t reg; - KASSERT(WM_TX_LOCKED(sc)); + KASSERT(WM_TX_LOCKED(txq)); mii->mii_media_status = IFM_AVALID; mii->mii_media_active = IFM_ETHER;