All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/15] virtio-gpu: split into two devices.
@ 2021-03-19 11:21 Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 01/15] virtio-gpu: rename virgl source file Gerd Hoffmann
                   ` (16 more replies)
  0 siblings, 17 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-19 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, vivek.kasireddy, tina.zhang

Currently we have one virtio-gpu device.  Problem with this approach is
that if you compile a full-featured qemu you'll get a virtio-gpu device
which depends on opengl and virgl, so these dependencies must be
installed and the libraries will be loaded into memory even if you don't
use virgl.  Also the code is cluttered with #ifdefs and a bit messy.

This patch series splits the virtio-gpu device into two:

 (1) virtio-gpu-device becomes the non-virgl device, same as
     virtio-gpu-device,virgl=off today.
 (2) virtio-gpu-gl-device is the new virgl device, same as
     virtio-gpu-device,virgl=on today.

When compiling qemu without virglrenderer support virtio-gpu-device
behavior doesn't change.

Gerd Hoffmann (15):
  virtio-gpu: rename virgl source file.
  virtio-gpu: add virtio-gpu-gl-device
  virtio-gpu: add virtio-gpu-gl-pci
  virtio-gpu: add virtio-vga-gl
  virtio-gpu: move virgl realize + properties
  virtio-gpu: move virgl reset
  virtio-gpu: use class function for ctrl queue handlers
  virtio-gpu: move virgl handle_ctrl
  virtio-gpu: move virgl gl_flushed
  virtio-gpu: move virgl process_cmd
  virtio-gpu: move update_cursor_data
  virtio-gpu: drop VIRGL() macro
  virtio-gpu: move virtio-gpu-gl-device to separate module
  virtio-gpu: drop use_virgl_renderer
  virtio-gpu: move fields to struct VirtIOGPUGL

 include/hw/virtio/virtio-gpu.h                |  31 +++-
 hw/display/virtio-gpu-base.c                  |   6 +-
 hw/display/virtio-gpu-gl.c                    | 163 ++++++++++++++++++
 hw/display/virtio-gpu-pci.c                   |  27 +++
 .../{virtio-gpu-3d.c => virtio-gpu-virgl.c}   |   0
 hw/display/virtio-gpu.c                       | 142 +++------------
 hw/display/virtio-vga.c                       |  30 ++++
 util/module.c                                 |   5 +
 hw/display/meson.build                        |  11 +-
 9 files changed, 281 insertions(+), 134 deletions(-)
 create mode 100644 hw/display/virtio-gpu-gl.c
 rename hw/display/{virtio-gpu-3d.c => virtio-gpu-virgl.c} (100%)

-- 
2.30.2




^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 01/15] virtio-gpu: rename virgl source file.
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
@ 2021-03-19 11:21 ` Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 02/15] virtio-gpu: add virtio-gpu-gl-device Gerd Hoffmann
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-19 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, vivek.kasireddy, tina.zhang

"3d" -> "virgl" as 3d is a rather broad term.
Hopefully a bit less confusing.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/display/{virtio-gpu-3d.c => virtio-gpu-virgl.c} | 0
 hw/display/meson.build                             | 2 +-
 2 files changed, 1 insertion(+), 1 deletion(-)
 rename hw/display/{virtio-gpu-3d.c => virtio-gpu-virgl.c} (100%)

diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-virgl.c
similarity index 100%
rename from hw/display/virtio-gpu-3d.c
rename to hw/display/virtio-gpu-virgl.c
diff --git a/hw/display/meson.build b/hw/display/meson.build
index 9d79e3951d9e..8e465731b85b 100644
--- a/hw/display/meson.build
+++ b/hw/display/meson.build
@@ -58,7 +58,7 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
   virtio_gpu_ss.add(when: 'CONFIG_VIRTIO_GPU',
                     if_true: [files('virtio-gpu-base.c', 'virtio-gpu.c'), pixman, virgl])
   virtio_gpu_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRGL'],
-                    if_true: [files('virtio-gpu-3d.c'), pixman, virgl])
+                    if_true: [files('virtio-gpu-virgl.c'), pixman, virgl])
   virtio_gpu_ss.add(when: 'CONFIG_VHOST_USER_GPU', if_true: files('vhost-user-gpu.c'))
   hw_display_modules += {'virtio-gpu': virtio_gpu_ss}
 endif
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 02/15] virtio-gpu: add virtio-gpu-gl-device
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 01/15] virtio-gpu: rename virgl source file Gerd Hoffmann
@ 2021-03-19 11:21 ` Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 03/15] virtio-gpu: add virtio-gpu-gl-pci Gerd Hoffmann
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-19 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, vivek.kasireddy, tina.zhang

Just a skeleton for starters, following patches will add more code.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/hw/virtio/virtio-gpu.h |  7 ++++++
 hw/display/virtio-gpu-gl.c     | 41 ++++++++++++++++++++++++++++++++++
 util/module.c                  |  1 +
 hw/display/meson.build         |  2 +-
 4 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 hw/display/virtio-gpu-gl.c

diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index fae149235c58..8ee6b8fe0fb8 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -31,6 +31,9 @@ OBJECT_DECLARE_TYPE(VirtIOGPUBase, VirtIOGPUBaseClass,
 #define TYPE_VIRTIO_GPU "virtio-gpu-device"
 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPU, VIRTIO_GPU)
 
+#define TYPE_VIRTIO_GPU_GL "virtio-gpu-gl-device"
+OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUGL, VIRTIO_GPU_GL)
+
 #define TYPE_VHOST_USER_GPU "vhost-user-gpu"
 OBJECT_DECLARE_SIMPLE_TYPE(VhostUserGPU, VHOST_USER_GPU)
 
@@ -163,6 +166,10 @@ struct VirtIOGPU {
     } stats;
 };
 
+struct VirtIOGPUGL {
+    struct VirtIOGPU parent_obj;
+};
+
 struct VhostUserGPU {
     VirtIOGPUBase parent_obj;
 
diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
new file mode 100644
index 000000000000..a477cbe186d3
--- /dev/null
+++ b/hw/display/virtio-gpu-gl.c
@@ -0,0 +1,41 @@
+/*
+ * Virtio GPU Device
+ *
+ * Copyright Red Hat, Inc. 2013-2014
+ *
+ * Authors:
+ *     Dave Airlie <airlied@redhat.com>
+ *     Gerd Hoffmann <kraxel@redhat.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/iov.h"
+#include "qemu/module.h"
+#include "qemu/error-report.h"
+#include "qapi/error.h"
+#include "hw/virtio/virtio.h"
+#include "hw/virtio/virtio-gpu.h"
+#include "hw/virtio/virtio-gpu-bswap.h"
+#include "hw/virtio/virtio-gpu-pixman.h"
+#include "hw/qdev-properties.h"
+
+static void virtio_gpu_gl_class_init(ObjectClass *klass, void *data)
+{
+}
+
+static const TypeInfo virtio_gpu_gl_info = {
+    .name = TYPE_VIRTIO_GPU_GL,
+    .parent = TYPE_VIRTIO_GPU,
+    .instance_size = sizeof(VirtIOGPUGL),
+    .class_init = virtio_gpu_gl_class_init,
+};
+
+static void virtio_register_types(void)
+{
+    type_register_static(&virtio_gpu_gl_info);
+}
+
+type_init(virtio_register_types)
diff --git a/util/module.c b/util/module.c
index c65060c167df..fb80b85fe606 100644
--- a/util/module.c
+++ b/util/module.c
@@ -300,6 +300,7 @@ static struct {
     { "qxl-vga",               "hw-", "display-qxl"           },
     { "qxl",                   "hw-", "display-qxl"           },
     { "virtio-gpu-device",     "hw-", "display-virtio-gpu"    },
+    { "virtio-gpu-gl-device",  "hw-", "display-virtio-gpu"    },
     { "vhost-user-gpu",        "hw-", "display-virtio-gpu"    },
     { "virtio-gpu-pci-base",   "hw-", "display-virtio-gpu-pci" },
     { "virtio-gpu-pci",        "hw-", "display-virtio-gpu-pci" },
diff --git a/hw/display/meson.build b/hw/display/meson.build
index 8e465731b85b..5161efa08a6e 100644
--- a/hw/display/meson.build
+++ b/hw/display/meson.build
@@ -58,7 +58,7 @@ if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
   virtio_gpu_ss.add(when: 'CONFIG_VIRTIO_GPU',
                     if_true: [files('virtio-gpu-base.c', 'virtio-gpu.c'), pixman, virgl])
   virtio_gpu_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRGL'],
-                    if_true: [files('virtio-gpu-virgl.c'), pixman, virgl])
+                    if_true: [files('virtio-gpu-gl.c', 'virtio-gpu-virgl.c'), pixman, virgl])
   virtio_gpu_ss.add(when: 'CONFIG_VHOST_USER_GPU', if_true: files('vhost-user-gpu.c'))
   hw_display_modules += {'virtio-gpu': virtio_gpu_ss}
 endif
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 03/15] virtio-gpu: add virtio-gpu-gl-pci
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 01/15] virtio-gpu: rename virgl source file Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 02/15] virtio-gpu: add virtio-gpu-gl-device Gerd Hoffmann
@ 2021-03-19 11:21 ` Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 04/15] virtio-gpu: add virtio-vga-gl Gerd Hoffmann
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-19 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, vivek.kasireddy, tina.zhang

