Author: br
Date: Sat Feb  8 23:07:29 2020
New Revision: 357686
URL: https://svnweb.freebsd.org/changeset/base/357686

Log:
  Enter the network epoch in the xdma interrupt handler if required
  by a peripheral device driver.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/dev/altera/atse/if_atse.c
  head/sys/dev/flash/cqspi.c
  head/sys/dev/xdma/xdma.c
  head/sys/dev/xdma/xdma.h
  head/sys/dev/xdma/xdma_fdt_test.c
  head/sys/dev/xilinx/if_xae.c
  head/sys/mips/ingenic/jz4780_aic.c

Modified: head/sys/dev/altera/atse/if_atse.c
==============================================================================
--- head/sys/dev/altera/atse/if_atse.c  Sat Feb  8 21:59:46 2020        
(r357685)
+++ head/sys/dev/altera/atse/if_atse.c  Sat Feb  8 23:07:29 2020        
(r357686)
@@ -1293,7 +1293,8 @@ atse_attach(device_t dev)
        }
 
        /* Setup interrupt handler. */
-       error = xdma_setup_intr(sc->xchan_tx, atse_xdma_tx_intr, sc, 
&sc->ih_tx);
+       error = xdma_setup_intr(sc->xchan_tx, 0,
+           atse_xdma_tx_intr, sc, &sc->ih_tx);
        if (error) {
                device_printf(sc->dev,
                    "Can't setup xDMA interrupt handler.\n");
@@ -1324,7 +1325,8 @@ atse_attach(device_t dev)
        }
 
        /* Setup interrupt handler. */
-       error = xdma_setup_intr(sc->xchan_rx, atse_xdma_rx_intr, sc, 
&sc->ih_rx);
+       error = xdma_setup_intr(sc->xchan_rx, XDMA_INTR_NET,
+           atse_xdma_rx_intr, sc, &sc->ih_rx);
        if (error) {
                device_printf(sc->dev,
                    "Can't setup xDMA interrupt handler.\n");
@@ -1381,8 +1383,7 @@ atse_attach(device_t dev)
        }
        ifp->if_softc = sc;
        if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
-           IFF_NEEDSEPOCH;
+       ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
        ifp->if_ioctl = atse_ioctl;
        ifp->if_transmit = atse_transmit;
        ifp->if_qflush = atse_qflush;

Modified: head/sys/dev/flash/cqspi.c
==============================================================================
--- head/sys/dev/flash/cqspi.c  Sat Feb  8 21:59:46 2020        (r357685)
+++ head/sys/dev/flash/cqspi.c  Sat Feb  8 23:07:29 2020        (r357686)
@@ -705,7 +705,7 @@ cqspi_attach(device_t dev)
        }
 
        /* Setup xDMA interrupt handlers. */
