Index: sys/dev/virtio/pci/virtio_pci.c =================================================================== --- sys/dev/virtio/pci/virtio_pci.c +++ sys/dev/virtio/pci/virtio_pci.c @@ -273,6 +273,33 @@ return (BUS_PROBE_DEFAULT); } +static int +vtpci_attach_probe_msix(device_t dev, struct vtpci_softc *sc) +{ + int rid, table_rid; + + if (pci_find_cap(dev, PCIY_MSIX, NULL) != 0) + return (1); + + rid = table_rid = pci_msix_table_bar(dev); + if (rid != PCIR_BAR(0)) { + sc->vtpci_msix_table_res = bus_alloc_resource_any( + dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); + if (sc->vtpci_msix_table_res == NULL) + return (1); + } + + rid = pci_msix_pba_bar(dev); + if (rid != table_rid && rid != PCIR_BAR(0)) { + sc->vtpci_msix_pba_res = bus_alloc_resource_any( + dev, SYS_RES_MEMORY, &rid, RF_ACTIVE); + if (sc->vtpci_msix_pba_res == NULL) + return (1); + } + + return (0); +} + static int vtpci_attach(device_t dev) { @@ -305,19 +332,7 @@ if (pci_find_cap(dev, PCIY_MSI, NULL) != 0) sc->vtpci_flags |= VTPCI_FLAG_NO_MSI; - if (pci_find_cap(dev, PCIY_MSIX, NULL) == 0) { - 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_table_res == NULL) + if (vtpci_attach_probe_msix(dev, sc) != 0) sc->vtpci_flags |= VTPCI_FLAG_NO_MSIX; vtpci_reset(sc);