Add pci proxy for virtio-gpu-gl-device.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/display/virtio-gpu-pci.c | 27 +++++++++++++++++++++++++++
 util/module.c               |  1 +
 2 files changed, 28 insertions(+)

diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c
index d742a30aecf7..f5c685862ef7 100644
--- a/hw/display/virtio-gpu-pci.c
+++ b/hw/display/virtio-gpu-pci.c
@@ -91,10 +91,37 @@ static const VirtioPCIDeviceTypeInfo virtio_gpu_pci_info = {
     .instance_init = virtio_gpu_initfn,
 };
 
+#define TYPE_VIRTIO_GPU_GL_PCI "virtio-gpu-gl-pci"
+typedef struct VirtIOGPUGLPCI VirtIOGPUGLPCI;
+DECLARE_INSTANCE_CHECKER(VirtIOGPUGLPCI, VIRTIO_GPU_GL_PCI,
+                         TYPE_VIRTIO_GPU_GL_PCI)
+
+struct VirtIOGPUGLPCI {
+    VirtIOGPUPCIBase parent_obj;
+    VirtIOGPUGL vdev;
+};
+
+static void virtio_gpu_gl_initfn(Object *obj)
+{
+    VirtIOGPUGLPCI *dev = VIRTIO_GPU_GL_PCI(obj);
+
+    virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
+                                TYPE_VIRTIO_GPU_GL);
+    VIRTIO_GPU_PCI_BASE(obj)->vgpu = VIRTIO_GPU_BASE(&dev->vdev);
+}
+
+static const VirtioPCIDeviceTypeInfo virtio_gpu_gl_pci_info = {
+    .generic_name = TYPE_VIRTIO_GPU_GL_PCI,
+    .parent = TYPE_VIRTIO_GPU_PCI_BASE,
+    .instance_size = sizeof(VirtIOGPUGLPCI),
+    .instance_init = virtio_gpu_gl_initfn,
+};
+
 static void virtio_gpu_pci_register_types(void)
 {
     type_register_static(&virtio_gpu_pci_base_info);
     virtio_pci_types_register(&virtio_gpu_pci_info);
+    virtio_pci_types_register(&virtio_gpu_gl_pci_info);
 }
 
 type_init(virtio_gpu_pci_register_types)
diff --git a/util/module.c b/util/module.c
index fb80b85fe606..f825b071baa2 100644
--- a/util/module.c
+++ b/util/module.c
@@ -304,6 +304,7 @@ static struct {
     { "vhost-user-gpu",        "hw-", "display-virtio-gpu"    },
     { "virtio-gpu-pci-base",   "hw-", "display-virtio-gpu-pci" },
     { "virtio-gpu-pci",        "hw-", "display-virtio-gpu-pci" },
+    { "virtio-gpu-gl-pci",     "hw-", "display-virtio-gpu-pci" },
     { "vhost-user-gpu-pci",    "hw-", "display-virtio-gpu-pci" },
     { "virtio-vga-base",       "hw-", "display-virtio-vga"    },
     { "virtio-vga",            "hw-", "display-virtio-vga"    },
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 04/15] virtio-gpu: add virtio-vga-gl
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2021-03-19 11:21 ` [PATCH 03/15] virtio-gpu: add virtio-gpu-gl-pci Gerd Hoffmann
@ 2021-03-19 11:21 ` Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 05/15] virtio-gpu: move virgl realize + properties Gerd Hoffmann
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-19 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, vivek.kasireddy, tina.zhang

Add pci proxy for virtio-gpu-gl-device, with vga compatibility.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/display/virtio-vga.c | 30 ++++++++++++++++++++++++++++++
 util/module.c           |  1 +
 2 files changed, 31 insertions(+)

diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
index d3c640406152..f45ebe97d3ed 100644
--- a/hw/display/virtio-vga.c
+++ b/hw/display/virtio-vga.c
@@ -269,10 +269,40 @@ static VirtioPCIDeviceTypeInfo virtio_vga_info = {
     .instance_init = virtio_vga_inst_initfn,
 };
 
+#define TYPE_VIRTIO_VGA_GL "virtio-vga-gl"
+
+typedef struct VirtIOVGAGL VirtIOVGAGL;
+DECLARE_INSTANCE_CHECKER(VirtIOVGAGL, VIRTIO_VGA_GL,
+                         TYPE_VIRTIO_VGA_GL)
+
+struct VirtIOVGAGL {
+    VirtIOVGABase parent_obj;
+
+    VirtIOGPUGL   vdev;
+};
+
+static void virtio_vga_gl_inst_initfn(Object *obj)
+{
+    VirtIOVGAGL *dev = VIRTIO_VGA_GL(obj);
+
+    virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
+                                TYPE_VIRTIO_GPU_GL);
+    VIRTIO_VGA_BASE(dev)->vgpu = VIRTIO_GPU_BASE(&dev->vdev);
+}
+
+
+static VirtioPCIDeviceTypeInfo virtio_vga_gl_info = {
+    .generic_name  = TYPE_VIRTIO_VGA_GL,
+    .parent        = TYPE_VIRTIO_VGA_BASE,
+    .instance_size = sizeof(VirtIOVGAGL),
+    .instance_init = virtio_vga_gl_inst_initfn,
+};
+
 static void virtio_vga_register_types(void)
 {
     type_register_static(&virtio_vga_base_info);
     virtio_pci_types_register(&virtio_vga_info);
+    virtio_pci_types_register(&virtio_vga_gl_info);
 }
 
 type_init(virtio_vga_register_types)
diff --git a/util/module.c b/util/module.c
index f825b071baa2..0bbe2b25fbec 100644
--- a/util/module.c
+++ b/util/module.c
@@ -308,6 +308,7 @@ static struct {
     { "vhost-user-gpu-pci",    "hw-", "display-virtio-gpu-pci" },
     { "virtio-vga-base",       "hw-", "display-virtio-vga"    },
     { "virtio-vga",            "hw-", "display-virtio-vga"    },
+    { "virtio-vga-gl",         "hw-", "display-virtio-vga"    },
     { "vhost-user-vga",        "hw-", "display-virtio-vga"    },
     { "chardev-braille",       "chardev-", "baum"             },
     { "chardev-spicevmc",      "chardev-", "spice"            },
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 05/15] virtio-gpu: move virgl realize + properties
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2021-03-19 11:21 ` [PATCH 04/15] virtio-gpu: add virtio-vga-gl Gerd Hoffmann
@ 2021-03-19 11:21 ` Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 06/15] virtio-gpu: move virgl reset Gerd Hoffmann
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-19 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, vivek.kasireddy, tina.zhang

Move device init (realize) and properties.

Drop the virgl property, the virtio-gpu-gl-device has virgl enabled no
matter what.  Just use virtio-gpu-device instead if you don't want
enable virgl and opengl.  This simplifies the logic and reduces the test
matrix.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/hw/virtio/virtio-gpu.h |  1 +
 hw/display/virtio-gpu-gl.c     | 33 +++++++++++++++++++++++++++++++++
 hw/display/virtio-gpu.c        | 23 +----------------------
 3 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 8ee6b8fe0fb8..4c1a8faebec9 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -220,6 +220,7 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g,
 void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g,
                                     struct iovec *iov, uint32_t count);
 void virtio_gpu_process_cmdq(VirtIOGPU *g);
+void virtio_gpu_device_realize(DeviceState *qdev, Error **errp);
 
 /* virtio-gpu-3d.c */
 void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,
diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index a477cbe186d3..9b7b5f00d7e6 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -16,14 +16,47 @@
 #include "qemu/module.h"
 #include "qemu/error-report.h"
 #include "qapi/error.h"
+#include "sysemu/sysemu.h"
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/virtio-gpu.h"
 #include "hw/virtio/virtio-gpu-bswap.h"
 #include "hw/virtio/virtio-gpu-pixman.h"
 #include "hw/qdev-properties.h"
 
