On Thu, 30 Jan 2020, Hans Petter Selasky wrote:

Author: hselasky
Date: Thu Jan 30 10:28:01 2020
New Revision: 357291
URL: https://svnweb.freebsd.org/changeset/base/357291

Log:
 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@

I understand your frustration at the bugs introduced by this change but the passive aggressive "pointy hat" is not appropriate. It is sufficient to note the revision.

Jeff


 Sponsored by:  Mellanox Technologies

Modified:
 head/sys/dev/bwi/if_bwi.c
 head/sys/dev/bwn/if_bwn.c
 head/sys/dev/ipw/if_ipw.c
 head/sys/dev/iwi/if_iwi.c
 head/sys/dev/iwm/if_iwm.c
 head/sys/dev/iwn/if_iwn.c
 head/sys/dev/malo/if_malo.c
 head/sys/dev/mwl/if_mwl.c
 head/sys/dev/ral/rt2560.c
 head/sys/dev/ral/rt2661.c
 head/sys/dev/ral/rt2860.c
 head/sys/dev/rtwn/pci/rtwn_pci_rx.c
 head/sys/dev/wi/if_wi.c
 head/sys/dev/wpi/if_wpi.c
 head/sys/dev/wtap/if_wtap.c

Modified: head/sys/dev/bwi/if_bwi.c
==============================================================================
--- head/sys/dev/bwi/if_bwi.c   Thu Jan 30 09:56:57 2020        (r357290)
+++ head/sys/dev/bwi/if_bwi.c   Thu Jan 30 10:28:01 2020        (r357291)
@@ -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;

Modified: head/sys/dev/bwn/if_bwn.c
==============================================================================
--- head/sys/dev/bwn/if_bwn.c   Thu Jan 30 09:56:57 2020        (r357290)
+++ head/sys/dev/bwn/if_bwn.c   Thu Jan 30 10:28:01 2020        (r357291)
@@ -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__));

Modified: head/sys/dev/ipw/if_ipw.c
==============================================================================
--- head/sys/dev/ipw/if_ipw.c   Thu Jan 30 09:56:57 2020        (r357290)
+++ head/sys/dev/ipw/if_ipw.c   Thu Jan 30 10:28:01 2020        (r357291)
@@ -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_stat

        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);

Modified: head/sys/dev/iwi/if_iwi.c
==============================================================================
--- head/sys/dev/iwi/if_iwi.c   Thu Jan 30 09:56:57 2020        (r357290)
+++ head/sys/dev/iwi/if_iwi.c   Thu Jan 30 10:28:01 2020        (r357291)
@@ -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_dat
        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) {

Modified: head/sys/dev/iwm/if_iwm.c
==============================================================================
--- head/sys/dev/iwm/if_iwm.c   Thu Jan 30 09:56:57 2020        (r357290)
+++ head/sys/dev/iwm/if_iwm.c   Thu Jan 30 10:28:01 2020        (r357291)
@@ -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, uint
        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, uint
                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;

Modified: head/sys/dev/iwn/if_iwn.c
==============================================================================
--- head/sys/dev/iwn/if_iwn.c   Thu Jan 30 09:56:57 2020        (r357290)
+++ head/sys/dev/iwn/if_iwn.c   Thu Jan 30 10:28:01 2020        (r357291)
@@ -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 *
        }

        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 *
        } 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__);

Modified: head/sys/dev/malo/if_malo.c
==============================================================================
--- head/sys/dev/malo/if_malo.c Thu Jan 30 09:56:57 2020        (r357290)
+++ head/sys/dev/malo/if_malo.c Thu Jan 30 10:28:01 2020        (r357291)
@@ -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);

Modified: head/sys/dev/mwl/if_mwl.c
==============================================================================
--- head/sys/dev/mwl/if_mwl.c   Thu Jan 30 09:56:57 2020        (r357290)
+++ head/sys/dev/mwl/if_mwl.c   Thu Jan 30 10:28:01 2020        (r357291)
@@ -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);

Modified: head/sys/dev/ral/rt2560.c
==============================================================================
--- head/sys/dev/ral/rt2560.c   Thu Jan 30 09:56:57 2020        (r357290)
+++ head/sys/dev/ral/rt2560.c   Thu Jan 30 10:28:01 2020        (r357291)
@@ -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);

Modified: head/sys/dev/ral/rt2661.c
==============================================================================
--- head/sys/dev/ral/rt2661.c   Thu Jan 30 09:56:57 2020        (r357290)
+++ head/sys/dev/ral/rt2661.c   Thu Jan 30 10:28:01 2020        (r357291)
@@ -958,6 +958,7 @@ rt2661_tx_dma_intr(struct rt2661_softc *sc, struct rt2
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;

Modified: head/sys/dev/ral/rt2860.c
==============================================================================
--- head/sys/dev/ral/rt2860.c   Thu Jan 30 09:56:57 2020        (r357290)
+++ head/sys/dev/ral/rt2860.c   Thu Jan 30 10:28:01 2020        (r357291)
@@ -1179,6 +1179,7 @@ rt2860_maxrssi_chain(struct rt2860_softc *sc, const st
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);


Modified: head/sys/dev/rtwn/pci/rtwn_pci_rx.c
==============================================================================
--- head/sys/dev/rtwn/pci/rtwn_pci_rx.c Thu Jan 30 09:56:57 2020        
(r357290)
+++ head/sys/dev/rtwn/pci/rtwn_pci_rx.c Thu Jan 30 10:28:01 2020        
(r357291)
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/taskqueue.h>
#include <sys/bus.h>
#include <sys/endian.h>
+#include <sys/epoch.h>

#include <machine/bus.h>
#include <machine/resource.h>
@@ -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);


Modified: head/sys/dev/wi/if_wi.c
==============================================================================
--- head/sys/dev/wi/if_wi.c     Thu Jan 30 09:56:57 2020        (r357290)
+++ head/sys/dev/wi/if_wi.c     Thu Jan 30 10:28:01 2020        (r357291)
@@ -1254,6 +1254,7 @@ wi_sync_bssid(struct wi_softc *sc, u_int8_t new_bssid[
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);
}

Modified: head/sys/dev/wpi/if_wpi.c
==============================================================================
--- head/sys/dev/wpi/if_wpi.c   Thu Jan 30 09:56:57 2020        (r357290)
+++ head/sys/dev/wpi/if_wpi.c   Thu Jan 30 10:28:01 2020        (r357291)
@@ -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 *
        }

        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 *
        } else
                (void)ieee80211_input_all(ic, m, stat->rssi, WPI_RSSI_OFFSET);

+       NET_EPOCH_EXIT(et);
        WPI_LOCK(sc);

        return;

Modified: head/sys/dev/wtap/if_wtap.c
==============================================================================
--- head/sys/dev/wtap/if_wtap.c Thu Jan 30 09:56:57 2020        (r357290)
+++ head/sys/dev/wtap/if_wtap.c Thu Jan 30 10:28:01 2020        (r357291)
@@ -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);
        }

_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to