mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
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.
This commit is contained in:
parent
ddf06178e0
commit
9725900ba6
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=263109
|
@ -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) {
|
||||
|
|
|
@ -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_t, struct resource *, int,
|
|||
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_ */
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue