diff options
author | sam <sam@FreeBSD.org> | 2003-11-14 19:00:32 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2003-11-14 19:00:32 +0000 |
commit | 29f07789b1fc26f60bc1c931437f78725f1bc994 (patch) | |
tree | 0e5901939d8633065a9035209aa5138fe4ea6820 /sys/dev | |
parent | 6873e20b753b589bfb09a3e55bb3781e9889e442 (diff) | |
download | FreeBSD-src-29f07789b1fc26f60bc1c931437f78725f1bc994.zip FreeBSD-src-29f07789b1fc26f60bc1c931437f78725f1bc994.tar.gz |
Drop the driver lock around calls to if_input to avoid a LOR when
the packets are immediately returned for sending (e.g. when bridging
or packet forwarding). There are more efficient ways to do this
but for now use the least intrusive approach.
Reviewed by: imp, rwatson
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/an/if_an.c | 4 | ||||
-rw-r--r-- | sys/dev/an/if_anreg.h | 1 | ||||
-rw-r--r-- | sys/dev/bfe/if_bfe.c | 2 | ||||
-rw-r--r-- | sys/dev/dc/if_dc.c | 10 | ||||
-rw-r--r-- | sys/dev/dc/if_dcreg.h | 1 | ||||
-rw-r--r-- | sys/dev/my/if_my.c | 2 | ||||
-rw-r--r-- | sys/dev/owi/if_owi.c | 4 | ||||
-rw-r--r-- | sys/dev/owi/if_wivar.h | 2 | ||||
-rw-r--r-- | sys/dev/re/if_re.c | 4 | ||||
-rw-r--r-- | sys/dev/sf/if_sf.c | 4 | ||||
-rw-r--r-- | sys/dev/sf/if_sfreg.h | 1 | ||||
-rw-r--r-- | sys/dev/sk/if_sk.c | 6 | ||||
-rw-r--r-- | sys/dev/sk/if_skreg.h | 1 | ||||
-rw-r--r-- | sys/dev/ti/if_ti.c | 4 | ||||
-rw-r--r-- | sys/dev/ti/if_tireg.h | 1 | ||||
-rw-r--r-- | sys/dev/vr/if_vr.c | 4 | ||||
-rw-r--r-- | sys/dev/vr/if_vrreg.h | 1 | ||||
-rw-r--r-- | sys/dev/wl/if_wl.c | 4 |
18 files changed, 55 insertions, 1 deletions
diff --git a/sys/dev/an/if_an.c b/sys/dev/an/if_an.c index 15cd3e0..ec96d95 100644 --- a/sys/dev/an/if_an.c +++ b/sys/dev/an/if_an.c @@ -833,6 +833,8 @@ an_rxeof(sc) struct an_card_rx_desc an_rx_desc; u_int8_t *buf; + AN_LOCK_ASSERT(sc); + ifp = &sc->arpcom.ac_if; if (!sc->mpi350) { @@ -981,7 +983,9 @@ an_rxeof(sc) rx_frame.an_rx_signal_strength, rx_frame.an_rsvd0); #endif + AN_UNLOCK(sc); (*ifp->if_input)(ifp, m); + AN_LOCK(sc); } } else { /* MPI-350 */ diff --git a/sys/dev/an/if_anreg.h b/sys/dev/an/if_anreg.h index 86b5efa..6ed2bf9 100644 --- a/sys/dev/an/if_anreg.h +++ b/sys/dev/an/if_anreg.h @@ -502,6 +502,7 @@ struct an_softc { #define AN_LOCK(_sc) mtx_lock(&(_sc)->an_mtx) #define AN_UNLOCK(_sc) mtx_unlock(&(_sc)->an_mtx) +#define AN_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->an_mtx, MA_OWNED) void an_release_resources (device_t); int an_alloc_port (device_t, int, int); diff --git a/sys/dev/bfe/if_bfe.c b/sys/dev/bfe/if_bfe.c index 3d5a7e7..d91d416 100644 --- a/sys/dev/bfe/if_bfe.c +++ b/sys/dev/bfe/if_bfe.c @@ -1153,7 +1153,9 @@ bfe_rxeof(struct bfe_softc *sc) ifp->if_ipackets++; m->m_pkthdr.rcvif = ifp; + BFE_UNLOCK(sc); (*ifp->if_input)(ifp, m); + BFE_LOCK(sc); BFE_INC(cons, BFE_RX_LIST_CNT); } diff --git a/sys/dev/dc/if_dc.c b/sys/dev/dc/if_dc.c index dc1c1b3..45ec33f 100644 --- a/sys/dev/dc/if_dc.c +++ b/sys/dev/dc/if_dc.c @@ -2723,6 +2723,8 @@ dc_rxeof(struct dc_softc *sc) int i, total_len = 0; u_int32_t rxstat; + DC_LOCK_ASSERT(sc); + ifp = &sc->arpcom.ac_if; i = sc->dc_cdata.dc_rx_prod; @@ -2816,7 +2818,9 @@ dc_rxeof(struct dc_softc *sc) } ifp->if_ipackets++; + DC_UNLOCK(sc); (*ifp->if_input)(ifp, m); + DC_LOCK(sc); } sc->dc_cdata.dc_rx_prod = i; @@ -3069,6 +3073,7 @@ dc_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) CSR_WRITE_4(sc, DC_IMR, DC_INTRS); return; } + DC_LOCK(sc); sc->rxcycles = count; dc_rxeof(sc); dc_txeof(sc); @@ -3082,8 +3087,10 @@ dc_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) status &= (DC_ISR_RX_WATDOGTIMEO | DC_ISR_RX_NOBUF | DC_ISR_TX_NOBUF | DC_ISR_TX_IDLE | DC_ISR_TX_UNDERRUN | DC_ISR_BUS_ERR); - if (!status) + if (!status) { + DC_UNLOCK(sc); return; + } /* ack what we have */ CSR_WRITE_4(sc, DC_ISR, status); @@ -3107,6 +3114,7 @@ dc_poll(struct ifnet *ifp, enum poll_cmd cmd, int count) dc_init(sc); } } + DC_UNLOCK(sc); } #endif /* DEVICE_POLLING */ diff --git a/sys/dev/dc/if_dcreg.h b/sys/dev/dc/if_dcreg.h index 14912b5..fc77dd8 100644 --- a/sys/dev/dc/if_dcreg.h +++ b/sys/dev/dc/if_dcreg.h @@ -766,6 +766,7 @@ struct dc_softc { #define DC_LOCK(_sc) mtx_lock(&(_sc)->dc_mtx) #define DC_UNLOCK(_sc) mtx_unlock(&(_sc)->dc_mtx) +#define DC_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->dc_mtx, MA_OWNED) #define DC_TX_POLL 0x00000001 #define DC_TX_COALESCE 0x00000002 diff --git a/sys/dev/my/if_my.c b/sys/dev/my/if_my.c index b1dffa8..82b45af 100644 --- a/sys/dev/my/if_my.c +++ b/sys/dev/my/if_my.c @@ -1277,7 +1277,9 @@ my_rxeof(struct my_softc * sc) } } #endif + MY_UNLOCK(sc); (*ifp->if_input)(ifp, m); + MY_LOCK(sc); } MY_UNLOCK(sc); return; diff --git a/sys/dev/owi/if_owi.c b/sys/dev/owi/if_owi.c index 70f1941..6f3488b 100644 --- a/sys/dev/owi/if_owi.c +++ b/sys/dev/owi/if_owi.c @@ -449,6 +449,8 @@ wi_rxeof(sc) struct mbuf *m; int id; + WI_LOCK_ASSERT(sc); + ifp = &sc->arpcom.ac_if; id = CSR_READ_2(sc, WI_RX_FID); @@ -650,7 +652,9 @@ wi_rxeof(sc) #ifdef WICACHE wi_cache_store(sc, eh, m, rx_frame.wi_q_info); #endif + WI_UNLOCK(sc); (*ifp->if_input)(ifp, m); + WI_LOCK(sc); } } diff --git a/sys/dev/owi/if_wivar.h b/sys/dev/owi/if_wivar.h index 723f2ca..98f1970 100644 --- a/sys/dev/owi/if_wivar.h +++ b/sys/dev/owi/if_wivar.h @@ -171,9 +171,11 @@ struct wi_card_ident { #define ifaddr_byindex(idx) ifnet_addrs[(idx) - 1]; #define WI_LOCK(_sc, _s) s = splimp() #define WI_UNLOCK(_sc, _s) splx(s) +#define WI_LOCK_ASSERT(_sc) #else #define WI_LOCK(_sc, _s) _s = 1 #define WI_UNLOCK(_sc, _s) +#define WI_LOCK_ASSERT(_sc) #endif int owi_generic_attach(device_t); diff --git a/sys/dev/re/if_re.c b/sys/dev/re/if_re.c index c72d43b..13b1216 100644 --- a/sys/dev/re/if_re.c +++ b/sys/dev/re/if_re.c @@ -1517,6 +1517,8 @@ re_rxeof(sc) struct rl_desc *cur_rx; u_int32_t rxstat, rxvlan; + RL_LOCK_ASSERT(sc); + ifp = &sc->arpcom.ac_if; i = sc->rl_ldata.rl_rx_prodidx; @@ -1659,7 +1661,9 @@ re_rxeof(sc) if (rxvlan & RL_RDESC_VLANCTL_TAG) VLAN_INPUT_TAG(ifp, m, ntohs((rxvlan & RL_RDESC_VLANCTL_DATA)), continue); + RL_UNLOCK(sc); (*ifp->if_input)(ifp, m); + RL_LOCK(sc); } /* Flush the RX DMA ring */ diff --git a/sys/dev/sf/if_sf.c b/sys/dev/sf/if_sf.c index e1def22..254277a 100644 --- a/sys/dev/sf/if_sf.c +++ b/sys/dev/sf/if_sf.c @@ -955,6 +955,8 @@ sf_rxeof(sc) u_int32_t rxcons, rxprod; int cmpprodidx, cmpconsidx, bufprodidx; + SF_LOCK_ASSERT(sc); + ifp = &sc->arpcom.ac_if; rxcons = csr_read_4(sc, SF_CQ_CONSIDX); @@ -988,7 +990,9 @@ sf_rxeof(sc) m = m0; ifp->if_ipackets++; + SF_UNLOCK(sc); (*ifp->if_input)(ifp, m); + SF_LOCK(sc); } csr_write_4(sc, SF_CQ_CONSIDX, diff --git a/sys/dev/sf/if_sfreg.h b/sys/dev/sf/if_sfreg.h index 1975cfc..630f0b2 100644 --- a/sys/dev/sf/if_sfreg.h +++ b/sys/dev/sf/if_sfreg.h @@ -1051,6 +1051,7 @@ struct sf_softc { #define SF_LOCK(_sc) mtx_lock(&(_sc)->sf_mtx) #define SF_UNLOCK(_sc) mtx_unlock(&(_sc)->sf_mtx) +#define SF_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sf_mtx, MA_OWNED) #define SF_TIMEOUT 1000 diff --git a/sys/dev/sk/if_sk.c b/sys/dev/sk/if_sk.c index 1ef4493..3226d91 100644 --- a/sys/dev/sk/if_sk.c +++ b/sys/dev/sk/if_sk.c @@ -1839,6 +1839,7 @@ static void sk_rxeof(sc_if) struct sk_if_softc *sc_if; { + struct sk_softc *sc; struct mbuf *m; struct ifnet *ifp; struct sk_chain *cur_rx; @@ -1846,10 +1847,13 @@ sk_rxeof(sc_if) int i; u_int32_t rxstat; + sc = sc_if->sk_softc; ifp = &sc_if->arpcom.ac_if; i = sc_if->sk_cdata.sk_rx_prod; cur_rx = &sc_if->sk_cdata.sk_rx_chain[i]; + SK_LOCK_ASSERT(sc); + while(!(sc_if->sk_rdata->sk_rx_ring[i].sk_ctl & SK_RXCTL_OWN)) { cur_rx = &sc_if->sk_cdata.sk_rx_chain[i]; @@ -1891,7 +1895,9 @@ sk_rxeof(sc_if) } ifp->if_ipackets++; + SK_UNLOCK(sc); (*ifp->if_input)(ifp, m); + SK_LOCK(sc); } sc_if->sk_cdata.sk_rx_prod = i; diff --git a/sys/dev/sk/if_skreg.h b/sys/dev/sk/if_skreg.h index 7309841..8e2eb53 100644 --- a/sys/dev/sk/if_skreg.h +++ b/sys/dev/sk/if_skreg.h @@ -1423,6 +1423,7 @@ struct sk_softc { #define SK_LOCK(_sc) mtx_lock(&(_sc)->sk_mtx) #define SK_UNLOCK(_sc) mtx_unlock(&(_sc)->sk_mtx) +#define SK_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sk_mtx, MA_OWNED) #define SK_IF_LOCK(_sc) mtx_lock(&(_sc)->sk_softc->sk_mtx) #define SK_IF_UNLOCK(_sc) mtx_unlock(&(_sc)->sk_softc->sk_mtx) diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c index 4cbea9b..c5f3fc0 100644 --- a/sys/dev/ti/if_ti.c +++ b/sys/dev/ti/if_ti.c @@ -2384,6 +2384,8 @@ ti_rxeof(sc) struct ifnet *ifp; struct ti_cmd_desc cmd; + TI_LOCK_ASSERT(sc); + ifp = &sc->arpcom.ac_if; while(sc->ti_rx_saved_considx != sc->ti_return_prodidx.ti_idx) { @@ -2479,7 +2481,9 @@ ti_rxeof(sc) */ if (have_tag) VLAN_INPUT_TAG(ifp, m, vlan_tag, continue); + TI_UNLOCK(sc); (*ifp->if_input)(ifp, m); + TI_LOCK(sc); } /* Only necessary on the Tigon 1. */ diff --git a/sys/dev/ti/if_tireg.h b/sys/dev/ti/if_tireg.h index b15b28b..71d9661 100644 --- a/sys/dev/ti/if_tireg.h +++ b/sys/dev/ti/if_tireg.h @@ -1030,6 +1030,7 @@ struct ti_softc { #define TI_LOCK(_sc) mtx_lock(&(_sc)->ti_mtx) #define TI_UNLOCK(_sc) mtx_unlock(&(_sc)->ti_mtx) +#define TI_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->ti_mtx, MA_OWNED) /* * Microchip Technology 24Cxx EEPROM control bytes diff --git a/sys/dev/vr/if_vr.c b/sys/dev/vr/if_vr.c index 712bbea..1d35c3f 100644 --- a/sys/dev/vr/if_vr.c +++ b/sys/dev/vr/if_vr.c @@ -1061,6 +1061,8 @@ vr_rxeof(sc) int total_len = 0; u_int32_t rxstat; + VR_LOCK_ASSERT(sc); + ifp = &sc->arpcom.ac_if; while(!((rxstat = sc->vr_cdata.vr_rx_head->vr_ptr->vr_status) & @@ -1122,7 +1124,9 @@ vr_rxeof(sc) m = m0; ifp->if_ipackets++; + VR_UNLOCK(sc); (*ifp->if_input)(ifp, m); + VR_LOCK(sc); } return; diff --git a/sys/dev/vr/if_vrreg.h b/sys/dev/vr/if_vrreg.h index 043c3ed..2f8e810 100644 --- a/sys/dev/vr/if_vrreg.h +++ b/sys/dev/vr/if_vrreg.h @@ -475,6 +475,7 @@ struct vr_softc { #define VR_LOCK(_sc) mtx_lock(&(_sc)->vr_mtx) #define VR_UNLOCK(_sc) mtx_unlock(&(_sc)->vr_mtx) +#define VR_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->vr_mtx, MA_OWNED) /* * register space access macros diff --git a/sys/dev/wl/if_wl.c b/sys/dev/wl/if_wl.c index ecf1fa4..465a490 100644 --- a/sys/dev/wl/if_wl.c +++ b/sys/dev/wl/if_wl.c @@ -265,6 +265,7 @@ struct wl_softc{ }; #define WL_LOCK(_sc) mtx_lock(&(_sc)->wl_mtx) +#define WL_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->wl_mtx, MA_OWNED) #define WL_UNLOCK(_sc) mtx_unlock(&(_sc)->wl_mtx) static int wlprobe(device_t); @@ -1069,6 +1070,7 @@ wlread(struct wl_softc *sc, u_short fd_p) u_short mlen, len; u_short bytes_in_msg, bytes_in_mbuf, bytes; + WL_LOCK_ASSERT(sc); #ifdef WLDEBUG if (sc->wl_if.if_flags & IFF_DEBUG) @@ -1212,7 +1214,9 @@ wlread(struct wl_softc *sc, u_short fd_p) * received packet is now in a chain of mbuf's. next step is * to pass the packet upwards. */ + WL_UNLOCK(sc); (*ifp->if_input)(ifp, m); + WL_LOCK(sc); return 1; } |