thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
169b9a
From 5a0718f03d4da66682d5580e156c6cf4b8005891 Mon Sep 17 00:00:00 2001
169b9a
From: Tarun Gupta <tgupta@redhat.com>
169b9a
Date: Wed, 20 Jun 2018 18:54:23 +0200
169b9a
Subject: [PATCH 15/17] vfio/display: core & wireup
169b9a
169b9a
RH-Author: Tarun Gupta <tgupta@redhat.com>
169b9a
Message-id: <1529520865-18127-10-git-send-email-tgupta@redhat.com>
169b9a
Patchwork-id: 80918
169b9a
O-Subject: [RHEL7.6 qemu-kvm PATCH v3 09/11] vfio/display: core & wireup
169b9a
Bugzilla: 1555246
169b9a
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>
169b9a
RH-Acked-by: Gerd Hoffmann <kraxel@redhat.com>
169b9a
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
169b9a
169b9a
nfrastructure for display support.  Must be enabled
169b9a
using 'display' property.
169b9a
169b9a
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
169b9a
Reviewed By: Kirti Wankhede <kwankhede@nvidia.com>
169b9a
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
169b9a
169b9a
(cherry picked from a9994687cb9b5f72399398a0985419f4d2b95dc5)
169b9a
169b9a
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
169b9a
---
169b9a
 hw/misc/vfio.c | 40 ++++++++++++++++++++++++++++++++++++++++
169b9a
 1 file changed, 40 insertions(+)
169b9a
169b9a
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
169b9a
index 414b689..22d5cac 100644
169b9a
--- a/hw/misc/vfio.c
169b9a
+++ b/hw/misc/vfio.c
169b9a
@@ -40,6 +40,7 @@
169b9a
 #include "sysemu/kvm.h"
169b9a
 #include "sysemu/sysemu.h"
169b9a
 #include "trace.h"
169b9a
+#include "ui/console.h"
169b9a
 
169b9a
 /* #define DEBUG_VFIO */
169b9a
 #ifdef DEBUG_VFIO
169b9a
@@ -235,6 +236,7 @@ typedef struct VFIOPCIDevice {
169b9a
 #define VFIO_FEATURE_ENABLE_VGA (1 << VFIO_FEATURE_ENABLE_VGA_BIT)
169b9a
 #define VFIO_FEATURE_ENABLE_REQ_BIT 1
169b9a
 #define VFIO_FEATURE_ENABLE_REQ (1 << VFIO_FEATURE_ENABLE_REQ_BIT)
169b9a
+    OnOffAuto display;
169b9a
     int32_t bootindex;
169b9a
     uint8_t pm_cap;
169b9a
     bool has_vga;
169b9a
@@ -2760,6 +2762,33 @@ static int vfio_region_mmap(VFIORegion *region)
169b9a
     return 0;
169b9a
 }
169b9a
 
169b9a
+static int vfio_display_probe(VFIOPCIDevice *vdev)
169b9a
+{
169b9a
+    struct vfio_device_gfx_plane_info probe;
169b9a
+    int ret;
169b9a
+
169b9a
+    memset(&probe, 0, sizeof(probe));
169b9a
+    probe.argsz = sizeof(probe);
169b9a
+    probe.flags = VFIO_GFX_PLANE_TYPE_PROBE | VFIO_GFX_PLANE_TYPE_REGION;
169b9a
+    ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_QUERY_GFX_PLANE, &probe);
169b9a
+    if (ret == 0) {
169b9a
+        error_report("vfio-display: region support not implemented yet");
169b9a
+        return -1;
169b9a
+    }
169b9a
+
169b9a
+    if (vdev->display == ON_OFF_AUTO_AUTO) {
169b9a
+        /* not an error in automatic mode */
169b9a
+        return 0;
169b9a
+    }
169b9a
+
169b9a
+    error_report("vfio: device doesn't support any (known) display method");
169b9a
+    return -1;
169b9a
+}
169b9a
+
169b9a
+static void vfio_display_finalize(VFIOPCIDevice *vdev)
169b9a
+{
169b9a
+}
169b9a
+
169b9a
 static void vfio_region_exit(VFIORegion *region)
169b9a
 {
169b9a
     int i;
169b9a
@@ -4232,6 +4261,14 @@ static int vfio_initfn(PCIDevice *pdev)
169b9a
     }
169b9a
 
169b9a
     add_boot_device_path(vdev->bootindex, &pdev->qdev, NULL);
169b9a
+
169b9a
+    if (vdev->display != ON_OFF_AUTO_OFF) {
169b9a
+        ret = vfio_display_probe(vdev);
169b9a
+        if (ret) {
169b9a
+            goto out_teardown;
169b9a
+        }
169b9a
+    }
169b9a
+
169b9a
     vfio_register_err_notifier(vdev);
169b9a
     vfio_register_req_notifier(vdev);
169b9a
 
169b9a
@@ -4261,6 +4298,7 @@ static void vfio_exitfn(PCIDevice *pdev)
169b9a
         qemu_free_timer(vdev->intx.mmap_timer);
169b9a
     }
169b9a
     vfio_teardown_msi(vdev);
169b9a
+    vfio_display_finalize(vdev);
169b9a
     vfio_unmap_bars(vdev);
169b9a
     g_free(vdev->emulated_config_bits);
169b9a
     g_free(vdev->rom);
169b9a
@@ -4313,6 +4351,8 @@ static void vfio_instance_init(Object *obj)
169b9a
 static Property vfio_pci_dev_properties[] = {
169b9a
     DEFINE_PROP_PCI_HOST_DEVADDR("host", VFIOPCIDevice, host),
169b9a
     DEFINE_PROP_STRING("sysfsdev", VFIOPCIDevice, vbasedev.sysfsdev),
169b9a
+    DEFINE_PROP_ON_OFF_AUTO("display", VFIOPCIDevice,
169b9a
+                            display, ON_OFF_AUTO_AUTO),
169b9a
     DEFINE_PROP_UINT32("x-intx-mmap-timeout-ms", VFIOPCIDevice,
169b9a
                        intx.mmap_timeout, 1100),
169b9a
     DEFINE_PROP_BIT("x-vga", VFIOPCIDevice, features,
169b9a
-- 
169b9a
1.8.3.1
169b9a