Index: sys/dev/virtio/pci/virtio_pci.c =================================================================== --- sys/dev/virtio/pci/virtio_pci.c +++ sys/dev/virtio/pci/virtio_pci.c @@ -68,7 +68,8 @@ struct vtpci_softc { device_t vtpci_dev; struct resource *vtpci_res; - struct resource *vtpci_msix_res; + struct resource *vtpci_msix_table_res; + struct resource *vtpci_msix_pba_res; uint64_t vtpci_features; uint32_t vtpci_flags; #define VTPCI_FLAG_NO_MSI 0x0001 @@ -305,12 +306,18 @@ sc->vtpci_flags |= VTPCI_FLAG_NO_MSI; if (pci_find_cap(dev, PCIY_MSIX, NULL) == 0) { - rid = PCIR_BAR(1); - sc->vtpci_msix_res = bus_alloc_resource_any(dev, + int table_bar; + + rid = table_bar = pci_msix_table_bar(dev); + sc->vtpci_msix_table_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); + rid = pci_msix_pba_bar(dev); + if (rid != table_bar) + sc->vtpci_msix_pba_res = bus_alloc_resource_any(dev, + SYS_RES_MEMORY, &rid, RF_ACTIVE); } - if (sc->vtpci_msix_res == NULL) + if (sc->vtpci_msix_table_res == NULL) sc->vtpci_flags |= VTPCI_FLAG_NO_MSIX; vtpci_reset(sc); @@ -349,10 +356,18 @@ vtpci_reset(sc); - if (sc->vtpci_msix_res != NULL) { - bus_release_resource(dev, SYS_RES_MEMORY, PCIR_BAR(1), - sc->vtpci_msix_res); - sc->vtpci_msix_res = NULL; + if (sc->vtpci_msix_table_res != NULL) { + bus_release_resource(dev, SYS_RES_MEMORY, + rman_get_rid(sc->vtpci_msix_table_res), + sc->vtpci_msix_table_res); + sc->vtpci_msix_table_res = NULL; + } + + if (sc->vtpci_msix_pba_res != NULL) { + bus_release_resource(dev, SYS_RES_MEMORY, + rman_get_rid(sc->vtpci_msix_pba_res), + sc->vtpci_msix_pba_res); + sc->vtpci_msix_pba_res = NULL; } if (sc->vtpci_res != NULL) {