--- drivers/gpu/drm/virtio/virtgpu_drm_bus.c | 32 ++++++++++++++++++++++++++++++-- drivers/virtio/virtio_pci_common.c | 7 ++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c index 56bd4ed..33d12d5 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c +++ b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c @@ -37,6 +37,26 @@ int drm_virtio_set_busid(struct drm_device *dev, struct drm_master *master) return 0; } +static void virtio_pci_kick_out_firmware_fb(struct pci_dev *pci_dev) +{ + struct apertures_struct *ap; + bool primary; + + ap = alloc_apertures(1); + if (!ap) + return; + + ap->ranges[0].base = pci_resource_start(pci_dev, 2); + ap->ranges[0].size = pci_resource_len(pci_dev, 2); + + primary = pci_dev->resource[PCI_ROM_RESOURCE].flags + & IORESOURCE_ROM_SHADOW; + + remove_conflicting_framebuffers(ap, "virtiodrmfb", primary); + + kfree(ap); +} + int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev) { struct drm_device *dev; @@ -48,8 +68,16 @@ int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev) dev->virtdev = vdev; vdev->priv = dev; - if (strcmp(vdev->dev.parent->bus->name, "pci") == 0) - dev->pdev = to_pci_dev(vdev->dev.parent); + if (strcmp(vdev->dev.parent->bus->name, "pci") == 0) { + struct pci_dev *pdev = to_pci_dev(vdev->dev.parent); + bool vga = (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA; + + DRM_INFO("pci: %s detected\n", + vga ? "virtio-vga" : "virtio-gpu-pci"); + dev->pdev = pdev; + if (vga) + virtio_pci_kick_out_firmware_fb(pdev); + } ret = drm_dev_register(dev, 0); if (ret) diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c index e894eb2..36d82e8 100644 --- a/drivers/virtio/virtio_pci_common.c +++ b/drivers/virtio/virtio_pci_common.c @@ -510,7 +510,12 @@ static int virtio_pci_probe(struct pci_dev *pci_dev, goto err_enable_device; rc = pci_request_regions(pci_dev, "virtio-pci"); - if (rc) + /* + * virtio-vga: vesafb/efifb might hold vga framebuffer + * resource, but don't fail on that, we'll kick out vesafb + * later on. + */ + if (rc && ((pci_dev->class >> 8) != PCI_CLASS_DISPLAY_VGA)) goto err_request_regions; if (force_legacy) { -- 1.8.3.1 _______________________________________________ Virtualization mailing list Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/virtualization