qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vivek Kasireddy <vivek.kasireddy@intel.com>
To: qemu-devel@nongnu.org
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: [PATCH v3 16/20] virtio-gpu: Add virtio_gpu_wait_flush API
Date: Tue, 11 May 2021 01:08:14 -0700	[thread overview]
Message-ID: <20210511080818.366985-17-vivek.kasireddy@intel.com> (raw)
In-Reply-To: <20210511080818.366985-1-vivek.kasireddy@intel.com>

This new command can be used by the Guest Compositor as a way to
synchronize its updates (repaint/redraw) with Host UI buffer
submissions (redraw). In other words, the Guest can wait until
the buffer it has submitted has been used by the Host before it
starts it new repaint cycle.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
---
 hw/display/virtio-gpu.c                     | 31 +++++++++++++++++++++
 include/standard-headers/linux/virtio_gpu.h | 10 +++++++
 2 files changed, 41 insertions(+)

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 694d8f550c..59cbc2b1df 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -933,6 +933,30 @@ virtio_gpu_resource_detach_backing(VirtIOGPU *g,
     virtio_gpu_cleanup_mapping(g, res);
 }
 
+static void virtio_gpu_wait_flush(VirtIOGPU *g,
+                                  struct virtio_gpu_ctrl_command *cmd)
+{
+    struct virtio_gpu_simple_resource *res;
+    struct virtio_gpu_wait_flush wf;
+
+    VIRTIO_GPU_FILL_CMD(wf);
+    virtio_gpu_bswap_32(&wf, sizeof(wf));
+
+    res = virtio_gpu_find_check_resource(g, wf.resource_id, true,
+                                         __func__, &cmd->error);
+    if (!res) {
+        return;
+    }
+
+    if (res->blob) {
+        if (cmd->cmd_hdr.flags & VIRTIO_GPU_FLAG_FENCE &&
+            virtio_gpu_resource_has_sync(g, res)) {
+            virtio_gpu_resource_wait_sync(g, res);
+            cmd->finished = true;
+        }
+    }
+}
+
 void virtio_gpu_simple_process_cmd(VirtIOGPU *g,
                                    struct virtio_gpu_ctrl_command *cmd)
 {
@@ -981,6 +1005,13 @@ void virtio_gpu_simple_process_cmd(VirtIOGPU *g,
     case VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING:
         virtio_gpu_resource_detach_backing(g, cmd);
         break;
+    case VIRTIO_GPU_CMD_WAIT_FLUSH:
+        if (!virtio_gpu_expflush_enabled(g->parent_obj.conf)) {
+            cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
+            break;
+        }
+        virtio_gpu_wait_flush(g, cmd);
+        break;
     default:
         cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
         break;
diff --git a/include/standard-headers/linux/virtio_gpu.h b/include/standard-headers/linux/virtio_gpu.h
index d015741f0b..f9aba84174 100644
--- a/include/standard-headers/linux/virtio_gpu.h
+++ b/include/standard-headers/linux/virtio_gpu.h
@@ -60,6 +60,9 @@
  */
 #define VIRTIO_GPU_F_RESOURCE_BLOB       3
 
+/*
+ * VIRTIO_GPU_CMD_WAIT_FLUSH
+ */
 #define VIRTIO_GPU_F_EXPLICIT_FLUSH      4
 
 enum virtio_gpu_ctrl_type {
@@ -80,6 +83,7 @@ enum virtio_gpu_ctrl_type {
 	VIRTIO_GPU_CMD_RESOURCE_ASSIGN_UUID,
 	VIRTIO_GPU_CMD_RESOURCE_CREATE_BLOB,
 	VIRTIO_GPU_CMD_SET_SCANOUT_BLOB,
+	VIRTIO_GPU_CMD_WAIT_FLUSH,
 
 	/* 3d commands */
 	VIRTIO_GPU_CMD_CTX_CREATE = 0x0200,
@@ -443,4 +447,10 @@ struct virtio_gpu_resource_unmap_blob {
 	uint32_t padding;
 };
 
+/* VIRTIO_GPU_CMD_WAIT_FLUSH */
+struct virtio_gpu_wait_flush {
+	struct virtio_gpu_ctrl_hdr hdr;
+	uint32_t resource_id;
+};
+
 #endif
-- 
2.30.2



  parent reply	other threads:[~2021-05-11  8:54 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-11  8:07 [PATCH v3 00/20] virtio-gpu: Add support for Blob resources Vivek Kasireddy
2021-05-11  8:07 ` [PATCH v3 01/20] ui: Get the fd associated with udmabuf driver Vivek Kasireddy
2021-05-11  8:08 ` [PATCH v3 02/20] headers: Add udmabuf.h Vivek Kasireddy
2021-05-11  8:08 ` [PATCH v3 03/20] virtio-gpu: Add udmabuf helpers Vivek Kasireddy
2021-05-11 11:22   ` Gerd Hoffmann
2021-05-11  8:08 ` [PATCH v3 04/20] virtio-gpu: Add virtio_gpu_find_check_resource Vivek Kasireddy
2021-05-11  8:08 ` [PATCH v3 05/20] virtio-gpu: Refactor virtio_gpu_set_scanout Vivek Kasireddy
2021-05-11  8:08 ` [PATCH v3 06/20] virtio-gpu: Refactor virtio_gpu_create_mapping_iov Vivek Kasireddy
2021-05-11  8:08 ` [PATCH v3 07/20] virtio-gpu: Add initial definitions for blob resources Vivek Kasireddy
2021-05-11  8:08 ` [PATCH v3 08/20] virtio-gpu: Add virtio_gpu_resource_create_blob Vivek Kasireddy
2021-05-11  8:08 ` [PATCH v3 09/20] ui/pixman: Add qemu_pixman_to_drm_format() Vivek Kasireddy
2021-05-11  8:08 ` [PATCH v3 10/20] virtio-gpu: Add helpers to create and destroy dmabuf objects Vivek Kasireddy
2021-05-11  8:08 ` [PATCH v3 11/20] virtio-gpu: Factor out update scanout Vivek Kasireddy
2021-05-11  8:08 ` [PATCH v3 12/20] virtio-gpu: Add virtio_gpu_set_scanout_blob Vivek Kasireddy
2021-05-11 11:39   ` Gerd Hoffmann
2021-05-11 22:42     ` Kasireddy, Vivek
2021-05-11  8:08 ` [PATCH v3 13/20] virtio-gpu: Update cursor data using blob Vivek Kasireddy
2021-05-11  8:08 ` [PATCH v3 14/20] virtio-gpu: Add initial definitions for explict flush feature Vivek Kasireddy
2021-05-11 11:42   ` Gerd Hoffmann
2021-05-11  8:08 ` [PATCH v3 15/20] virtio-gpu: Add dmabuf helpers for synchronization Vivek Kasireddy
2021-05-11  8:08 ` Vivek Kasireddy [this message]
2021-05-11  8:08 ` [PATCH v3 17/20] ui: Add egl " Vivek Kasireddy
2021-05-11  8:08 ` [PATCH v3 18/20] ui/gtk-egl: Wait for the draw signal for dmabuf blobs Vivek Kasireddy
2021-05-11  8:08 ` [PATCH v3 19/20] ui/gtk: Create a common release_dmabuf helper Vivek Kasireddy
2021-05-11  8:08 ` [PATCH v3 20/20] virtio-gpu: Add gl_flushed callback Vivek Kasireddy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210511080818.366985-17-vivek.kasireddy@intel.com \
    --to=vivek.kasireddy@intel.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).