-       error = xdma_setup_intr(sc->xchan_tx, cqspi_xdma_tx_intr,
+       error = xdma_setup_intr(sc->xchan_tx, 0, cqspi_xdma_tx_intr,
            sc, &sc->ih_tx);
        if (error) {
                device_printf(sc->dev,
@@ -713,7 +713,7 @@ cqspi_attach(device_t dev)
                return (ENXIO);
        }
 
-       error = xdma_setup_intr(sc->xchan_rx, cqspi_xdma_rx_intr,
+       error = xdma_setup_intr(sc->xchan_rx, 0, cqspi_xdma_rx_intr,
            sc, &sc->ih_rx);
        if (error) {
                device_printf(sc->dev,

Modified: head/sys/dev/xdma/xdma.c
==============================================================================
--- head/sys/dev/xdma/xdma.c    Sat Feb  8 21:59:46 2020        (r357685)
+++ head/sys/dev/xdma/xdma.c    Sat Feb  8 23:07:29 2020        (r357686)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/param.h>
 #include <sys/conf.h>
 #include <sys/bus.h>
+#include <sys/epoch.h>
 #include <sys/kernel.h>
 #include <sys/queue.h>
 #include <sys/kobj.h>
@@ -203,7 +204,7 @@ xdma_channel_free(xdma_channel_t *xchan)
 }
 
 int
-xdma_setup_intr(xdma_channel_t *xchan,
+xdma_setup_intr(xdma_channel_t *xchan, int flags,
     int (*cb)(void *, xdma_transfer_status_t *),
     void *arg, void **ihandler)
 {
@@ -224,6 +225,7 @@ xdma_setup_intr(xdma_channel_t *xchan,
 
        ih = malloc(sizeof(struct xdma_intr_handler),
            M_XDMA, M_WAITOK | M_ZERO);
+       ih->flags = flags;
        ih->cb = cb;
        ih->cb_user = arg;
 
@@ -325,13 +327,20 @@ xdma_callback(xdma_channel_t *xchan, xdma_transfer_sta
        struct xdma_intr_handler *ih_tmp;
        struct xdma_intr_handler *ih;
        xdma_controller_t *xdma;
+       struct epoch_tracker et;
 
        xdma = xchan->xdma;
        KASSERT(xdma != NULL, ("xdma is NULL"));
 
-       TAILQ_FOREACH_SAFE(ih, &xchan->ie_handlers, ih_next, ih_tmp)
-               if (ih->cb != NULL)
+       TAILQ_FOREACH_SAFE(ih, &xchan->ie_handlers, ih_next, ih_tmp) {
+               if (ih->cb != NULL) {
+                       if (ih->flags & XDMA_INTR_NET)
+                               NET_EPOCH_ENTER(et);
                        ih->cb(ih->cb_user, status);
+                       if (ih->flags & XDMA_INTR_NET)
+                               NET_EPOCH_EXIT(et);
+               }
+       }
 
        if (xchan->flags & XCHAN_TYPE_SG)
                xdma_queue_submit(xchan);

Modified: head/sys/dev/xdma/xdma.h
==============================================================================
--- head/sys/dev/xdma/xdma.h    Sat Feb  8 21:59:46 2020        (r357685)
+++ head/sys/dev/xdma/xdma.h    Sat Feb  8 23:07:29 2020        (r357686)
@@ -195,6 +195,8 @@ typedef struct xdma_channel xdma_channel_t;
 
 struct xdma_intr_handler {
        int             (*cb)(void *cb_user, xdma_transfer_status_t *status);
+       int             flags;
+#define        XDMA_INTR_NET   (1 << 0)
        void            *cb_user;
        TAILQ_ENTRY(xdma_intr_handler)  ih_next;
 };
@@ -275,7 +277,7 @@ uint32_t xdma_mbuf_chain_count(struct mbuf *m0);
 int xdma_control(xdma_channel_t *xchan, enum xdma_command cmd);
 
 /* Interrupt callback */
-int xdma_setup_intr(xdma_channel_t *xchan, int (*cb)(void *,
+int xdma_setup_intr(xdma_channel_t *xchan, int flags, int (*cb)(void *,
     xdma_transfer_status_t *), void *arg, void **);
 int xdma_teardown_intr(xdma_channel_t *xchan, struct xdma_intr_handler *ih);
 int xdma_teardown_all_intr(xdma_channel_t *xchan);

Modified: head/sys/dev/xdma/xdma_fdt_test.c
==============================================================================
--- head/sys/dev/xdma/xdma_fdt_test.c   Sat Feb  8 21:59:46 2020        
(r357685)
+++ head/sys/dev/xdma/xdma_fdt_test.c   Sat Feb  8 23:07:29 2020        
(r357686)
@@ -217,7 +217,7 @@ xdmatest_test(struct xdmatest_softc *sc)
        }
 
        /* Setup callback. */
-       err = xdma_setup_intr(sc->xchan, xdmatest_intr, sc, &sc->ih);
+       err = xdma_setup_intr(sc->xchan, 0, xdmatest_intr, sc, &sc->ih);
        if (err) {
                device_printf(sc->dev, "Can't setup xDMA interrupt handler.\n");
                return (-1);

Modified: head/sys/dev/xilinx/if_xae.c
==============================================================================
--- head/sys/dev/xilinx/if_xae.c        Sat Feb  8 21:59:46 2020        
(r357685)
+++ head/sys/dev/xilinx/if_xae.c        Sat Feb  8 23:07:29 2020        
(r357686)
@@ -869,7 +869,7 @@ setup_xdma(struct xae_softc *sc)
        }
 
        /* Setup interrupt handler. */
-       error = xdma_setup_intr(sc->xchan_tx,
+       error = xdma_setup_intr(sc->xchan_tx, 0,
            xae_xdma_tx_intr, sc, &sc->ih_tx);
        if (error) {
                device_printf(sc->dev,
@@ -885,7 +885,7 @@ setup_xdma(struct xae_softc *sc)
        }
 
        /* Setup interrupt handler. */
-       error = xdma_setup_intr(sc->xchan_rx,
+       error = xdma_setup_intr(sc->xchan_rx, XDMA_INTR_NET,
            xae_xdma_rx_intr, sc, &sc->ih_rx);
        if (error) {
                device_printf(sc->dev,

Modified: head/sys/mips/ingenic/jz4780_aic.c
==============================================================================
--- head/sys/mips/ingenic/jz4780_aic.c  Sat Feb  8 21:59:46 2020        
(r357685)
+++ head/sys/mips/ingenic/jz4780_aic.c  Sat Feb  8 23:07:29 2020        
(r357686)
@@ -744,7 +744,7 @@ aic_attach(device_t dev)
        pcm_setflags(dev, pcm_getflags(dev) | SD_F_MPSAFE);
 
        /* Setup interrupt handler. */
-       err = xdma_setup_intr(sc->xchan, aic_intr, scp, &sc->ih);
+       err = xdma_setup_intr(sc->xchan, 0, aic_intr, scp, &sc->ih);
        if (err) {
                device_printf(sc->dev,
                    "Can't setup xDMA interrupt handler.\n");
_______________________________________________
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