+static void virtio_gpu_gl_device_realize(DeviceState *qdev, Error **errp)
+{
+    VirtIOGPU *g = VIRTIO_GPU(qdev);
+
+#if defined(HOST_WORDS_BIGENDIAN)
+    error_setg(errp, "virgl is not supported on bigendian platforms");
+    return;
+#endif
+
+    if (!display_opengl) {
+        error_setg(errp, "opengl is not available");
+        return;
+    }
+
+    g->parent_obj.conf.flags |= (1 << VIRTIO_GPU_FLAG_VIRGL_ENABLED);
+    VIRTIO_GPU_BASE(g)->virtio_config.num_capsets =
+        virtio_gpu_virgl_get_num_capsets(g);
+
+    virtio_gpu_device_realize(qdev, errp);
+}
+
+static Property virtio_gpu_gl_properties[] = {
+    DEFINE_PROP_BIT("stats", VirtIOGPU, parent_obj.conf.flags,
+                    VIRTIO_GPU_FLAG_STATS_ENABLED, false),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
 static void virtio_gpu_gl_class_init(ObjectClass *klass, void *data)
 {
+    DeviceClass *dc = DEVICE_CLASS(klass);
+    VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
+
+    vdc->realize = virtio_gpu_gl_device_realize;
+    device_class_set_props(dc, virtio_gpu_gl_properties);
 }
 
 static const TypeInfo virtio_gpu_gl_info = {
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index c9f5e36fd076..2ee6ba756aba 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -1105,25 +1105,10 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size,
     return 0;
 }
 
-static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
+void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(qdev);
     VirtIOGPU *g = VIRTIO_GPU(qdev);
-    bool have_virgl;
-
-#if !defined(CONFIG_VIRGL) || defined(HOST_WORDS_BIGENDIAN)
-    have_virgl = false;
-#else
-    have_virgl = display_opengl;
-#endif
-    if (!have_virgl) {
-        g->parent_obj.conf.flags &= ~(1 << VIRTIO_GPU_FLAG_VIRGL_ENABLED);
-    } else {
-#if defined(CONFIG_VIRGL)
-        VIRTIO_GPU_BASE(g)->virtio_config.num_capsets =
-            virtio_gpu_virgl_get_num_capsets(g);
-#endif
-    }
 
     if (!virtio_gpu_base_device_realize(qdev,
                                         virtio_gpu_handle_ctrl_cb,
@@ -1235,12 +1220,6 @@ static Property virtio_gpu_properties[] = {
     VIRTIO_GPU_BASE_PROPERTIES(VirtIOGPU, parent_obj.conf),
     DEFINE_PROP_SIZE("max_hostmem", VirtIOGPU, conf_max_hostmem,
                      256 * MiB),
-#ifdef CONFIG_VIRGL
-    DEFINE_PROP_BIT("virgl", VirtIOGPU, parent_obj.conf.flags,
-                    VIRTIO_GPU_FLAG_VIRGL_ENABLED, true),
-    DEFINE_PROP_BIT("stats", VirtIOGPU, parent_obj.conf.flags,
-                    VIRTIO_GPU_FLAG_STATS_ENABLED, false),
-#endif
     DEFINE_PROP_END_OF_LIST(),
 };
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 06/15] virtio-gpu: move virgl reset
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
                   ` (4 preceding siblings ...)
  2021-03-19 11:21 ` [PATCH 05/15] virtio-gpu: move virgl realize + properties Gerd Hoffmann
@ 2021-03-19 11:21 ` Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 07/15] virtio-gpu: use class function for ctrl queue handlers Gerd Hoffmann
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-19 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, vivek.kasireddy, tina.zhang

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/hw/virtio/virtio-gpu.h |  1 +
 hw/display/virtio-gpu-gl.c     | 17 +++++++++++++++++
 hw/display/virtio-gpu.c        | 19 +------------------
 3 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 4c1a8faebec9..a7b7d78310ea 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -221,6 +221,7 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g,
                                     struct iovec *iov, uint32_t count);
 void virtio_gpu_process_cmdq(VirtIOGPU *g);
 void virtio_gpu_device_realize(DeviceState *qdev, Error **errp);
+void virtio_gpu_reset(VirtIODevice *vdev);
 
 /* virtio-gpu-3d.c */
 void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,
diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index 9b7b5f00d7e6..c3e562f835f7 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -23,6 +23,22 @@
 #include "hw/virtio/virtio-gpu-pixman.h"
 #include "hw/qdev-properties.h"
 
+static void virtio_gpu_gl_reset(VirtIODevice *vdev)
+{
+    VirtIOGPU *g = VIRTIO_GPU(vdev);
+
+    virtio_gpu_reset(vdev);
+
+    if (g->parent_obj.use_virgl_renderer) {
+        if (g->parent_obj.renderer_blocked) {
+            g->renderer_reset = true;
+        } else {
+            virtio_gpu_virgl_reset(g);
+        }
+        g->parent_obj.use_virgl_renderer = false;
+    }
+}
+
 static void virtio_gpu_gl_device_realize(DeviceState *qdev, Error **errp)
 {
     VirtIOGPU *g = VIRTIO_GPU(qdev);
@@ -56,6 +72,7 @@ static void virtio_gpu_gl_class_init(ObjectClass *klass, void *data)
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
 
     vdc->realize = virtio_gpu_gl_device_realize;
+    vdc->reset = virtio_gpu_gl_reset;
     device_class_set_props(dc, virtio_gpu_gl_properties);
 }
 
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 2ee6ba756aba..68286f75a01a 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -1126,18 +1126,12 @@ void virtio_gpu_device_realize(DeviceState *qdev, Error **errp)
     QTAILQ_INIT(&g->fenceq);
 }
 
-static void virtio_gpu_reset(VirtIODevice *vdev)
+void virtio_gpu_reset(VirtIODevice *vdev)
 {
     VirtIOGPU *g = VIRTIO_GPU(vdev);
     struct virtio_gpu_simple_resource *res, *tmp;
     struct virtio_gpu_ctrl_command *cmd;
 
-#ifdef CONFIG_VIRGL
-    if (g->parent_obj.use_virgl_renderer) {
-        virtio_gpu_virgl_reset(g);
-    }
-#endif
-
     QTAILQ_FOREACH_SAFE(res, &g->reslist, next, tmp) {
         virtio_gpu_resource_destroy(g, res);
     }
@@ -1155,17 +1149,6 @@ static void virtio_gpu_reset(VirtIODevice *vdev)
         g_free(cmd);
     }
 
-#ifdef CONFIG_VIRGL
-    if (g->parent_obj.use_virgl_renderer) {
-        if (g->parent_obj.renderer_blocked) {
-            g->renderer_reset = true;
-        } else {
-            virtio_gpu_virgl_reset(g);
-        }
-        g->parent_obj.use_virgl_renderer = false;
-    }
-#endif
-
     virtio_gpu_base_reset(VIRTIO_GPU_BASE(vdev));
 }
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 07/15] virtio-gpu: use class function for ctrl queue handlers
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
                   ` (5 preceding siblings ...)
  2021-03-19 11:21 ` [PATCH 06/15] virtio-gpu: move virgl reset Gerd Hoffmann
@ 2021-03-19 11:21 ` Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 08/15] virtio-gpu: move virgl handle_ctrl Gerd Hoffmann
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-19 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, vivek.kasireddy, tina.zhang

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/hw/virtio/virtio-gpu.h |  8 +++++++-
 hw/display/virtio-gpu.c        | 12 +++++++++---
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index a7b7d78310ea..380aa7dd6322 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -29,7 +29,7 @@ OBJECT_DECLARE_TYPE(VirtIOGPUBase, VirtIOGPUBaseClass,
                     VIRTIO_GPU_BASE)
 
 #define TYPE_VIRTIO_GPU "virtio-gpu-device"
-OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPU, VIRTIO_GPU)
+OBJECT_DECLARE_TYPE(VirtIOGPU, VirtIOGPUClass, VIRTIO_GPU)
 
 #define TYPE_VIRTIO_GPU_GL "virtio-gpu-gl-device"
 OBJECT_DECLARE_SIMPLE_TYPE(VirtIOGPUGL, VIRTIO_GPU_GL)
@@ -166,6 +166,12 @@ struct VirtIOGPU {
     } stats;
 };
 
+struct VirtIOGPUClass {
+    VirtIOGPUBaseClass parent;
+
+    void (*handle_ctrl)(VirtIODevice *vdev, VirtQueue *vq);
+};
+
 struct VirtIOGPUGL {
     struct VirtIOGPU parent_obj;
 };
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 68286f75a01a..39ef22b7c08d 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -893,7 +893,9 @@ static void virtio_gpu_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
 static void virtio_gpu_ctrl_bh(void *opaque)
 {
     VirtIOGPU *g = opaque;
-    virtio_gpu_handle_ctrl(&g->parent_obj.parent_obj, g->ctrl_vq);
+    VirtIOGPUClass *vgc = VIRTIO_GPU_GET_CLASS(g);
+
+    vgc->handle_ctrl(&g->parent_obj.parent_obj, g->ctrl_vq);
 }
 
 static void virtio_gpu_handle_cursor(VirtIODevice *vdev, VirtQueue *vq)
@@ -1210,9 +1212,12 @@ static void virtio_gpu_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
-    VirtIOGPUBaseClass *vgc = VIRTIO_GPU_BASE_CLASS(klass);
+    VirtIOGPUBaseClass *vbc = VIRTIO_GPU_BASE_CLASS(klass);
+    VirtIOGPUClass *vgc = VIRTIO_GPU_CLASS(klass);
+
+    vbc->gl_flushed = virtio_gpu_gl_flushed;
+    vgc->handle_ctrl = virtio_gpu_handle_ctrl;
 
-    vgc->gl_flushed = virtio_gpu_gl_flushed;
     vdc->realize = virtio_gpu_device_realize;
     vdc->reset = virtio_gpu_reset;
     vdc->get_config = virtio_gpu_get_config;
@@ -1226,6 +1231,7 @@ static const TypeInfo virtio_gpu_info = {
     .name = TYPE_VIRTIO_GPU,
     .parent = TYPE_VIRTIO_GPU_BASE,
     .instance_size = sizeof(VirtIOGPU),
+    .class_size = sizeof(VirtIOGPUClass),
     .class_init = virtio_gpu_class_init,
 };
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 08/15] virtio-gpu: move virgl handle_ctrl
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
                   ` (6 preceding siblings ...)
  2021-03-19 11:21 ` [PATCH 07/15] virtio-gpu: use class function for ctrl queue handlers Gerd Hoffmann
