{"id":1571405,"url":"http://patchwork.ozlabs.org/api/patches/1571405/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20211221065855.142578-15-marcandre.lureau@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20211221065855.142578-15-marcandre.lureau@redhat.com>","list_archive_url":null,"date":"2021-12-21T06:58:33","name":"[PULL,v2,14/36] ui: simplify gl unblock & flush","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"2507a02817263cf33e434edb9cb9325efbf1ff4c","submitter":{"id":66774,"url":"http://patchwork.ozlabs.org/api/people/66774/?format=json","name":"Marc-André Lureau","email":"marcandre.lureau@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20211221065855.142578-15-marcandre.lureau@redhat.com/mbox/","series":[{"id":277865,"url":"http://patchwork.ozlabs.org/api/series/277865/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=277865","date":"2021-12-21T06:58:19","name":"[PULL,v2,01/36] ui/vdagent: add CHECK_SPICE_PROTOCOL_VERSION","version":2,"mbox":"http://patchwork.ozlabs.org/series/277865/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/1571405/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/1571405/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["bilbo.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=cuBD0mNx;\n\tdkim-atps=neutral","ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=<UNKNOWN>)","relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=marcandre.lureau@redhat.com"],"Received":["from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby bilbo.ozlabs.org (Postfix) with ESMTPS id 4JJ79F6f4zz9s3q\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Dec 2021 18:18:40 +1100 (AEDT)","from localhost ([::1]:46212 helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1mzZPx-0008HS-4w\n\tfor incoming@patchwork.ozlabs.org; Tue, 21 Dec 2021 02:18:37 -0500","from eggs.gnu.org ([209.51.188.92]:58626)\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <marcandre.lureau@redhat.com>)\n id 1mzZAc-00055i-0P\n for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:46 -0500","from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40728)\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <marcandre.lureau@redhat.com>)\n id 1mzZAa-000250-3C\n for qemu-devel@nongnu.org; Tue, 21 Dec 2021 02:02:45 -0500","from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com\n [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n us-mta-590-5xpnZumAOj29DB56ZZSznw-1; Tue, 21 Dec 2021 02:02:42 -0500","from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com\n [10.5.11.12])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 614FC2F25;\n Tue, 21 Dec 2021 07:02:41 +0000 (UTC)","from localhost (unknown [10.39.208.37])\n by smtp.corp.redhat.com (Postfix) with ESMTP id A5DF57EDB9;\n Tue, 21 Dec 2021 07:02:32 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1640070163;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=f8UvDTsSg5s/5xh4bXNQhmRbd8oCeKhx4pniuOht2/g=;\n b=cuBD0mNxTOmn7663HPohsBtWHJJ04qC32LG5Sb8myjlB6yMjqxV8dITYVnyFrZfvRgowev\n 7SKi9f0LhehEvVZg9BVzQb9RfWonhQLTw85UXv+pEF/kTLS5jgd9fkjRKzShPaSbE977K0\n exkOh58+6pJ2TDMrS5PmNj4M6vX1ug4=","X-MC-Unique":"5xpnZumAOj29DB56ZZSznw-1","From":"marcandre.lureau@redhat.com","To":"qemu-devel@nongnu.org","Subject":"[PULL v2 14/36] ui: simplify gl unblock & flush","Date":"Tue, 21 Dec 2021 10:58:33 +0400","Message-Id":"<20211221065855.142578-15-marcandre.lureau@redhat.com>","In-Reply-To":"<20211221065855.142578-1-marcandre.lureau@redhat.com>","References":"<20211221065855.142578-1-marcandre.lureau@redhat.com>","MIME-Version":"1.0","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.12","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Received-SPF":"pass client-ip=170.10.133.124;\n envelope-from=marcandre.lureau@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com","X-Spam_score_int":"-29","X-Spam_score":"-3.0","X-Spam_bar":"---","X-Spam_report":"(-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.203,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001,\n SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"peter.maydell@linaro.org, richard.henderson@linaro.org, =?utf-8?q?Marc-A?=\n\t=?utf-8?q?ndr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n <qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"From: Marc-André Lureau <marcandre.lureau@redhat.com>\n\nGraphicHw.gl_flushed was introduced to notify the\ndevice (vhost-user-gpu) that the GL resources (the display scanout) are\nno longer needed.\n\nIt was decoupled from QEMU own gl-blocking mechanism, but that\ndifference isn't helping. Instead, we can reuse QEMU gl-blocking and\nnotify virtio_gpu_gl_flushed() when unblocking (to unlock\nvhost-user-gpu).\n\nAn extra block/unblock is added arount dpy_gl_update() so existing\nbackends that don't block will have the flush event handled. It will\nalso help when there are no backends associated.\n\nSigned-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>\nAcked-by: Gerd Hoffmann <kraxel@redhat.com>\n---\n include/ui/console.h         |  2 --\n hw/display/vhost-user-gpu.c  |  2 +-\n hw/display/virtio-gpu-base.c |  5 ++++-\n hw/display/virtio-vga.c      | 11 -----------\n ui/console.c                 | 12 +++---------\n ui/gtk-egl.c                 |  2 --\n ui/gtk-gl-area.c             |  2 --\n ui/gtk.c                     |  1 -\n ui/sdl2-gl.c                 |  2 --\n ui/spice-display.c           |  1 -\n 10 files changed, 8 insertions(+), 32 deletions(-)","diff":"diff --git a/include/ui/console.h b/include/ui/console.h\nindex fb10e6d60cd7..3ff51b492e5b 100644\n--- a/include/ui/console.h\n+++ b/include/ui/console.h\n@@ -391,7 +391,6 @@ typedef struct GraphicHwOps {\n     void (*update_interval)(void *opaque, uint64_t interval);\n     int (*ui_info)(void *opaque, uint32_t head, QemuUIInfo *info);\n     void (*gl_block)(void *opaque, bool block);\n-    void (*gl_flushed)(void *opaque);\n } GraphicHwOps;\n \n QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head,\n@@ -407,7 +406,6 @@ void graphic_hw_update_done(QemuConsole *con);\n void graphic_hw_invalidate(QemuConsole *con);\n void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata);\n void graphic_hw_gl_block(QemuConsole *con, bool block);\n-void graphic_hw_gl_flushed(QemuConsole *con);\n \n void qemu_console_early_init(void);\n \ndiff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c\nindex 49df56cd14e9..09818231bd24 100644\n--- a/hw/display/vhost-user-gpu.c\n+++ b/hw/display/vhost-user-gpu.c\n@@ -254,8 +254,8 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUserGpuMsg *msg)\n             vhost_user_gpu_unblock(g);\n             break;\n         }\n-        dpy_gl_update(con, m->x, m->y, m->width, m->height);\n         g->backend_blocked = true;\n+        dpy_gl_update(con, m->x, m->y, m->width, m->height);\n         break;\n     }\n     case VHOST_USER_GPU_UPDATE: {\ndiff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c\nindex c8da4806e0bb..fff0fb4a828a 100644\n--- a/hw/display/virtio-gpu-base.c\n+++ b/hw/display/virtio-gpu-base.c\n@@ -117,6 +117,10 @@ virtio_gpu_gl_block(void *opaque, bool block)\n         g->renderer_blocked--;\n     }\n     assert(g->renderer_blocked >= 0);\n+\n+    if (!block && g->renderer_blocked == 0) {\n+        virtio_gpu_gl_flushed(g);\n+    }\n }\n \n static int\n@@ -143,7 +147,6 @@ static const GraphicHwOps virtio_gpu_ops = {\n     .text_update = virtio_gpu_text_update,\n     .ui_info = virtio_gpu_ui_info,\n     .gl_block = virtio_gpu_gl_block,\n-    .gl_flushed = virtio_gpu_gl_flushed,\n };\n \n bool\ndiff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c\nindex 9e57f61e9edb..b23a75a04b9d 100644\n--- a/hw/display/virtio-vga.c\n+++ b/hw/display/virtio-vga.c\n@@ -68,16 +68,6 @@ static void virtio_vga_base_gl_block(void *opaque, bool block)\n     }\n }\n \n-static void virtio_vga_base_gl_flushed(void *opaque)\n-{\n-    VirtIOVGABase *vvga = opaque;\n-    VirtIOGPUBase *g = vvga->vgpu;\n-\n-    if (g->hw_ops->gl_flushed) {\n-        g->hw_ops->gl_flushed(g);\n-    }\n-}\n-\n static int virtio_vga_base_get_flags(void *opaque)\n {\n     VirtIOVGABase *vvga = opaque;\n@@ -93,7 +83,6 @@ static const GraphicHwOps virtio_vga_base_ops = {\n     .text_update = virtio_vga_base_text_update,\n     .ui_info = virtio_vga_base_ui_info,\n     .gl_block = virtio_vga_base_gl_block,\n-    .gl_flushed = virtio_vga_base_gl_flushed,\n };\n \n static const VMStateDescription vmstate_virtio_vga_base = {\ndiff --git a/ui/console.c b/ui/console.c\nindex fcc4fe6a0aa0..6f21007737e5 100644\n--- a/ui/console.c\n+++ b/ui/console.c\n@@ -267,15 +267,6 @@ void graphic_hw_gl_block(QemuConsole *con, bool block)\n     }\n }\n \n-void graphic_hw_gl_flushed(QemuConsole *con)\n-{\n-    assert(con != NULL);\n-\n-    if (con->hw_ops->gl_flushed) {\n-        con->hw_ops->gl_flushed(con->hw);\n-    }\n-}\n-\n int qemu_console_get_window_id(QemuConsole *con)\n {\n     return con->window_id;\n@@ -1894,7 +1885,10 @@ void dpy_gl_update(QemuConsole *con,\n                    uint32_t x, uint32_t y, uint32_t w, uint32_t h)\n {\n     assert(con->gl);\n+\n+    graphic_hw_gl_block(con, true);\n     con->gl->ops->dpy_gl_update(con->gl, x, y, w, h);\n+    graphic_hw_gl_block(con, false);\n }\n \n /***********************************************************/\ndiff --git a/ui/gtk-egl.c b/ui/gtk-egl.c\nindex 45cb67712df0..e891b61048a8 100644\n--- a/ui/gtk-egl.c\n+++ b/ui/gtk-egl.c\n@@ -119,8 +119,6 @@ void gd_egl_draw(VirtualConsole *vc)\n \n         glFlush();\n     }\n-\n-    graphic_hw_gl_flushed(vc->gfx.dcl.con);\n }\n \n void gd_egl_update(DisplayChangeListener *dcl,\ndiff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c\nindex 01e4e74ee361..f1c7636cba98 100644\n--- a/ui/gtk-gl-area.c\n+++ b/ui/gtk-gl-area.c\n@@ -101,8 +101,6 @@ void gd_gl_area_draw(VirtualConsole *vc)\n         surface_gl_setup_viewport(vc->gfx.gls, vc->gfx.ds, ww, wh);\n         surface_gl_render_texture(vc->gfx.gls, vc->gfx.ds);\n     }\n-\n-    graphic_hw_gl_flushed(vc->gfx.dcl.con);\n }\n \n void gd_gl_area_update(DisplayChangeListener *dcl,\ndiff --git a/ui/gtk.c b/ui/gtk.c\nindex 25896023ffe7..077d38145de8 100644\n--- a/ui/gtk.c\n+++ b/ui/gtk.c\n@@ -593,7 +593,6 @@ void gd_hw_gl_flushed(void *vcon)\n     close(dmabuf->fence_fd);\n     dmabuf->fence_fd = -1;\n     graphic_hw_gl_block(vc->gfx.dcl.con, false);\n-    graphic_hw_gl_flushed(vc->gfx.dcl.con);\n }\n \n /** DisplayState Callbacks (opengl version) **/\ndiff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c\nindex a21d2deed916..5b950fbbea2f 100644\n--- a/ui/sdl2-gl.c\n+++ b/ui/sdl2-gl.c\n@@ -58,7 +58,6 @@ static void sdl2_gl_render_surface(struct sdl2_console *scon)\n \n     surface_gl_render_texture(scon->gls, scon->surface);\n     SDL_GL_SwapWindow(scon->real_window);\n-    graphic_hw_gl_flushed(scon->dcl.con);\n }\n \n void sdl2_gl_update(DisplayChangeListener *dcl,\n@@ -241,5 +240,4 @@ void sdl2_gl_scanout_flush(DisplayChangeListener *dcl,\n     egl_fb_blit(&scon->win_fb, &scon->guest_fb, !scon->y0_top);\n \n     SDL_GL_SwapWindow(scon->real_window);\n-    graphic_hw_gl_flushed(dcl->con);\n }\ndiff --git a/ui/spice-display.c b/ui/spice-display.c\nindex 2c204bceee27..ec501f129f07 100644\n--- a/ui/spice-display.c\n+++ b/ui/spice-display.c\n@@ -830,7 +830,6 @@ static void qemu_spice_gl_unblock_bh(void *opaque)\n     SimpleSpiceDisplay *ssd = opaque;\n \n     qemu_spice_gl_block(ssd, false);\n-    graphic_hw_gl_flushed(ssd->dcl.con);\n }\n \n static void qemu_spice_gl_block_timer(void *opaque)\n","prefixes":["PULL","v2","14/36"]}