From b65f813c1ab99448278961c5ca80dc422b1eae29 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Thu, 30 Jan 2020 10:28:01 +0000 Subject: [PATCH] Widen EPOCH(9) usage in PCI WLAN drivers. Make sure all occurrences of ieee80211_input_xxx() in sys/dev are covered by a network epoch section. Do not depend on the interrupt handler nor any taskqueues being in a network epoch section. This patch should unbreak the PCI WLAN drivers after r357004. Pointy hat: glebius@ Sponsored by: Mellanox Technologies --- sys/dev/bwi/if_bwi.c | 3 +++ sys/dev/bwn/if_bwn.c | 3 +++ sys/dev/ipw/if_ipw.c | 3 +++ sys/dev/iwi/if_iwi.c | 3 +++ sys/dev/iwm/if_iwm.c | 5 +++++ sys/dev/iwn/if_iwn.c | 3 +++ sys/dev/malo/if_malo.c | 3 +++ sys/dev/mwl/if_mwl.c | 4 ++++ sys/dev/ral/rt2560.c | 4 +++- sys/dev/ral/rt2661.c | 3 +++ sys/dev/ral/rt2860.c | 3 +++ sys/dev/rtwn/pci/rtwn_pci_rx.c | 5 +++++ sys/dev/wi/if_wi.c | 4 ++++ sys/dev/wpi/if_wpi.c | 3 +++ sys/dev/wtap/if_wtap.c | 8 +++++++- 15 files changed, 55 insertions(+), 2 deletions(-) diff --git a/sys/dev/bwi/if_bwi.c b/sys/dev/bwi/if_bwi.c index feb522acfc3c..2114a9ace69b 100644 --- a/sys/dev/bwi/if_bwi.c +++ b/sys/dev/bwi/if_bwi.c @@ -1506,6 +1506,7 @@ bwi_stop_locked(struct bwi_softc *sc, int statechg) void bwi_intr(void *xsc) { + struct epoch_tracker et; struct bwi_softc *sc = xsc; struct bwi_mac *mac; uint32_t intr_status; @@ -1625,7 +1626,9 @@ bwi_intr(void *xsc) device_printf(sc->sc_dev, "intr noise\n"); if (txrx_intr_status[0] & BWI_TXRX_INTR_RX) { + NET_EPOCH_ENTER(et); rx_data = sc->sc_rxeof(sc); + NET_EPOCH_EXIT(et); if (sc->sc_flags & BWI_F_STOP) { BWI_UNLOCK(sc); return; diff --git a/sys/dev/bwn/if_bwn.c b/sys/dev/bwn/if_bwn.c index 11c709b441cc..8f22de453898 100644 --- a/sys/dev/bwn/if_bwn.c +++ b/sys/dev/bwn/if_bwn.c @@ -5072,6 +5072,7 @@ bwn_intr(void *arg) static void bwn_intrtask(void *arg, int npending) { + struct epoch_tracker et; struct bwn_mac *mac = arg; struct bwn_softc *sc = mac->mac_sc; uint32_t merged = 0; @@ -5132,6 +5133,7 @@ bwn_intrtask(void *arg, int npending) if (mac->mac_reason_intr & BWN_INTR_NOISESAMPLE_OK) bwn_intr_noise(mac); + NET_EPOCH_ENTER(et); if (mac->mac_flags & BWN_MAC_FLAG_DMA) { if (mac->mac_reason[0] & BWN_DMAINTR_RX_DONE) { bwn_dma_rx(mac->mac_method.dma.rx); @@ -5139,6 +5141,7 @@ bwn_intrtask(void *arg, int npending) } } else rx = bwn_pio_rx(&mac->mac_method.pio.rx); + NET_EPOCH_EXIT(et); KASSERT(!(mac->mac_reason[1] & BWN_DMAINTR_RX_DONE), ("%s", __func__)); KASSERT(!(mac->mac_reason[2] & BWN_DMAINTR_RX_DONE), ("%s", __func__)); diff --git a/sys/dev/ipw/if_ipw.c b/sys/dev/ipw/if_ipw.c index 49150f9151bf..99587155ab34 100644 --- a/sys/dev/ipw/if_ipw.c +++ b/sys/dev/ipw/if_ipw.c @@ -1159,6 +1159,7 @@ static void ipw_rx_data_intr(struct ipw_softc *sc, struct ipw_status *status, struct ipw_soft_bd *sbd, struct ipw_soft_buf *sbuf) { + struct epoch_tracker et; struct ieee80211com *ic = &sc->sc_ic; struct mbuf *mnew, *m; struct ieee80211_node *ni; @@ -1230,11 +1231,13 @@ ipw_rx_data_intr(struct ipw_softc *sc, struct ipw_status *status, IPW_UNLOCK(sc); ni = ieee80211_find_rxnode(ic, mtod(m, struct ieee80211_frame_min *)); + NET_EPOCH_ENTER(et); if (ni != NULL) { (void) ieee80211_input(ni, m, rssi - nf, nf); ieee80211_free_node(ni); } else (void) ieee80211_input_all(ic, m, rssi - nf, nf); + NET_EPOCH_EXIT(et); IPW_LOCK(sc); bus_dmamap_sync(sc->rbd_dmat, sc->rbd_map, BUS_DMASYNC_PREWRITE); diff --git a/sys/dev/iwi/if_iwi.c b/sys/dev/iwi/if_iwi.c index ae8577888dfe..2facc93eade1 100644 --- a/sys/dev/iwi/if_iwi.c +++ b/sys/dev/iwi/if_iwi.c @@ -1181,6 +1181,7 @@ static void iwi_frame_intr(struct iwi_softc *sc, struct iwi_rx_data *data, int i, struct iwi_frame *frame) { + struct epoch_tracker et; struct ieee80211com *ic = &sc->sc_ic; struct mbuf *mnew, *m; struct ieee80211_node *ni; @@ -1270,11 +1271,13 @@ iwi_frame_intr(struct iwi_softc *sc, struct iwi_rx_data *data, int i, IWI_UNLOCK(sc); ni = ieee80211_find_rxnode(ic, mtod(m, struct ieee80211_frame_min *)); + NET_EPOCH_ENTER(et); if (ni != NULL) { type = ieee80211_input(ni, m, rssi, nf); ieee80211_free_node(ni); } else type = ieee80211_input_all(ic, m, rssi, nf); + NET_EPOCH_EXIT(et); IWI_LOCK(sc); if (sc->sc_softled) { diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c index 4538a0a38113..9237309d3f3e 100644 --- a/sys/dev/iwm/if_iwm.c +++ b/sys/dev/iwm/if_iwm.c @@ -3465,6 +3465,7 @@ static bool iwm_rx_mpdu(struct iwm_softc *sc, struct mbuf *m, uint32_t offset, bool stolen) { + struct epoch_tracker et; struct ieee80211com *ic; struct ieee80211_frame *wh; struct ieee80211_node *ni; @@ -3484,6 +3485,8 @@ iwm_rx_mpdu(struct iwm_softc *sc, struct mbuf *m, uint32_t offset, ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh); IWM_UNLOCK(sc); + + NET_EPOCH_ENTER(et); if (ni != NULL) { IWM_DPRINTF(sc, IWM_DEBUG_RECV, "input m %p\n", m); ieee80211_input_mimo(ni, m); @@ -3492,6 +3495,8 @@ iwm_rx_mpdu(struct iwm_softc *sc, struct mbuf *m, uint32_t offset, IWM_DPRINTF(sc, IWM_DEBUG_RECV, "inputall m %p\n", m); ieee80211_input_mimo_all(ic, m); } + NET_EPOCH_EXIT(et); + IWM_LOCK(sc); return true; diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c index e3b87f214ec2..7a9829ae6e47 100644 --- a/sys/dev/iwn/if_iwn.c +++ b/sys/dev/iwn/if_iwn.c @@ -3031,6 +3031,7 @@ static void iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc, struct iwn_rx_data *data) { + struct epoch_tracker et; struct iwn_ops *ops = &sc->ops; struct ieee80211com *ic = &sc->sc_ic; struct iwn_rx_ring *ring = &sc->rxq; @@ -3190,6 +3191,7 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc, } IWN_UNLOCK(sc); + NET_EPOCH_ENTER(et); /* Send the frame to the 802.11 layer. */ if (ni != NULL) { @@ -3201,6 +3203,7 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc, } else (void)ieee80211_input_all(ic, m, rssi - nf, nf); + NET_EPOCH_EXIT(et); IWN_LOCK(sc); DPRINTF(sc, IWN_DEBUG_TRACE, "->%s: end\n",__func__); diff --git a/sys/dev/malo/if_malo.c b/sys/dev/malo/if_malo.c index 4679fa9a78ef..ae21af8b4536 100644 --- a/sys/dev/malo/if_malo.c +++ b/sys/dev/malo/if_malo.c @@ -1939,6 +1939,7 @@ malo_set_channel(struct ieee80211com *ic) static void malo_rx_proc(void *arg, int npending) { + struct epoch_tracker et; struct malo_softc *sc = arg; struct ieee80211com *ic = &sc->malo_ic; struct malo_rxbuf *bf; @@ -2071,11 +2072,13 @@ malo_rx_proc(void *arg, int npending) /* dispatch */ ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh); + NET_EPOCH_ENTER(et); if (ni != NULL) { (void) ieee80211_input(ni, m, rssi, ds->nf); ieee80211_free_node(ni); } else (void) ieee80211_input_all(ic, m, rssi, ds->nf); + NET_EPOCH_EXIT(et); rx_next: /* NB: ignore ENOMEM so we process more descriptors */ (void) malo_rxbuf_init(sc, bf); diff --git a/sys/dev/mwl/if_mwl.c b/sys/dev/mwl/if_mwl.c index a33e49324968..6e8e560ba663 100644 --- a/sys/dev/mwl/if_mwl.c +++ b/sys/dev/mwl/if_mwl.c @@ -2608,6 +2608,7 @@ cvtrssi(uint8_t ssi) static void mwl_rx_proc(void *arg, int npending) { + struct epoch_tracker et; struct mwl_softc *sc = arg; struct ieee80211com *ic = &sc->sc_ic; struct mwl_rxbuf *bf; @@ -2796,6 +2797,8 @@ mwl_rx_proc(void *arg, int npending) /* dispatch */ ni = ieee80211_find_rxnode(ic, (const struct ieee80211_frame_min *) wh); + + NET_EPOCH_ENTER(et); if (ni != NULL) { mn = MWL_NODE(ni); #ifdef MWL_ANT_INFO_SUPPORT @@ -2811,6 +2814,7 @@ mwl_rx_proc(void *arg, int npending) ieee80211_free_node(ni); } else (void) ieee80211_input_all(ic, m, rssi, nf); + NET_EPOCH_EXIT(et); rx_next: /* NB: ignore ENOMEM so we process more descriptors */ (void) mwl_rxbuf_init(sc, bf); diff --git a/sys/dev/ral/rt2560.c b/sys/dev/ral/rt2560.c index de520c6a475e..2c7b7e0e96cc 100644 --- a/sys/dev/ral/rt2560.c +++ b/sys/dev/ral/rt2560.c @@ -1086,6 +1086,7 @@ rt2560_prio_intr(struct rt2560_softc *sc) static void rt2560_decryption_intr(struct rt2560_softc *sc) { + struct epoch_tracker et; struct ieee80211com *ic = &sc->sc_ic; struct rt2560_rx_desc *desc; struct rt2560_rx_data *data; @@ -1196,12 +1197,13 @@ rt2560_decryption_intr(struct rt2560_softc *sc) wh = mtod(m, struct ieee80211_frame *); ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh); + NET_EPOCH_ENTER(et); if (ni != NULL) { (void) ieee80211_input(ni, m, rssi, nf); ieee80211_free_node(ni); } else (void) ieee80211_input_all(ic, m, rssi, nf); - + NET_EPOCH_EXIT(et); RAL_LOCK(sc); sc->sc_flags &= ~RT2560_F_INPUT_RUNNING; skip: desc->flags = htole32(RT2560_RX_BUSY); diff --git a/sys/dev/ral/rt2661.c b/sys/dev/ral/rt2661.c index 0ae78e8b5271..f0a984bf1c9e 100644 --- a/sys/dev/ral/rt2661.c +++ b/sys/dev/ral/rt2661.c @@ -958,6 +958,7 @@ rt2661_tx_dma_intr(struct rt2661_softc *sc, struct rt2661_tx_ring *txq) static void rt2661_rx_intr(struct rt2661_softc *sc) { + struct epoch_tracker et; struct ieee80211com *ic = &sc->sc_ic; struct rt2661_rx_desc *desc; struct rt2661_rx_data *data; @@ -1074,11 +1075,13 @@ rt2661_rx_intr(struct rt2661_softc *sc) /* send the frame to the 802.11 layer */ ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh); + NET_EPOCH_ENTER(et); if (ni != NULL) { (void) ieee80211_input(ni, m, rssi, nf); ieee80211_free_node(ni); } else (void) ieee80211_input_all(ic, m, rssi, nf); + NET_EPOCH_EXIT(et); RAL_LOCK(sc); sc->sc_flags &= ~RAL_INPUT_RUNNING; diff --git a/sys/dev/ral/rt2860.c b/sys/dev/ral/rt2860.c index a298f412f6ef..4ecab1eb3f99 100644 --- a/sys/dev/ral/rt2860.c +++ b/sys/dev/ral/rt2860.c @@ -1179,6 +1179,7 @@ rt2860_maxrssi_chain(struct rt2860_softc *sc, const struct rt2860_rxwi *rxwi) static void rt2860_rx_intr(struct rt2860_softc *sc) { + struct epoch_tracker et; struct rt2860_rx_radiotap_header *tap; struct ieee80211com *ic = &sc->sc_ic; struct ieee80211_frame *wh; @@ -1326,11 +1327,13 @@ rt2860_rx_intr(struct rt2860_softc *sc) /* send the frame to the 802.11 layer */ ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh); + NET_EPOCH_ENTER(et); if (ni != NULL) { (void)ieee80211_input(ni, m, rssi - nf, nf); ieee80211_free_node(ni); } else (void)ieee80211_input_all(ic, m, rssi - nf, nf); + NET_EPOCH_EXIT(et); RAL_LOCK(sc); diff --git a/sys/dev/rtwn/pci/rtwn_pci_rx.c b/sys/dev/rtwn/pci/rtwn_pci_rx.c index 362856c4c35a..2aaaeecaa7b4 100644 --- a/sys/dev/rtwn/pci/rtwn_pci_rx.c +++ b/sys/dev/rtwn/pci/rtwn_pci_rx.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -85,6 +86,7 @@ rtwn_pci_setup_rx_desc(struct rtwn_pci_softc *pc, static void rtwn_pci_rx_frame(struct rtwn_pci_softc *pc) { + struct epoch_tracker et; struct rtwn_softc *sc = &pc->pc_sc; struct rtwn_rx_ring *ring = &pc->rx_ring; struct rtwn_rx_stat_pci *rx_desc = &ring->desc[ring->cur]; @@ -164,12 +166,15 @@ rtwn_pci_rx_frame(struct rtwn_pci_softc *pc) /* Send the frame to the 802.11 layer. */ RTWN_UNLOCK(sc); + + NET_EPOCH_ENTER(et); if (ni != NULL) { (void)ieee80211_input_mimo(ni, m); /* Node is no longer needed. */ ieee80211_free_node(ni); } else (void)ieee80211_input_mimo_all(ic, m); + NET_EPOCH_EXIT(et); RTWN_LOCK(sc); diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c index 5a8e875430fe..2b73cb08ac4b 100644 --- a/sys/dev/wi/if_wi.c +++ b/sys/dev/wi/if_wi.c @@ -1254,6 +1254,7 @@ wi_sync_bssid(struct wi_softc *sc, u_int8_t new_bssid[IEEE80211_ADDR_LEN]) static __noinline void wi_rx_intr(struct wi_softc *sc) { + struct epoch_tracker et; struct ieee80211com *ic = &sc->sc_ic; struct wi_frame frmhdr; struct mbuf *m; @@ -1349,11 +1350,14 @@ wi_rx_intr(struct wi_softc *sc) WI_UNLOCK(sc); ni = ieee80211_find_rxnode(ic, mtod(m, struct ieee80211_frame_min *)); + + NET_EPOCH_ENTER(et); if (ni != NULL) { (void) ieee80211_input(ni, m, rssi, nf); ieee80211_free_node(ni); } else (void) ieee80211_input_all(ic, m, rssi, nf); + NET_EPOCH_EXIT(et); WI_LOCK(sc); } diff --git a/sys/dev/wpi/if_wpi.c b/sys/dev/wpi/if_wpi.c index b1198c96bbcf..dd8b17c8d21c 100644 --- a/sys/dev/wpi/if_wpi.c +++ b/sys/dev/wpi/if_wpi.c @@ -1909,6 +1909,7 @@ static void wpi_rx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc, struct wpi_rx_data *data) { + struct epoch_tracker et; struct ieee80211com *ic = &sc->sc_ic; struct wpi_rx_ring *ring = &sc->rxq; struct wpi_rx_stat *stat; @@ -2028,6 +2029,7 @@ wpi_rx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc, } WPI_UNLOCK(sc); + NET_EPOCH_ENTER(et); /* Send the frame to the 802.11 layer. */ if (ni != NULL) { @@ -2037,6 +2039,7 @@ wpi_rx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc, } else (void)ieee80211_input_all(ic, m, stat->rssi, WPI_RSSI_OFFSET); + NET_EPOCH_EXIT(et); WPI_LOCK(sc); return; diff --git a/sys/dev/wtap/if_wtap.c b/sys/dev/wtap/if_wtap.c index fe0a610c6058..3244c67213d8 100644 --- a/sys/dev/wtap/if_wtap.c +++ b/sys/dev/wtap/if_wtap.c @@ -451,6 +451,7 @@ wtap_inject(struct wtap_softc *sc, struct mbuf *m) void wtap_rx_deliver(struct wtap_softc *sc, struct mbuf *m) { + struct epoch_tracker et; struct ieee80211com *ic = &sc->sc_ic; struct ieee80211_node *ni; int type; @@ -472,6 +473,7 @@ wtap_rx_deliver(struct wtap_softc *sc, struct mbuf *m) */ ni = ieee80211_find_rxnode_withkey(ic, mtod(m, const struct ieee80211_frame_min *),IEEE80211_KEYIX_NONE); + NET_EPOCH_ENTER(et); if (ni != NULL) { /* * Sending station is known, dispatch directly. @@ -481,11 +483,13 @@ wtap_rx_deliver(struct wtap_softc *sc, struct mbuf *m) } else { type = ieee80211_input_all(ic, m, 1<<7, 10); } + NET_EPOCH_EXIT(et); } static void wtap_rx_proc(void *arg, int npending) { + struct epoch_tracker et; struct wtap_softc *sc = (struct wtap_softc *)arg; struct ieee80211com *ic = &sc->sc_ic; struct mbuf *m; @@ -526,6 +530,7 @@ wtap_rx_proc(void *arg, int npending) ni = ieee80211_find_rxnode_withkey(ic, mtod(m, const struct ieee80211_frame_min *), IEEE80211_KEYIX_NONE); + NET_EPOCH_ENTER(et); if (ni != NULL) { /* * Sending station is known, dispatch directly. @@ -535,7 +540,8 @@ wtap_rx_proc(void *arg, int npending) } else { type = ieee80211_input_all(ic, m, 1<<7, 10); } - + NET_EPOCH_EXIT(et); + /* The mbufs are freed by the Net80211 stack */ free(bf, M_WTAP_RXBUF); }