Date: Thu, 13 Mar 2014 15:57:26 +0000 (UTC) From: Ryan Stone <rstone@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r263109 - head/sys/dev/puc Message-ID: <201403131557.s2DFvQKK062146@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rstone Date: Thu Mar 13 15:57:25 2014 New Revision: 263109 URL: http://svnweb.freebsd.org/changeset/base/263109 Log: 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: head/sys/dev/puc/puc.c head/sys/dev/puc/puc_bfe.h head/sys/dev/puc/puc_cfg.c head/sys/dev/puc/puc_pccard.c head/sys/dev/puc/puc_pci.c head/sys/dev/puc/pucdata.c Modified: head/sys/dev/puc/puc.c ============================================================================== --- head/sys/dev/puc/puc.c Thu Mar 13 14:34:25 2014 (r263108) +++ head/sys/dev/puc/puc.c Thu Mar 13 15:57:25 2014 (r263109) @@ -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: head/sys/dev/puc/puc_bfe.h ============================================================================== --- head/sys/dev/puc/puc_bfe.h Thu Mar 13 14:34:25 2014 (r263108) +++ head/sys/dev/puc/puc_bfe.h Thu Mar 13 15:57:25 2014 (r263109) @@ -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: head/sys/dev/puc/puc_cfg.c ============================================================================== --- head/sys/dev/puc/puc_cfg.c Thu Mar 13 14:34:25 2014 (r263108) +++ head/sys/dev/puc/puc_cfg.c Thu Mar 13 15:57:25 2014 (r263109) @@ -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: head/sys/dev/puc/puc_pccard.c ============================================================================== --- head/sys/dev/puc/puc_pccard.c Thu Mar 13 14:34:25 2014 (r263108) +++ head/sys/dev/puc/puc_pccard.c Thu Mar 13 15:57:25 2014 (r263109) @@ -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: head/sys/dev/puc/puc_pci.c ============================================================================== --- head/sys/dev/puc/puc_pci.c Thu Mar 13 14:34:25 2014 (r263108) +++ head/sys/dev/puc/puc_pci.c Thu Mar 13 15:57:25 2014 (r263109) @@ -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: head/sys/dev/puc/pucdata.c ============================================================================== --- head/sys/dev/puc/pucdata.c Thu Mar 13 14:34:25 2014 (r263108) +++ head/sys/dev/puc/pucdata.c Thu Mar 13 15:57:25 2014 (r263109) @@ -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>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403131557.s2DFvQKK062146>