Index: sys/dev/virtio/pci/virtio_pci.c =================================================================== --- sys/dev/virtio/pci/virtio_pci.c +++ sys/dev/virtio/pci/virtio_pci.c @@ -305,21 +305,35 @@ if (pci_find_cap(dev, PCIY_MSI, NULL) != 0) sc->vtpci_flags |= VTPCI_FLAG_NO_MSI; + sc->vtpci_flags |= VTPCI_FLAG_NO_MSIX; if (pci_find_cap(dev, PCIY_MSIX, NULL) == 0) { - int table_bar; + int table_rid; + int msix_load; + + msix_load = 0; + rid = table_rid = pci_msix_table_bar(dev); + + if (table_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) + msix_load++; + } else + msix_load++; - 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 (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) + msix_load++; + } else + msix_load++; + + if (msix_load == 2) + sc->vtpci_flags &= ~VTPCI_FLAG_NO_MSIX; } - if (sc->vtpci_msix_table_res == NULL) - sc->vtpci_flags |= VTPCI_FLAG_NO_MSIX; - vtpci_reset(sc); /* Tell the host we've noticed this device. */