@ 2021-03-19 11:21 ` Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 09/15] virtio-gpu: move virgl gl_flushed Gerd Hoffmann
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-19 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, vivek.kasireddy, tina.zhang

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/display/virtio-gpu-gl.c | 33 +++++++++++++++++++++++++++++++++
 hw/display/virtio-gpu.c    | 13 -------------
 2 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index c3e562f835f7..6d0ce5bcd6f1 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -23,6 +23,36 @@
 #include "hw/virtio/virtio-gpu-pixman.h"
 #include "hw/qdev-properties.h"
 
+static void virtio_gpu_gl_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
+{
+    VirtIOGPU *g = VIRTIO_GPU(vdev);
+    struct virtio_gpu_ctrl_command *cmd;
+
+    if (!virtio_queue_ready(vq)) {
+        return;
+    }
+
+    if (!g->renderer_inited && g->parent_obj.use_virgl_renderer) {
+        virtio_gpu_virgl_init(g);
+        g->renderer_inited = true;
+    }
+
+    cmd = virtqueue_pop(vq, sizeof(struct virtio_gpu_ctrl_command));
+    while (cmd) {
+        cmd->vq = vq;
+        cmd->error = 0;
+        cmd->finished = false;
+        QTAILQ_INSERT_TAIL(&g->cmdq, cmd, next);
+        cmd = virtqueue_pop(vq, sizeof(struct virtio_gpu_ctrl_command));
+    }
+
+    virtio_gpu_process_cmdq(g);
+
+    if (g->parent_obj.use_virgl_renderer) {
+        virtio_gpu_virgl_fence_poll(g);
+    }
+}
+
 static void virtio_gpu_gl_reset(VirtIODevice *vdev)
 {
     VirtIOGPU *g = VIRTIO_GPU(vdev);
@@ -70,6 +100,9 @@ static void virtio_gpu_gl_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
+    VirtIOGPUClass *vgc = VIRTIO_GPU_CLASS(klass);
+
+    vgc->handle_ctrl = virtio_gpu_gl_handle_ctrl;
 
     vdc->realize = virtio_gpu_gl_device_realize;
     vdc->reset = virtio_gpu_gl_reset;
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 39ef22b7c08d..5901e09bcd81 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -865,13 +865,6 @@ static void virtio_gpu_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
         return;
     }
 
-#ifdef CONFIG_VIRGL
-    if (!g->renderer_inited && g->parent_obj.use_virgl_renderer) {
-        virtio_gpu_virgl_init(g);
-        g->renderer_inited = true;
-    }
-#endif
-
     cmd = virtqueue_pop(vq, sizeof(struct virtio_gpu_ctrl_command));
     while (cmd) {
         cmd->vq = vq;
@@ -882,12 +875,6 @@ static void virtio_gpu_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
     }
 
     virtio_gpu_process_cmdq(g);
-
-#ifdef CONFIG_VIRGL
-    if (g->parent_obj.use_virgl_renderer) {
-        virtio_gpu_virgl_fence_poll(g);
-    }
-#endif
 }
 
 static void virtio_gpu_ctrl_bh(void *opaque)
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 09/15] virtio-gpu: move virgl gl_flushed
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
                   ` (7 preceding siblings ...)
  2021-03-19 11:21 ` [PATCH 08/15] virtio-gpu: move virgl handle_ctrl Gerd Hoffmann
@ 2021-03-19 11:21 ` Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 10/15] virtio-gpu: move virgl process_cmd Gerd Hoffmann
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-19 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, vivek.kasireddy, tina.zhang

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/display/virtio-gpu-gl.c | 13 +++++++++++++
 hw/display/virtio-gpu.c    | 15 ---------------
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index 6d0ce5bcd6f1..e976fb8d04c4 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -23,6 +23,17 @@
 #include "hw/virtio/virtio-gpu-pixman.h"
 #include "hw/qdev-properties.h"
 
+static void virtio_gpu_gl_flushed(VirtIOGPUBase *b)
+{
+    VirtIOGPU *g = VIRTIO_GPU(b);
+
+    if (g->renderer_reset) {
+        g->renderer_reset = false;
+        virtio_gpu_virgl_reset(g);
+    }
+    virtio_gpu_process_cmdq(g);
+}
+
 static void virtio_gpu_gl_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
 {
     VirtIOGPU *g = VIRTIO_GPU(vdev);
@@ -100,8 +111,10 @@ static void virtio_gpu_gl_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
+    VirtIOGPUBaseClass *vbc = VIRTIO_GPU_BASE_CLASS(klass);
     VirtIOGPUClass *vgc = VIRTIO_GPU_CLASS(klass);
 
+    vbc->gl_flushed = virtio_gpu_gl_flushed;
     vgc->handle_ctrl = virtio_gpu_gl_handle_ctrl;
 
     vdc->realize = virtio_gpu_gl_device_realize;
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 5901e09bcd81..ae80519c7356 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -843,19 +843,6 @@ void virtio_gpu_process_cmdq(VirtIOGPU *g)
     g->processing_cmdq = false;
 }
 
-static void virtio_gpu_gl_flushed(VirtIOGPUBase *b)
-{
-    VirtIOGPU *g = VIRTIO_GPU(b);
-
-#ifdef CONFIG_VIRGL
-    if (g->renderer_reset) {
-        g->renderer_reset = false;
-        virtio_gpu_virgl_reset(g);
-    }
-#endif
-    virtio_gpu_process_cmdq(g);
-}
-
 static void virtio_gpu_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
 {
     VirtIOGPU *g = VIRTIO_GPU(vdev);
@@ -1199,10 +1186,8 @@ static void virtio_gpu_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
-    VirtIOGPUBaseClass *vbc = VIRTIO_GPU_BASE_CLASS(klass);
     VirtIOGPUClass *vgc = VIRTIO_GPU_CLASS(klass);
 
-    vbc->gl_flushed = virtio_gpu_gl_flushed;
     vgc->handle_ctrl = virtio_gpu_handle_ctrl;
 
     vdc->realize = virtio_gpu_device_realize;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 10/15] virtio-gpu: move virgl process_cmd
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
                   ` (8 preceding siblings ...)
  2021-03-19 11:21 ` [PATCH 09/15] virtio-gpu: move virgl gl_flushed Gerd Hoffmann
@ 2021-03-19 11:21 ` Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 11/15] virtio-gpu: move update_cursor_data Gerd Hoffmann
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-19 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, vivek.kasireddy, tina.zhang

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/hw/virtio/virtio-gpu.h |  2 ++
 hw/display/virtio-gpu-gl.c     | 11 +++++++++++
 hw/display/virtio-gpu.c        |  9 +++++----
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 380aa7dd6322..4ce39d2abb4c 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -170,6 +170,7 @@ struct VirtIOGPUClass {
     VirtIOGPUBaseClass parent;
 
     void (*handle_ctrl)(VirtIODevice *vdev, VirtQueue *vq);
+    void (*process_cmd)(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd);
 };
 
 struct VirtIOGPUGL {
@@ -228,6 +229,7 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g,
 void virtio_gpu_process_cmdq(VirtIOGPU *g);
 void virtio_gpu_device_realize(DeviceState *qdev, Error **errp);
 void virtio_gpu_reset(VirtIODevice *vdev);
+void virtio_gpu_simple_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd);
 
 /* virtio-gpu-3d.c */
 void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,
diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index e976fb8d04c4..792cc0b41256 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -23,6 +23,16 @@
 #include "hw/virtio/virtio-gpu-pixman.h"
 #include "hw/qdev-properties.h"
 
+static void virtio_gpu_gl_process_cmd(VirtIOGPU *g,
+                                      struct virtio_gpu_ctrl_command *cmd)
+{
+    if (g->parent_obj.use_virgl_renderer) {
+        virtio_gpu_virgl_process_cmd(g, cmd);
+        return;
+    }
+    virtio_gpu_simple_process_cmd(g, cmd);
+}
+
 static void virtio_gpu_gl_flushed(VirtIOGPUBase *b)
 {
     VirtIOGPU *g = VIRTIO_GPU(b);
@@ -116,6 +126,7 @@ static void virtio_gpu_gl_class_init(ObjectClass *klass, void *data)
 
     vbc->gl_flushed = virtio_gpu_gl_flushed;
     vgc->handle_ctrl = virtio_gpu_gl_handle_ctrl;
+    vgc->process_cmd = virtio_gpu_gl_process_cmd;
 
     vdc->realize = virtio_gpu_gl_device_realize;
     vdc->reset = virtio_gpu_gl_reset;
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index ae80519c7356..e61bfffa8019 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -747,8 +747,8 @@ virtio_gpu_resource_detach_backing(VirtIOGPU *g,
     virtio_gpu_cleanup_mapping(g, res);
 }
 
-static void virtio_gpu_simple_process_cmd(VirtIOGPU *g,
-                                          struct virtio_gpu_ctrl_command *cmd)
+void virtio_gpu_simple_process_cmd(VirtIOGPU *g,
+                                   struct virtio_gpu_ctrl_command *cmd)
 {
     VIRTIO_GPU_FILL_CMD(cmd->cmd_hdr);
     virtio_gpu_ctrl_hdr_bswap(&cmd->cmd_hdr);
@@ -806,6 +806,7 @@ static void virtio_gpu_handle_cursor_cb(VirtIODevice *vdev, VirtQueue *vq)
 void virtio_gpu_process_cmdq(VirtIOGPU *g)
 {
     struct virtio_gpu_ctrl_command *cmd;
+    VirtIOGPUClass *vgc = VIRTIO_GPU_GET_CLASS(g);
 
     if (g->processing_cmdq) {
         return;
@@ -819,8 +820,7 @@ void virtio_gpu_process_cmdq(VirtIOGPU *g)
         }
 
         /* process command */
-        VIRGL(g, virtio_gpu_virgl_process_cmd, virtio_gpu_simple_process_cmd,
-              g, cmd);
+        vgc->process_cmd(g, cmd);
 
         QTAILQ_REMOVE(&g->cmdq, cmd, next);
         if (virtio_gpu_stats_enabled(g->parent_obj.conf)) {
@@ -1189,6 +1189,7 @@ static void virtio_gpu_class_init(ObjectClass *klass, void *data)
     VirtIOGPUClass *vgc = VIRTIO_GPU_CLASS(klass);
 
     vgc->handle_ctrl = virtio_gpu_handle_ctrl;
+    vgc->process_cmd = virtio_gpu_simple_process_cmd;
 
     vdc->realize = virtio_gpu_device_realize;
     vdc->reset = virtio_gpu_reset;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 11/15] virtio-gpu: move update_cursor_data
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
                   ` (9 preceding siblings ...)
  2021-03-19 11:21 ` [PATCH 10/15] virtio-gpu: move virgl process_cmd Gerd Hoffmann
@ 2021-03-19 11:21 ` Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 12/15] virtio-gpu: drop VIRGL() macro Gerd Hoffmann
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-19 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, vivek.kasireddy, tina.zhang

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/hw/virtio/virtio-gpu.h |  6 ++++++
 hw/display/virtio-gpu-gl.c     | 30 +++++++++++++++++++++++++++
 hw/display/virtio-gpu.c        | 38 ++++++----------------------------
 3 files changed, 42 insertions(+), 32 deletions(-)

diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 4ce39d2abb4c..cd55c2d07090 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -171,6 +171,9 @@ struct VirtIOGPUClass {
 
     void (*handle_ctrl)(VirtIODevice *vdev, VirtQueue *vq);
     void (*process_cmd)(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd);
+    void (*update_cursor_data)(VirtIOGPU *g,
+                               struct virtio_gpu_scanout *s,
+                               uint32_t resource_id);
 };
 
 struct VirtIOGPUGL {
@@ -230,6 +233,9 @@ void virtio_gpu_process_cmdq(VirtIOGPU *g);
 void virtio_gpu_device_realize(DeviceState *qdev, Error **errp);
 void virtio_gpu_reset(VirtIODevice *vdev);
 void virtio_gpu_simple_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd);
+void virtio_gpu_update_cursor_data(VirtIOGPU *g,
+                                   struct virtio_gpu_scanout *s,
+                                   uint32_t resource_id);
 
 /* virtio-gpu-3d.c */
 void virtio_gpu_virgl_process_cmd(VirtIOGPU *g,
diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index 792cc0b41256..b4303cc5bb41 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -23,6 +23,35 @@
 #include "hw/virtio/virtio-gpu-pixman.h"
 #include "hw/qdev-properties.h"
 
+#include <virglrenderer.h>
+
+static void virtio_gpu_gl_update_cursor_data(VirtIOGPU *g,
+                                             struct virtio_gpu_scanout *s,
+                                             uint32_t resource_id)
+{
+    uint32_t width, height;
+    uint32_t pixels, *data;
+
+    if (g->parent_obj.use_virgl_renderer) {
+        data = virgl_renderer_get_cursor_data(resource_id, &width, &height);
+        if (!data) {
+            return;
+        }
+
+        if (width != s->current_cursor->width ||
+            height != s->current_cursor->height) {
+            free(data);
+            return;
+        }
+
+        pixels = s->current_cursor->width * s->current_cursor->height;
+        memcpy(s->current_cursor->data, data, pixels * sizeof(uint32_t));
+        free(data);
+        return;
+    }
+    virtio_gpu_update_cursor_data(g, s, resource_id);
+}
+
 static void virtio_gpu_gl_process_cmd(VirtIOGPU *g,
                                       struct virtio_gpu_ctrl_command *cmd)
 {
@@ -127,6 +156,7 @@ static void virtio_gpu_gl_class_init(ObjectClass *klass, void *data)
     vbc->gl_flushed = virtio_gpu_gl_flushed;
     vgc->handle_ctrl = virtio_gpu_gl_handle_ctrl;
     vgc->process_cmd = virtio_gpu_gl_process_cmd;
+    vgc->update_cursor_data = virtio_gpu_gl_update_cursor_data;
 
     vdc->realize = virtio_gpu_gl_device_realize;
     vdc->reset = virtio_gpu_gl_reset;
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index e61bfffa8019..2c0065277ffd 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -56,9 +56,9 @@ static void virtio_gpu_cleanup_mapping(VirtIOGPU *g,
     } while (0)
 #endif
 
-static void update_cursor_data_simple(VirtIOGPU *g,
-                                      struct virtio_gpu_scanout *s,
-                                      uint32_t resource_id)
+void virtio_gpu_update_cursor_data(VirtIOGPU *g,
+                                   struct virtio_gpu_scanout *s,
+                                   uint32_t resource_id)
 {
     struct virtio_gpu_simple_resource *res;
     uint32_t pixels;
@@ -79,36 +79,10 @@ static void update_cursor_data_simple(VirtIOGPU *g,
            pixels * sizeof(uint32_t));
 }
 
-#ifdef CONFIG_VIRGL
-
-static void update_cursor_data_virgl(VirtIOGPU *g,
-                                     struct virtio_gpu_scanout *s,
-                                     uint32_t resource_id)
-{
-    uint32_t width, height;
-    uint32_t pixels, *data;
-
-    data = virgl_renderer_get_cursor_data(resource_id, &width, &height);
-    if (!data) {
-        return;
-    }
-
-    if (width != s->current_cursor->width ||
-        height != s->current_cursor->height) {
-        free(data);
-        return;
-    }
-
-    pixels = s->current_cursor->width * s->current_cursor->height;
-    memcpy(s->current_cursor->data, data, pixels * sizeof(uint32_t));
-    free(data);
-}
-
-#endif
-
 static void update_cursor(VirtIOGPU *g, struct virtio_gpu_update_cursor *cursor)
 {
     struct virtio_gpu_scanout *s;
+    VirtIOGPUClass *vgc = VIRTIO_GPU_GET_CLASS(g);
     bool move = cursor->hdr.type == VIRTIO_GPU_CMD_MOVE_CURSOR;
 
     if (cursor->pos.scanout_id >= g->parent_obj.conf.max_outputs) {
@@ -131,8 +105,7 @@ static void update_cursor(VirtIOGPU *g, struct virtio_gpu_update_cursor *cursor)
         s->current_cursor->hot_y = cursor->hot_y;
 
         if (cursor->resource_id > 0) {
-            VIRGL(g, update_cursor_data_virgl, update_cursor_data_simple,
-                  g, s, cursor->resource_id);
+            vgc->update_cursor_data(g, s, cursor->resource_id);
         }
         dpy_cursor_define(s->con, s->current_cursor);
 
@@ -1190,6 +1163,7 @@ static void virtio_gpu_class_init(ObjectClass *klass, void *data)
 
     vgc->handle_ctrl = virtio_gpu_handle_ctrl;
     vgc->process_cmd = virtio_gpu_simple_process_cmd;
+    vgc->update_cursor_data = virtio_gpu_update_cursor_data;
 
     vdc->realize = virtio_gpu_device_realize;
     vdc->reset = virtio_gpu_reset;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 12/15] virtio-gpu: drop VIRGL() macro
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
                   ` (10 preceding siblings ...)
  2021-03-19 11:21 ` [PATCH 11/15] virtio-gpu: move update_cursor_data Gerd Hoffmann
@ 2021-03-19 11:21 ` Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 13/15] virtio-gpu: move virtio-gpu-gl-device to separate module Gerd Hoffmann
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-19 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, vivek.kasireddy, tina.zhang

Drops last virgl/opengl dependency from virtio-gpu-device.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/display/virtio-gpu.c | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 2c0065277ffd..34cf35127a3d 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -39,23 +39,6 @@ virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id);
 static void virtio_gpu_cleanup_mapping(VirtIOGPU *g,
                                        struct virtio_gpu_simple_resource *res);
 
-#ifdef CONFIG_VIRGL
-#include <virglrenderer.h>
-#define VIRGL(_g, _virgl, _simple, ...)                     \
-    do {                                                    \
-        if (_g->parent_obj.use_virgl_renderer) {            \
-            _virgl(__VA_ARGS__);                            \
-        } else {                                            \
-            _simple(__VA_ARGS__);                           \
-        }                                                   \
-    } while (0)
-#else
-#define VIRGL(_g, _virgl, _simple, ...)                 \
-    do {                                                \
-        _simple(__VA_ARGS__);                           \
-    } while (0)
-#endif
-
 void virtio_gpu_update_cursor_data(VirtIOGPU *g,
                                    struct virtio_gpu_scanout *s,
                                    uint32_t resource_id)
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 13/15] virtio-gpu: move virtio-gpu-gl-device to separate module
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
                   ` (11 preceding siblings ...)
  2021-03-19 11:21 ` [PATCH 12/15] virtio-gpu: drop VIRGL() macro Gerd Hoffmann
@ 2021-03-19 11:21 ` Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 14/15] virtio-gpu: drop use_virgl_renderer Gerd Hoffmann
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-19 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, vivek.kasireddy, tina.zhang

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 util/module.c          |  4 +++-
 hw/display/meson.build | 11 ++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/util/module.c b/util/module.c
index 0bbe2b25fbec..ffff98a7e751 100644
--- a/util/module.c
+++ b/util/module.c
@@ -182,6 +182,8 @@ static const struct {
     { "ui-spice-app",   "ui-spice-core" },
     { "ui-spice-app",   "chardev-spice" },
 
+    { "hw-display-virtio-gpu-gl", "hw-display-virtio-gpu" },
+
 #ifdef CONFIG_OPENGL
     { "ui-egl-headless", "ui-opengl"    },
     { "ui-gtk",          "ui-opengl"    },
@@ -300,7 +302,7 @@ static struct {
     { "qxl-vga",               "hw-", "display-qxl"           },
     { "qxl",                   "hw-", "display-qxl"           },
     { "virtio-gpu-device",     "hw-", "display-virtio-gpu"    },
-    { "virtio-gpu-gl-device",  "hw-", "display-virtio-gpu"    },
+    { "virtio-gpu-gl-device",  "hw-", "display-virtio-gpu-gl" },
     { "vhost-user-gpu",        "hw-", "display-virtio-gpu"    },
     { "virtio-gpu-pci-base",   "hw-", "display-virtio-gpu-pci" },
     { "virtio-gpu-pci",        "hw-", "display-virtio-gpu-pci" },
diff --git a/hw/display/meson.build b/hw/display/meson.build
index 5161efa08a6e..7cd5a1129812 100644
--- a/hw/display/meson.build
+++ b/hw/display/meson.build
@@ -56,13 +56,18 @@ softmmu_ss.add(when: [pixman, 'CONFIG_ATI_VGA'], if_true: files('ati.c', 'ati_2d
 if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
   virtio_gpu_ss = ss.source_set()
   virtio_gpu_ss.add(when: 'CONFIG_VIRTIO_GPU',
-                    if_true: [files('virtio-gpu-base.c', 'virtio-gpu.c'), pixman, virgl])
-  virtio_gpu_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRGL'],
-                    if_true: [files('virtio-gpu-gl.c', 'virtio-gpu-virgl.c'), pixman, virgl])
+                    if_true: [files('virtio-gpu-base.c', 'virtio-gpu.c'), pixman])
   virtio_gpu_ss.add(when: 'CONFIG_VHOST_USER_GPU', if_true: files('vhost-user-gpu.c'))
   hw_display_modules += {'virtio-gpu': virtio_gpu_ss}
 endif
 
+if config_all_devices.has_key('CONFIG_VIRTIO_GPU')
+  virtio_gpu_gl_ss = ss.source_set()
+  virtio_gpu_gl_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRGL', opengl],
+                       if_true: [files('virtio-gpu-gl.c', 'virtio-gpu-virgl.c'), pixman, virgl])
+  hw_display_modules += {'virtio-gpu-gl': virtio_gpu_gl_ss}
+endif
+
 if config_all_devices.has_key('CONFIG_VIRTIO_PCI')
   virtio_gpu_pci_ss = ss.source_set()
   virtio_gpu_pci_ss.add(when: ['CONFIG_VIRTIO_GPU', 'CONFIG_VIRTIO_PCI'],
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 14/15] virtio-gpu: drop use_virgl_renderer
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
                   ` (12 preceding siblings ...)
  2021-03-19 11:21 ` [PATCH 13/15] virtio-gpu: move virtio-gpu-gl-device to separate module Gerd Hoffmann
@ 2021-03-19 11:21 ` Gerd Hoffmann
  2021-03-19 11:21 ` [PATCH 15/15] virtio-gpu: move fields to struct VirtIOGPUGL Gerd Hoffmann
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-19 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, vivek.kasireddy, tina.zhang

Now that we have separated the gl and non-gl code flows to two different
devices there is little reason turn on and off virglrenderer usage at
runtime.  The gl code can simply use virglrenderer unconditionally.

So drop use_virgl_renderer field and just do that.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/hw/virtio/virtio-gpu.h |  1 -
 hw/display/virtio-gpu-base.c   |  6 +----
 hw/display/virtio-gpu-gl.c     | 44 ++++++++++------------------------
 3 files changed, 14 insertions(+), 37 deletions(-)

diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index cd55c2d07090..9629885c895f 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -111,7 +111,6 @@ struct VirtIOGPUBase {
     struct virtio_gpu_config virtio_config;
     const GraphicHwOps *hw_ops;
 
-    bool use_virgl_renderer;
     int renderer_blocked;
     int enable;
 
diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c
index 25f8920fdb67..afb3ee7d9afc 100644
--- a/hw/display/virtio-gpu-base.c
+++ b/hw/display/virtio-gpu-base.c
@@ -25,7 +25,6 @@ virtio_gpu_base_reset(VirtIOGPUBase *g)
     int i;
 
     g->enable = 0;
-    g->use_virgl_renderer = false;
 
     for (i = 0; i < g->conf.max_outputs; i++) {
         g->scanout[i].resource_id = 0;
@@ -162,7 +161,6 @@ virtio_gpu_base_device_realize(DeviceState *qdev,
         return false;
     }
 
-    g->use_virgl_renderer = false;
     if (virtio_gpu_virgl_enabled(g->conf)) {
         error_setg(&g->migration_blocker, "virgl is not yet migratable");
         if (migrate_add_blocker(g->migration_blocker, errp) < 0) {
@@ -218,10 +216,8 @@ static void
 virtio_gpu_base_set_features(VirtIODevice *vdev, uint64_t features)
 {
     static const uint32_t virgl = (1 << VIRTIO_GPU_F_VIRGL);
-    VirtIOGPUBase *g = VIRTIO_GPU_BASE(vdev);
 
-    g->use_virgl_renderer = ((features & virgl) == virgl);
-    trace_virtio_gpu_features(g->use_virgl_renderer);
+    trace_virtio_gpu_features(((features & virgl) == virgl));
 }
 
 static void
diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index b4303cc5bb41..1642a973549e 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -32,34 +32,20 @@ static void virtio_gpu_gl_update_cursor_data(VirtIOGPU *g,
     uint32_t width, height;
     uint32_t pixels, *data;
 
-    if (g->parent_obj.use_virgl_renderer) {
-        data = virgl_renderer_get_cursor_data(resource_id, &width, &height);
-        if (!data) {
-            return;
-        }
+    data = virgl_renderer_get_cursor_data(resource_id, &width, &height);
+    if (!data) {
+        return;
+    }
 
-        if (width != s->current_cursor->width ||
-            height != s->current_cursor->height) {
-            free(data);
-            return;
-        }
-
-        pixels = s->current_cursor->width * s->current_cursor->height;
-        memcpy(s->current_cursor->data, data, pixels * sizeof(uint32_t));
+    if (width != s->current_cursor->width ||
+        height != s->current_cursor->height) {
         free(data);
         return;
     }
-    virtio_gpu_update_cursor_data(g, s, resource_id);
-}
 
-static void virtio_gpu_gl_process_cmd(VirtIOGPU *g,
-                                      struct virtio_gpu_ctrl_command *cmd)
-{
-    if (g->parent_obj.use_virgl_renderer) {
-        virtio_gpu_virgl_process_cmd(g, cmd);
-        return;
-    }
-    virtio_gpu_simple_process_cmd(g, cmd);
+    pixels = s->current_cursor->width * s->current_cursor->height;
+    memcpy(s->current_cursor->data, data, pixels * sizeof(uint32_t));
+    free(data);
 }
 
 static void virtio_gpu_gl_flushed(VirtIOGPUBase *b)
@@ -82,7 +68,7 @@ static void virtio_gpu_gl_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
         return;
     }
 
-    if (!g->renderer_inited && g->parent_obj.use_virgl_renderer) {
+    if (!g->renderer_inited) {
         virtio_gpu_virgl_init(g);
         g->renderer_inited = true;
     }
@@ -97,10 +83,7 @@ static void virtio_gpu_gl_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
     }
 
     virtio_gpu_process_cmdq(g);
-
-    if (g->parent_obj.use_virgl_renderer) {
-        virtio_gpu_virgl_fence_poll(g);
-    }
+    virtio_gpu_virgl_fence_poll(g);
 }
 
 static void virtio_gpu_gl_reset(VirtIODevice *vdev)
@@ -109,13 +92,12 @@ static void virtio_gpu_gl_reset(VirtIODevice *vdev)
 
     virtio_gpu_reset(vdev);
 
-    if (g->parent_obj.use_virgl_renderer) {
+    if (g->renderer_inited) {
         if (g->parent_obj.renderer_blocked) {
             g->renderer_reset = true;
         } else {
             virtio_gpu_virgl_reset(g);
         }
-        g->parent_obj.use_virgl_renderer = false;
     }
 }
 
@@ -155,7 +137,7 @@ static void virtio_gpu_gl_class_init(ObjectClass *klass, void *data)
 
     vbc->gl_flushed = virtio_gpu_gl_flushed;
     vgc->handle_ctrl = virtio_gpu_gl_handle_ctrl;
-    vgc->process_cmd = virtio_gpu_gl_process_cmd;
+    vgc->process_cmd = virtio_gpu_virgl_process_cmd;
     vgc->update_cursor_data = virtio_gpu_gl_update_cursor_data;
 
     vdc->realize = virtio_gpu_gl_device_realize;
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 15/15] virtio-gpu: move fields to struct VirtIOGPUGL
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
                   ` (13 preceding siblings ...)
  2021-03-19 11:21 ` [PATCH 14/15] virtio-gpu: drop use_virgl_renderer Gerd Hoffmann
@ 2021-03-19 11:21 ` Gerd Hoffmann
  2021-03-19 11:42 ` [PATCH 00/15] virtio-gpu: split into two devices no-reply
  2021-03-19 11:48 ` Marc-André Lureau
  16 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-19 11:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael S. Tsirkin, Gerd Hoffmann, vivek.kasireddy, tina.zhang

Move two virglrenderer state variables to struct VirtIOGPUGL.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/hw/virtio/virtio-gpu.h |  5 +++--
 hw/display/virtio-gpu-gl.c     | 15 +++++++++------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h
index 9629885c895f..0a8281aeb555 100644
--- a/include/hw/virtio/virtio-gpu.h
+++ b/include/hw/virtio/virtio-gpu.h
@@ -151,8 +151,6 @@ struct VirtIOGPU {
     uint64_t hostmem;
 
     bool processing_cmdq;
-    bool renderer_inited;
-    bool renderer_reset;
     QEMUTimer *fence_poll;
     QEMUTimer *print_stats;
 
@@ -177,6 +175,9 @@ struct VirtIOGPUClass {
 
 struct VirtIOGPUGL {
     struct VirtIOGPU parent_obj;
+
+    bool renderer_inited;
+    bool renderer_reset;
 };
 
 struct VhostUserGPU {
diff --git a/hw/display/virtio-gpu-gl.c b/hw/display/virtio-gpu-gl.c
index 1642a973549e..d971b480806a 100644
--- a/hw/display/virtio-gpu-gl.c
+++ b/hw/display/virtio-gpu-gl.c
@@ -51,9 +51,10 @@ static void virtio_gpu_gl_update_cursor_data(VirtIOGPU *g,
 static void virtio_gpu_gl_flushed(VirtIOGPUBase *b)
 {
     VirtIOGPU *g = VIRTIO_GPU(b);
+    VirtIOGPUGL *gl = VIRTIO_GPU_GL(b);
 
-    if (g->renderer_reset) {
-        g->renderer_reset = false;
+    if (gl->renderer_reset) {
+        gl->renderer_reset = false;
         virtio_gpu_virgl_reset(g);
     }
     virtio_gpu_process_cmdq(g);
@@ -62,15 +63,16 @@ static void virtio_gpu_gl_flushed(VirtIOGPUBase *b)
 static void virtio_gpu_gl_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
 {
     VirtIOGPU *g = VIRTIO_GPU(vdev);
+    VirtIOGPUGL *gl = VIRTIO_GPU_GL(vdev);
     struct virtio_gpu_ctrl_command *cmd;
 
     if (!virtio_queue_ready(vq)) {
         return;
     }
 
-    if (!g->renderer_inited) {
+    if (!gl->renderer_inited) {
         virtio_gpu_virgl_init(g);
-        g->renderer_inited = true;
+        gl->renderer_inited = true;
     }
 
     cmd = virtqueue_pop(vq, sizeof(struct virtio_gpu_ctrl_command));
@@ -89,12 +91,13 @@ static void virtio_gpu_gl_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
 static void virtio_gpu_gl_reset(VirtIODevice *vdev)
 {
     VirtIOGPU *g = VIRTIO_GPU(vdev);
+    VirtIOGPUGL *gl = VIRTIO_GPU_GL(vdev);
 
     virtio_gpu_reset(vdev);
 
-    if (g->renderer_inited) {
+    if (gl->renderer_inited) {
         if (g->parent_obj.renderer_blocked) {
-            g->renderer_reset = true;
+            gl->renderer_reset = true;
         } else {
             virtio_gpu_virgl_reset(g);
         }
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 00/15] virtio-gpu: split into two devices.
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
                   ` (14 preceding siblings ...)
  2021-03-19 11:21 ` [PATCH 15/15] virtio-gpu: move fields to struct VirtIOGPUGL Gerd Hoffmann
@ 2021-03-19 11:42 ` no-reply
  2021-03-19 11:48 ` Marc-André Lureau
  16 siblings, 0 replies; 21+ messages in thread
From: no-reply @ 2021-03-19 11:42 UTC (permalink / raw)
  To: kraxel; +Cc: vivek.kasireddy, tina.zhang, kraxel, qemu-devel, mst

Patchew URL: https://patchew.org/QEMU/20210319112147.4138943-1-kraxel@redhat.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20210319112147.4138943-1-kraxel@redhat.com
Subject: [PATCH 00/15] virtio-gpu: split into two devices.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 - [tag update]      patchew/20210311165947.27470-1-peter.maydell@linaro.org -> patchew/20210311165947.27470-1-peter.maydell@linaro.org
 * [new tag]         patchew/20210319112147.4138943-1-kraxel@redhat.com -> patchew/20210319112147.4138943-1-kraxel@redhat.com
Switched to a new branch 'test'
d701bd8 virtio-gpu: move fields to struct VirtIOGPUGL
3efa9d2 virtio-gpu: drop use_virgl_renderer
b347213 virtio-gpu: move virtio-gpu-gl-device to separate module
d09c1f0 virtio-gpu: drop VIRGL() macro
05d9255 virtio-gpu: move update_cursor_data
192d336 virtio-gpu: move virgl process_cmd
8eeb29f virtio-gpu: move virgl gl_flushed
9e76d10 virtio-gpu: move virgl handle_ctrl
d272555 virtio-gpu: use class function for ctrl queue handlers
c37479b virtio-gpu: move virgl reset
576cff3 virtio-gpu: move virgl realize + properties
04c9c17 virtio-gpu: add virtio-vga-gl
e6934ec virtio-gpu: add virtio-gpu-gl-pci
57c1b29 virtio-gpu: add virtio-gpu-gl-device
660100e virtio-gpu: rename virgl source file.

=== OUTPUT BEGIN ===
1/15 Checking commit 660100eb846e (virtio-gpu: rename virgl source file.)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#14: 
 hw/display/{virtio-gpu-3d.c => virtio-gpu-virgl.c} | 0

total: 0 errors, 1 warnings, 8 lines checked

Patch 1/15 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
2/15 Checking commit 57c1b2934802 (virtio-gpu: add virtio-gpu-gl-device)
Use of uninitialized value $acpi_testexpected in string eq at ./scripts/checkpatch.pl line 1529.
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#32: 
new file mode 100644

total: 0 errors, 1 warnings, 75 lines checked

Patch 2/15 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
3/15 Checking commit e6934ec37d3d (virtio-gpu: add virtio-gpu-gl-pci)
4/15 Checking commit 04c9c179a093 (virtio-gpu: add virtio-vga-gl)
5/15 Checking commit 576cff3a938e (virtio-gpu: move virgl realize + properties)
6/15 Checking commit c37479b06276 (virtio-gpu: move virgl reset)
7/15 Checking commit d2725554fce3 (virtio-gpu: use class function for ctrl queue handlers)
8/15 Checking commit 9e76d10e3190 (virtio-gpu: move virgl handle_ctrl)
9/15 Checking commit 8eeb29f94541 (virtio-gpu: move virgl gl_flushed)
10/15 Checking commit 192d3360b319 (virtio-gpu: move virgl process_cmd)
WARNING: line over 80 characters
#101: FILE: include/hw/virtio/virtio-gpu.h:232:
+void virtio_gpu_simple_process_cmd(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd);

total: 0 errors, 1 warnings, 70 lines checked

Patch 10/15 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
11/15 Checking commit 05d925520ac0 (virtio-gpu: move update_cursor_data)
12/15 Checking commit d09c1f0ac45a (virtio-gpu: drop VIRGL() macro)
13/15 Checking commit b347213cfde6 (virtio-gpu: move virtio-gpu-gl-device to separate module)
14/15 Checking commit 3efa9d26ea18 (virtio-gpu: drop use_virgl_renderer)
ERROR: "foo * bar" should be "foo *bar"
#96: FILE: hw/display/virtio-gpu-gl.c:47:
+    memcpy(s->current_cursor->data, data, pixels * sizeof(uint32_t));

total: 1 errors, 0 warnings, 116 lines checked

Patch 14/15 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

15/15 Checking commit d701bd87ca8e (virtio-gpu: move fields to struct VirtIOGPUGL)
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20210319112147.4138943-1-kraxel@redhat.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 00/15] virtio-gpu: split into two devices.
  2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
                   ` (15 preceding siblings ...)
  2021-03-19 11:42 ` [PATCH 00/15] virtio-gpu: split into two devices no-reply
@ 2021-03-19 11:48 ` Marc-André Lureau
  2021-03-22  8:14   ` Gerd Hoffmann
  16 siblings, 1 reply; 21+ messages in thread
From: Marc-André Lureau @ 2021-03-19 11:48 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Tina Zhang, Vivek Kasireddy, QEMU, Michael S. Tsirkin

[-- Attachment #1: Type: text/plain, Size: 945 bytes --]

Hi Gerd

On Fri, Mar 19, 2021 at 3:22 PM Gerd Hoffmann <kraxel@redhat.com> wrote:

> Currently we have one virtio-gpu device.  Problem with this approach is
> that if you compile a full-featured qemu you'll get a virtio-gpu device
> which depends on opengl and virgl, so these dependencies must be
> installed and the libraries will be loaded into memory even if you don't
> use virgl.  Also the code is cluttered with #ifdefs and a bit messy.
>
> This patch series splits the virtio-gpu device into two:
>
>  (1) virtio-gpu-device becomes the non-virgl device, same as
>      virtio-gpu-device,virgl=off today.
>  (2) virtio-gpu-gl-device is the new virgl device, same as
>      virtio-gpu-device,virgl=on today.
>
> When compiling qemu without virglrenderer support virtio-gpu-device
> behavior doesn't change.
>

Nice!
We are post 6.0 soft freeze. I suppose you target those changes for 6.1?

-- 
Marc-André Lureau

[-- Attachment #2: Type: text/html, Size: 1371 bytes --]

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 00/15] virtio-gpu: split into two devices.
  2021-03-19 11:48 ` Marc-André Lureau
@ 2021-03-22  8:14   ` Gerd Hoffmann
  2021-03-22 18:41     ` Kasireddy, Vivek
  0 siblings, 1 reply; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-22  8:14 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Tina Zhang, Vivek Kasireddy, QEMU, Michael S. Tsirkin

On Fri, Mar 19, 2021 at 03:48:42PM +0400, Marc-André Lureau wrote:
> Hi Gerd
> 
> On Fri, Mar 19, 2021 at 3:22 PM Gerd Hoffmann <kraxel@redhat.com> wrote:
> 
> > Currently we have one virtio-gpu device.  Problem with this approach is
> > that if you compile a full-featured qemu you'll get a virtio-gpu device
> > which depends on opengl and virgl, so these dependencies must be
> > installed and the libraries will be loaded into memory even if you don't
> > use virgl.  Also the code is cluttered with #ifdefs and a bit messy.
> >
> > This patch series splits the virtio-gpu device into two:
> >
> >  (1) virtio-gpu-device becomes the non-virgl device, same as
> >      virtio-gpu-device,virgl=off today.
> >  (2) virtio-gpu-gl-device is the new virgl device, same as
> >      virtio-gpu-device,virgl=on today.
> >
> > When compiling qemu without virglrenderer support virtio-gpu-device
> > behavior doesn't change.
> >
> 
> Nice!
> We are post 6.0 soft freeze. I suppose you target those changes for 6.1?

Yes, it's clearly 6.1 material at this point.

take care,
  Gerd



^ permalink raw reply	[flat|nested] 21+ messages in thread

* RE: [PATCH 00/15] virtio-gpu: split into two devices.
  2021-03-22  8:14   ` Gerd Hoffmann
@ 2021-03-22 18:41     ` Kasireddy, Vivek
  2021-03-23  8:18       ` Gerd Hoffmann
  0 siblings, 1 reply; 21+ messages in thread
From: Kasireddy, Vivek @ 2021-03-22 18:41 UTC (permalink / raw)
  To: Gerd Hoffmann, Marc-André Lureau
  Cc: Zhang, Tina, QEMU, Michael S. Tsirkin

Hi Gerd,

> On Fri, Mar 19, 2021 at 03:48:42PM +0400, Marc-André Lureau wrote:
> > Hi Gerd
> >
> > On Fri, Mar 19, 2021 at 3:22 PM Gerd Hoffmann <kraxel@redhat.com> wrote:
> >
> > > Currently we have one virtio-gpu device.  Problem with this approach is
> > > that if you compile a full-featured qemu you'll get a virtio-gpu device
> > > which depends on opengl and virgl, so these dependencies must be
> > > installed and the libraries will be loaded into memory even if you don't
> > > use virgl.  Also the code is cluttered with #ifdefs and a bit messy.
> > >
> > > This patch series splits the virtio-gpu device into two:
> > >
> > >  (1) virtio-gpu-device becomes the non-virgl device, same as
> > >      virtio-gpu-device,virgl=off today.
> > >  (2) virtio-gpu-gl-device is the new virgl device, same as
> > >      virtio-gpu-device,virgl=on today.
> > >
> > > When compiling qemu without virglrenderer support virtio-gpu-device
> > > behavior doesn't change.
[Kasireddy, Vivek] Just a random thought: if a user enables both these devices 
either intentionally or accidentally, can they play nice with each other?
If this case is not allowed, where and how is that being enforced?

Thanks,
Vivek

> > >
> >
> > Nice!
> > We are post 6.0 soft freeze. I suppose you target those changes for 6.1?
> 
> Yes, it's clearly 6.1 material at this point.
> 
> take care,
>   Gerd



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 00/15] virtio-gpu: split into two devices.
  2021-03-22 18:41     ` Kasireddy, Vivek
@ 2021-03-23  8:18       ` Gerd Hoffmann
  0 siblings, 0 replies; 21+ messages in thread
From: Gerd Hoffmann @ 2021-03-23  8:18 UTC (permalink / raw)
  To: Kasireddy, Vivek
  Cc: Zhang, Tina, Marc-André Lureau, QEMU, Michael S. Tsirkin

On Mon, Mar 22, 2021 at 06:41:47PM +0000, Kasireddy, Vivek wrote:
> Hi Gerd,
> 
> > On Fri, Mar 19, 2021 at 03:48:42PM +0400, Marc-André Lureau wrote:
> > > Hi Gerd
> > >
> > > On Fri, Mar 19, 2021 at 3:22 PM Gerd Hoffmann <kraxel@redhat.com> wrote:
> > >
> > > > Currently we have one virtio-gpu device.  Problem with this approach is
> > > > that if you compile a full-featured qemu you'll get a virtio-gpu device
> > > > which depends on opengl and virgl, so these dependencies must be
> > > > installed and the libraries will be loaded into memory even if you don't
> > > > use virgl.  Also the code is cluttered with #ifdefs and a bit messy.
> > > >
> > > > This patch series splits the virtio-gpu device into two:
> > > >
> > > >  (1) virtio-gpu-device becomes the non-virgl device, same as
> > > >      virtio-gpu-device,virgl=off today.
> > > >  (2) virtio-gpu-gl-device is the new virgl device, same as
> > > >      virtio-gpu-device,virgl=on today.
> > > >
> > > > When compiling qemu without virglrenderer support virtio-gpu-device
> > > > behavior doesn't change.
> [Kasireddy, Vivek] Just a random thought: if a user enables both these devices 
> either intentionally or accidentally, can they play nice with each other?

Yes, should work fine.

take care,
  Gerd



^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2021-03-23  8:20 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 11:21 [PATCH 00/15] virtio-gpu: split into two devices Gerd Hoffmann
2021-03-19 11:21 ` [PATCH 01/15] virtio-gpu: rename virgl source file Gerd Hoffmann
2021-03-19 11:21 ` [PATCH 02/15] virtio-gpu: add virtio-gpu-gl-device Gerd Hoffmann
2021-03-19 11:21 ` [PATCH 03/15] virtio-gpu: add virtio-gpu-gl-pci Gerd Hoffmann
2021-03-19 11:21 ` [PATCH 04/15] virtio-gpu: add virtio-vga-gl Gerd Hoffmann
2021-03-19 11:21 ` [PATCH 05/15] virtio-gpu: move virgl realize + properties Gerd Hoffmann
2021-03-19 11:21 ` [PATCH 06/15] virtio-gpu: move virgl reset Gerd Hoffmann
2021-03-19 11:21 ` [PATCH 07/15] virtio-gpu: use class function for ctrl queue handlers Gerd Hoffmann
2021-03-19 11:21 ` [PATCH 08/15] virtio-gpu: move virgl handle_ctrl Gerd Hoffmann
2021-03-19 11:21 ` [PATCH 09/15] virtio-gpu: move virgl gl_flushed Gerd Hoffmann
2021-03-19 11:21 ` [PATCH 10/15] virtio-gpu: move virgl process_cmd Gerd Hoffmann
2021-03-19 11:21 ` [PATCH 11/15] virtio-gpu: move update_cursor_data Gerd Hoffmann
2021-03-19 11:21 ` [PATCH 12/15] virtio-gpu: drop VIRGL() macro Gerd Hoffmann
2021-03-19 11:21 ` [PATCH 13/15] virtio-gpu: move virtio-gpu-gl-device to separate module Gerd Hoffmann
2021-03-19 11:21 ` [PATCH 14/15] virtio-gpu: drop use_virgl_renderer Gerd Hoffmann
2021-03-19 11:21 ` [PATCH 15/15] virtio-gpu: move fields to struct VirtIOGPUGL Gerd Hoffmann
2021-03-19 11:42 ` [PATCH 00/15] virtio-gpu: split into two devices no-reply
2021-03-19 11:48 ` Marc-André Lureau
2021-03-22  8:14   ` Gerd Hoffmann
2021-03-22 18:41     ` Kasireddy, Vivek
2021-03-23  8:18       ` Gerd Hoffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.