[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/24] vhost-user-gpu: handle display-info in a callback
From: |
Gerd Hoffmann |
Subject: |
[PULL 08/24] vhost-user-gpu: handle display-info in a callback |
Date: |
Fri, 5 Feb 2021 07:56:04 +0100 |
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>
Message-Id: <20210204105232.834642-5-marcandre.lureau@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
contrib/vhost-user-gpu/vhost-user-gpu.c | 35 ++++++++++++++++++++-----
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c
b/contrib/vhost-user-gpu/vhost-user-gpu.c
index 7dcc02966ca9..b27990ffdbc0 100644
--- a/contrib/vhost-user-gpu/vhost-user-gpu.c
+++ b/contrib/vhost-user-gpu/vhost-user-gpu.c
@@ -261,10 +261,33 @@ vg_ctrl_response_nodata(VuGpu *g,
vg_ctrl_response(g, cmd, &resp, sizeof(resp));
}
-void
-vg_get_display_info(VuGpu *vg, struct virtio_gpu_ctrl_command *cmd)
+
+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)
+{
VhostUserGpuMsg msg = {
.request = VHOST_USER_GPU_GET_DISPLAY_INFO,
.size = 0,
@@ -273,11 +296,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.2
- [PULL 00/24] Vga ui 20210205 patches, Gerd Hoffmann, 2021/02/05
- [PULL 04/24] spice: delay starting until display are initialized, Gerd Hoffmann, 2021/02/05
- [PULL 02/24] qxl: set qxl.ssd.dcl.con on secondary devices, Gerd Hoffmann, 2021/02/05
- [PULL 09/24] ui: remove extra #ifdef CONFIG_OPENGL, Gerd Hoffmann, 2021/02/05
- [PULL 13/24] ui: remove console_has_gl_dmabuf(), Gerd Hoffmann, 2021/02/05
- [PULL 03/24] qxl: also notify the rendering is done when skipping it, Gerd Hoffmann, 2021/02/05
- [PULL 14/24] vhost-user-gpu: add a configuration flag for dmabuf usage, Gerd Hoffmann, 2021/02/05
- [PULL 01/24] hw/display/qxl: Fix bad printf format specifiers, Gerd Hoffmann, 2021/02/05
- [PULL 12/24] ui: annotate DCLOps callback requirements, Gerd Hoffmann, 2021/02/05
- [PULL 08/24] vhost-user-gpu: handle display-info in a callback,
Gerd Hoffmann <=
- [PULL 15/24] ui: add an optional get_flags callback to GraphicHwOps, Gerd Hoffmann, 2021/02/05
- [PULL 07/24] vhost-user-gpu: use an extandable state enum for commands, Gerd Hoffmann, 2021/02/05
- [PULL 11/24] ui: add gd_gl_area_scanout_disable, Gerd Hoffmann, 2021/02/05
- [PULL 17/24] ui: check hw requirements during DCL registration, Gerd Hoffmann, 2021/02/05
- [PULL 23/24] chardev: check if the chardev is registered for yanking, Gerd Hoffmann, 2021/02/05
- [PULL 10/24] ui: remove gl_ctx_get_current, Gerd Hoffmann, 2021/02/05
- [PULL 24/24] tests: add some virtio-gpu & vhost-user-gpu acceptance test, Gerd Hoffmann, 2021/02/05
- [PULL 18/24] ui: add qemu_egl_has_dmabuf helper, Gerd Hoffmann, 2021/02/05
- [PULL 16/24] ui: add a DCLOps callback to check dmabuf support, Gerd Hoffmann, 2021/02/05
- [PULL 06/24] vhost-user-gpu: handle vhost-user-gpu features in a callback, Gerd Hoffmann, 2021/02/05