diff mbox

[edk2,02/11] OvmfPkg/Virtio10Dxe: don't bind virtio-vga

Message ID 20160819124932.29711-3-lersek@redhat.com
State New
Headers show

Commit Message

Laszlo Ersek Aug. 19, 2016, 12:49 p.m. UTC
Commit 9399f68ae359 ("OvmfPkg: Virtio10Dxe: non-transitional driver for
virtio-1.0 PCI devices") created a "competition" between Virtio10Dxe and
QemuVideoDxe for virtio-vga devices. The binding order between these
drivers is unspecified, and the wrong order effectively breaks commit
94210dc95e9f ("OvmfPkg: QemuVideoDxe: add virtio-vga support").

Thus, never bind virtio-vga in Virtio10Dxe; QemuVideoDxe provides better
compatibility for guest OSes that insist on inheriting a linear
framebuffer. Users who prefer the VirtIo GPU interface at boot time should
specify virtio-gpu-pci, which is exactly virtio-vga, minus the VGA
compatibility (such as the framebuffer).

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Ref: https://tianocore.acgmultimedia.com/show_bug.cgi?id=66
Fixes: 9399f68ae359234b142c293ad1bef75f470ced30
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>

---
 OvmfPkg/Virtio10Dxe/Virtio10.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

-- 
2.9.2


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox

Patch

diff --git a/OvmfPkg/Virtio10Dxe/Virtio10.c b/OvmfPkg/Virtio10Dxe/Virtio10.c
index 06f069907753..a8a6a58c3f1d 100644
--- a/OvmfPkg/Virtio10Dxe/Virtio10.c
+++ b/OvmfPkg/Virtio10Dxe/Virtio10.c
@@ -819,25 +819,37 @@  Virtio10BindingSupported (
   Status = PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0,
                         sizeof Pci / sizeof (UINT32), &Pci);
   if (EFI_ERROR (Status)) {
     goto CloseProtocol;
   }
 
+  Status = EFI_UNSUPPORTED;
   //
   // Recognize non-transitional modern devices. Also, we'll have to parse the
   // PCI capability list, so make sure the CapabilityPtr field will be valid.
   //
   if (Pci.Hdr.VendorId == VIRTIO_VENDOR_ID &&
       Pci.Hdr.DeviceId >= 0x1040 &&
       Pci.Hdr.DeviceId <= 0x107F &&
       Pci.Hdr.RevisionID >= 0x01 &&
       Pci.Device.SubsystemID >= 0x40 &&
       (Pci.Hdr.Status & EFI_PCI_STATUS_CAPABILITY) != 0) {
-    Status = EFI_SUCCESS;
-  } else {
-    Status = EFI_UNSUPPORTED;
+    //
+    // The virtio-vga device is special. It can be driven both as a VGA device
+    // with a linear framebuffer, and through its underlying, modern,
+    // virtio-gpu-pci device, which has no linear framebuffer itself. For
+    // compatibility with guest OSes that insist on inheriting a linear
+    // framebuffer from the firmware, we should leave virtio-vga to
+    // QemuVideoDxe, and support only virtio-gpu-pci here.
+    //
+    // Both virtio-vga and virtio-gpu-pci have DeviceId 0x1050, but only the
+    // former has device class PCI_CLASS_DISPLAY_VGA.
+    //
+    if (Pci.Hdr.DeviceId != 0x1050 || !IS_PCI_VGA (&Pci)) {
+      Status = EFI_SUCCESS;
+    }
   }
 
 CloseProtocol:
   gBS->CloseProtocol (DeviceHandle, &gEfiPciIoProtocolGuid,
          This->DriverBindingHandle, DeviceHandle);