All of lore.kernel.org
 help / color / mirror / Atom feed
From: marcandre.lureau@redhat.com
To: qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Cleber Rosa" <crosa@redhat.com>
Subject: [PATCH 04/20] vhost-user-gpu: handle display-info in a callback
Date: Tue,  2 Feb 2021 18:26:09 +0400	[thread overview]
Message-ID: <20210202142625.609070-5-marcandre.lureau@redhat.com> (raw)
In-Reply-To: <20210202142625.609070-1-marcandre.lureau@redhat.com>

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Fixes a deadlock where the backend calls QEMU, while QEMU also calls the
backend simultaneously, both ends waiting for each other.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 contrib/vhost-user-gpu/vhost-user-gpu.c | 32 ++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c b/contrib/vhost-user-gpu/vhost-user-gpu.c
index 7dcc02966c..810e227382 100644
--- a/contrib/vhost-user-gpu/vhost-user-gpu.c
+++ b/contrib/vhost-user-gpu/vhost-user-gpu.c
@@ -261,10 +261,32 @@ vg_ctrl_response_nodata(VuGpu *g,
     vg_ctrl_response(g, cmd, &resp, sizeof(resp));
 }
 
+
+static gboolean
+get_display_info_cb(gint fd, GIOCondition condition, gpointer user_data)
+{
+    struct virtio_gpu_resp_display_info dpy_info = { {} };
+    VuGpu *vg = user_data;
+    struct virtio_gpu_ctrl_command *cmd = QTAILQ_LAST(&vg->fenceq);
+
+    g_debug("disp info cb");
+    assert(cmd->cmd_hdr.type == VIRTIO_GPU_CMD_GET_DISPLAY_INFO);
+    if (!vg_recv_msg(vg, VHOST_USER_GPU_GET_DISPLAY_INFO, sizeof(dpy_info), &dpy_info)) {
+        return G_SOURCE_CONTINUE;
+    }
+
+    QTAILQ_REMOVE(&vg->fenceq, cmd, next);
+    vg_ctrl_response(vg, cmd, &dpy_info.hdr, sizeof(dpy_info));
+
+    vg->wait_in = 0;
+    vg_handle_ctrl(&vg->dev.parent, 0);
+
+    return G_SOURCE_REMOVE;
+}
+
 void
 vg_get_display_info(VuGpu *vg, struct virtio_gpu_ctrl_command *cmd)
 {
-    struct virtio_gpu_resp_display_info dpy_info = { {} };
     VhostUserGpuMsg msg = {
         .request = VHOST_USER_GPU_GET_DISPLAY_INFO,
         .size = 0,
@@ -273,11 +295,9 @@ vg_get_display_info(VuGpu *vg, struct virtio_gpu_ctrl_command *cmd)
     assert(vg->wait_in == 0);
 
     vg_send_msg(vg, &msg, -1);
-    if (!vg_recv_msg(vg, msg.request, sizeof(dpy_info), &dpy_info)) {
-        return;
-    }
-
-    vg_ctrl_response(vg, cmd, &dpy_info.hdr, sizeof(dpy_info));
+    vg->wait_in = g_unix_fd_add(vg->sock_fd, G_IO_IN | G_IO_HUP,
+                               get_display_info_cb, vg);
+    cmd->state = VG_CMD_STATE_PENDING;
 }
 
 static void
-- 
2.29.0



  parent reply	other threads:[~2021-02-02 14:29 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-02 14:26 [PATCH 00/20] Various vhost-user-gpu & UI fixes marcandre.lureau
2021-02-02 14:26 ` [PATCH 01/20] vhost-user-gpu: check backend for EDID support marcandre.lureau
2021-02-02 14:26 ` [PATCH 02/20] vhost-user-gpu: handle vhost-user-gpu features in a callback marcandre.lureau
2021-02-02 14:26 ` [PATCH 03/20] vhost-user-gpu: use an extandable state enum for commands marcandre.lureau
2021-02-02 14:26 ` marcandre.lureau [this message]
2021-02-02 14:26 ` [PATCH 05/20] ui: remove extra #ifdef CONFIG_OPENGL marcandre.lureau
2021-02-02 14:26 ` [PATCH 06/20] ui: remove gl_ctx_get_current marcandre.lureau
2021-02-02 14:26 ` [PATCH 07/20] ui: add gd_gl_area_scanout_disable marcandre.lureau
2021-02-02 14:26 ` [PATCH 08/20] ui: annotate DCLOps callback requirements marcandre.lureau
2021-02-02 14:26 ` [PATCH 09/20] ui: remove console_has_gl_dmabuf() marcandre.lureau
2021-02-02 14:26 ` [PATCH 10/20] vhost-user-gpu: add a configuration flag for dmabuf usage marcandre.lureau
2021-02-02 14:26 ` [PATCH 11/20] ui: add an optional get_flags callback to GraphicHwOps marcandre.lureau
2021-02-03 15:48   ` Gerd Hoffmann
2021-02-03 22:21     ` Marc-André Lureau
2021-02-04  8:32       ` Gerd Hoffmann
2021-02-02 14:26 ` [PATCH 12/20] ui: add a DCLOps callback to check dmabuf support marcandre.lureau
2021-02-02 14:26 ` [PATCH 13/20] ui: check hw requirements during DCL registration marcandre.lureau
2021-02-02 14:26 ` [PATCH 14/20] ui: add qemu_egl_has_dmabuf helper marcandre.lureau
2021-02-02 14:26 ` [PATCH 15/20] ui: check gtk-egl dmabuf support marcandre.lureau
2021-02-02 14:26 ` [PATCH 16/20] ui: add egl dmabuf import to gtkglarea marcandre.lureau
2021-02-02 14:26 ` [PATCH 17/20] virtio-gpu: avoid re-entering cmdq processing marcandre.lureau
2021-02-02 14:26 ` [PATCH 18/20] display/ui: add a callback to indicate GL state is flushed marcandre.lureau
2021-02-02 14:26 ` [PATCH 19/20] chardev: check if the chardev is registered for yanking marcandre.lureau
2021-02-02 14:26 ` [PATCH 20/20] RFC: tests: add some virtio-gpu & vhost-user-gpu acceptance test marcandre.lureau
2021-02-03 11:38   ` Gerd Hoffmann
2021-02-03 13:33     ` Marc-André Lureau
2021-02-03 14:16       ` Gerd Hoffmann
2021-02-03 14:20         ` Marc-André Lureau
2021-02-02 14:57 ` [PATCH 00/20] Various vhost-user-gpu & UI fixes no-reply

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=20210202142625.609070-5-marcandre.lureau@redhat.com \
    --to=marcandre.lureau@redhat.com \
    --cc=crosa@redhat.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 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.