Author: rstone
Date: Thu Sep 17 17:56:23 2015
New Revision: 287926
URL: https://svnweb.freebsd.org/changeset/base/287926

Log:
  MFC r263109
  
    Add MSI support to puc(9)
  
    Add support for MSI interrupts in the puc(9) driver.  By default the driver
    will prefer MSI interrupts to legacy interrupts.  A tunable,
    hw.puc.msi_disable, has been added to force the allocation of legacy
    interrupts.
  
    Reviewed by:  jhb@
    MFC after:    2 weeks
    Sponsored by: Sandvine Inc.

Modified:
  stable/10/sys/dev/puc/puc.c
  stable/10/sys/dev/puc/puc_bfe.h
  stable/10/sys/dev/puc/puc_cfg.c
  stable/10/sys/dev/puc/puc_pccard.c
  stable/10/sys/dev/puc/puc_pci.c
  stable/10/sys/dev/puc/pucdata.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/puc/puc.c
==============================================================================
--- stable/10/sys/dev/puc/puc.c Thu Sep 17 17:45:20 2015        (r287925)
+++ stable/10/sys/dev/puc/puc.c Thu Sep 17 17:56:23 2015        (r287926)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/conf.h>
 #include <sys/malloc.h>
 #include <sys/mutex.h>
+#include <sys/sysctl.h>
 
 #include <machine/bus.h>
 #include <machine/resource.h>
@@ -70,6 +71,8 @@ const char puc_driver_name[] = "puc";
 
 static MALLOC_DEFINE(M_PUC, "PUC", "PUC driver");
 
+SYSCTL_NODE(_hw, OID_AUTO, puc, CTLFLAG_RD, 0, "puc(9) driver configuration");
+
 struct puc_bar *
 puc_get_bar(struct puc_softc *sc, int rid)
 {
@@ -324,7 +327,6 @@ puc_bfe_attach(device_t dev)
        if (bootverbose && sc->sc_ilr != 0)
                device_printf(dev, "using interrupt latch register\n");
 
-       sc->sc_irid = 0;
        sc->sc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->sc_irid,
            RF_ACTIVE|RF_SHAREABLE);
        if (sc->sc_ires != NULL) {

Modified: stable/10/sys/dev/puc/puc_bfe.h
==============================================================================
--- stable/10/sys/dev/puc/puc_bfe.h     Thu Sep 17 17:45:20 2015        
(r287925)
+++ stable/10/sys/dev/puc/puc_bfe.h     Thu Sep 17 17:56:23 2015        
(r287926)
@@ -66,6 +66,7 @@ struct puc_softc {
        int             sc_fastintr:1;
        int             sc_leaving:1;
        int             sc_polled:1;
+       int             sc_msi:1;
 
        int             sc_ilr;
 
@@ -94,4 +95,6 @@ int puc_bus_setup_intr(device_t, device_
     driver_filter_t *, driver_intr_t *, void *, void **);
 int puc_bus_teardown_intr(device_t, device_t, struct resource *, void *);
 
+SYSCTL_DECL(_hw_puc);
+
 #endif /* _DEV_PUC_BFE_H_ */

Modified: stable/10/sys/dev/puc/puc_cfg.c
==============================================================================
--- stable/10/sys/dev/puc/puc_cfg.c     Thu Sep 17 17:45:20 2015        
(r287925)
+++ stable/10/sys/dev/puc/puc_cfg.c     Thu Sep 17 17:56:23 2015        
(r287926)
@@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 #include <sys/bus.h>
 #include <sys/rman.h>
+#include <sys/sysctl.h>
 
 #include <dev/puc/puc_bus.h>
 #include <dev/puc/puc_cfg.h>

Modified: stable/10/sys/dev/puc/puc_pccard.c
==============================================================================
--- stable/10/sys/dev/puc/puc_pccard.c  Thu Sep 17 17:45:20 2015        
(r287925)
+++ stable/10/sys/dev/puc/puc_pccard.c  Thu Sep 17 17:56:23 2015        
(r287926)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/conf.h>
 #include <sys/malloc.h>
+#include <sys/sysctl.h>
 
 #include <machine/bus.h>
 #include <machine/resource.h>

Modified: stable/10/sys/dev/puc/puc_pci.c
==============================================================================
--- stable/10/sys/dev/puc/puc_pci.c     Thu Sep 17 17:45:20 2015        
(r287925)
+++ stable/10/sys/dev/puc/puc_pci.c     Thu Sep 17 17:56:23 2015        
(r287926)
@@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/bus.h>
 #include <sys/conf.h>
 #include <sys/malloc.h>
+#include <sys/sysctl.h>
 
 #include <machine/bus.h>
 #include <machine/resource.h>
@@ -78,6 +79,11 @@ __FBSDID("$FreeBSD$");
 #include <dev/puc/puc_cfg.h>
 #include <dev/puc/puc_bfe.h>
 
+static int puc_msi_disable;
+TUNABLE_INT("hw.puc.msi_disable", &puc_msi_disable);
+SYSCTL_INT(_hw_puc, OID_AUTO, msi_disable, CTLFLAG_RD | CTLFLAG_TUN,
+    &puc_msi_disable, 0, "Disable use of MSI interrupts by puc(9)");
+
 static const struct puc_cfg *
 puc_pci_match(device_t dev, const struct puc_cfg *desc)
 {
@@ -120,11 +126,56 @@ puc_pci_probe(device_t dev)
        return (puc_bfe_probe(dev, desc));
 }
 
+static int
+puc_pci_attach(device_t dev)
+{
+       struct puc_softc *sc;
+       int error, count;
+
+       sc = device_get_softc(dev);
+
+       if (!puc_msi_disable) {
+               count = 1;
+
+               if (pci_alloc_msi(dev, &count) == 0) {
+                       sc->sc_msi = 1;
+                       sc->sc_irid = 1;
+               }
+       }
+
+       error = puc_bfe_attach(dev);
+
+       if (error != 0 && sc->sc_msi)
+               pci_release_msi(dev);
+
+       return (error);
+}
+
+static int
+puc_pci_detach(device_t dev)
+{
+       struct puc_softc *sc;
+       int error;
+
+       sc = device_get_softc(dev);
+       
+       error = puc_bfe_detach(dev);
+
+       if (error != 0)
+               return (error);
+
+       if (sc->sc_msi)
+               error = pci_release_msi(dev);
+
+       return (error);
+}
+
+
 static device_method_t puc_pci_methods[] = {
     /* Device interface */
     DEVMETHOD(device_probe,            puc_pci_probe),
-    DEVMETHOD(device_attach,           puc_bfe_attach),
-    DEVMETHOD(device_detach,           puc_bfe_detach),
+    DEVMETHOD(device_attach,           puc_pci_attach),
+    DEVMETHOD(device_detach,           puc_pci_detach),
 
     DEVMETHOD(bus_alloc_resource,      puc_bus_alloc_resource),
     DEVMETHOD(bus_release_resource,    puc_bus_release_resource),

Modified: stable/10/sys/dev/puc/pucdata.c
==============================================================================
--- stable/10/sys/dev/puc/pucdata.c     Thu Sep 17 17:45:20 2015        
(r287925)
+++ stable/10/sys/dev/puc/pucdata.c     Thu Sep 17 17:56:23 2015        
(r287926)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/bus.h>
+#include <sys/sysctl.h>
 
 #include <machine/resource.h>
 #include <machine/bus.h>
_______________________________________________
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