Page MenuHomeFreeBSD

D9123.diff
No OneTemporary

D9123.diff

Index: head/sys/dev/uart/uart_bus_pci.c
===================================================================
--- head/sys/dev/uart/uart_bus_pci.c
+++ head/sys/dev/uart/uart_bus_pci.c
@@ -45,12 +45,14 @@
#define DEFAULT_RCLK 1843200
static int uart_pci_probe(device_t dev);
+static int uart_pci_attach(device_t dev);
+static int uart_pci_detach(device_t dev);
static device_method_t uart_pci_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, uart_pci_probe),
- DEVMETHOD(device_attach, uart_bus_attach),
- DEVMETHOD(device_detach, uart_bus_detach),
+ DEVMETHOD(device_attach, uart_pci_attach),
+ DEVMETHOD(device_detach, uart_pci_detach),
DEVMETHOD(device_resume, uart_bus_resume),
DEVMETHOD_END
};
@@ -209,4 +211,40 @@
return (result);
}
+static int
+uart_pci_attach(device_t dev)
+{
+ struct uart_softc *sc;
+ int count;
+
+ sc = device_get_softc(dev);
+
+ /*
+ * Use MSI in preference to legacy IRQ if available.
+ * Whilst some PCIe UARTs support >1 MSI vector, use only the first.
+ */
+ if (pci_msi_count(dev) > 0) {
+ count = 1;
+ if (pci_alloc_msi(dev, &count) == 0) {
+ sc->sc_irid = 1;
+ device_printf(dev, "Using %d MSI message\n", count);
+ }
+ }
+
+ return (uart_bus_attach(dev));
+}
+
+static int
+uart_pci_detach(device_t dev)
+{
+ struct uart_softc *sc;
+
+ sc = device_get_softc(dev);
+
+ if (sc->sc_irid != 0)
+ pci_release_msi(dev);
+
+ return (uart_bus_detach(dev));
+}
+
DRIVER_MODULE(uart, pci, uart_pci_driver, uart_devclass, NULL, NULL);
Index: head/sys/dev/uart/uart_core.c
===================================================================
--- head/sys/dev/uart/uart_core.c
+++ head/sys/dev/uart/uart_core.c
@@ -677,7 +677,6 @@
* safest thing to do.
*/
if (filt != FILTER_SCHEDULE_THREAD && !uart_force_poll) {
- sc->sc_irid = 0;
sc->sc_ires = bus_alloc_resource_any(dev, SYS_RES_IRQ,
&sc->sc_irid, RF_ACTIVE | RF_SHAREABLE);
}

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 8, 12:31 PM (7 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29398142
Default Alt Text
D9123.diff (1 KB)

Event Timeline