diff options
author | kib <kib@FreeBSD.org> | 2013-07-09 12:55:01 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2013-07-09 12:55:01 +0000 |
commit | 7d6c97df380cf3d9b4be83e98eaddc1d3f63698d (patch) | |
tree | 3b77082738847e97b71407e7354937991a38ce9d /sys/dev/usb/controller/xhci_pci.c | |
parent | d1d4eafe81aa7108ef39c1c2096b436bd68bb70d (diff) | |
download | FreeBSD-src-7d6c97df380cf3d9b4be83e98eaddc1d3f63698d.zip FreeBSD-src-7d6c97df380cf3d9b4be83e98eaddc1d3f63698d.tar.gz |
Use MSI for xhci(4), if supported.
Reviewed by: jhb
Tested by: dchagin
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Diffstat (limited to 'sys/dev/usb/controller/xhci_pci.c')
-rw-r--r-- | sys/dev/usb/controller/xhci_pci.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/sys/dev/usb/controller/xhci_pci.c b/sys/dev/usb/controller/xhci_pci.c index 8695dac..0d897d9 100644 --- a/sys/dev/usb/controller/xhci_pci.c +++ b/sys/dev/usb/controller/xhci_pci.c @@ -146,8 +146,7 @@ static int xhci_pci_attach(device_t self) { struct xhci_softc *sc = device_get_softc(self); - int err; - int rid; + int count, err, rid; /* XXX check for 64-bit capability */ @@ -171,11 +170,21 @@ xhci_pci_attach(device_t self) usb_callout_init_mtx(&sc->sc_callout, &sc->sc_bus.bus_mtx, 0); - rid = 0; - sc->sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, &rid, - RF_SHAREABLE | RF_ACTIVE); + sc->sc_irq_rid = 0; + count = pci_msi_count(self); + if (count >= 1) { + count = 1; + if (pci_alloc_msi(self, &count) == 0) { + if (bootverbose) + device_printf(self, "MSI enabled\n"); + sc->sc_irq_rid = 1; + } + } + sc->sc_irq_res = bus_alloc_resource_any(self, SYS_RES_IRQ, + &sc->sc_irq_rid, RF_SHAREABLE | RF_ACTIVE); if (sc->sc_irq_res == NULL) { device_printf(self, "Could not allocate IRQ\n"); + goto error; } sc->sc_bus.bdev = device_add_child(self, "usbus", -1); if (sc->sc_bus.bdev == NULL) { @@ -249,7 +258,10 @@ xhci_pci_detach(device_t self) sc->sc_intr_hdl = NULL; } if (sc->sc_irq_res) { - bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res); + if (sc->sc_irq_rid == 1) + pci_release_msi(self); + bus_release_resource(self, SYS_RES_IRQ, sc->sc_irq_rid, + sc->sc_irq_res); sc->sc_irq_res = NULL; } if (sc->sc_io_res) { |