Index: sys/dev/virtio/pci/virtio_pci.c =================================================================== --- sys/dev/virtio/pci/virtio_pci.c +++ sys/dev/virtio/pci/virtio_pci.c @@ -67,6 +67,7 @@ struct vtpci_softc { device_t vtpci_dev; + int vtpci_res_type; struct resource *vtpci_res; struct resource *vtpci_msix_res; uint64_t vtpci_features; @@ -285,11 +286,22 @@ pci_enable_busmaster(dev); rid = PCIR_BAR(0); + sc->vtpci_res_type = SYS_RES_IOPORT; sc->vtpci_res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, RF_ACTIVE); if (sc->vtpci_res == NULL) { - device_printf(dev, "cannot map I/O space\n"); - return (ENXIO); + /* + * We should try harder as the common configuration structure is + * possible to be in memory space. + */ + rid = PCIR_BAR(0); + sc->vtpci_res_type = SYS_RES_MEMORY; + sc->vtpci_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, + RF_ACTIVE); + if (sc->vtpci_res == NULL) { + device_printf(dev, "cannot map I/O nor memory space\n"); + return (ENXIO); + } } if (pci_find_cap(dev, PCIY_MSI, NULL) != 0) @@ -347,7 +359,7 @@ } if (sc->vtpci_res != NULL) { - bus_release_resource(dev, SYS_RES_IOPORT, PCIR_BAR(0), + bus_release_resource(dev, sc->vtpci_res_type, PCIR_BAR(0), sc->vtpci_res); sc->vtpci_res = NULL; }