Skip to contentSkip to conversation

virtio-gpu: first surface update with blob scanout after resumed

PATCH In review [email protected] 2 participants 3 messages Mar 6, 2024 – Mar 12, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 virtio-gpu: first surface update with blob scanout after resumed

From: Dongwon Kim <[email protected]>

The guest surface needs to be updated with a blob scanout after resumed from saved vm state if blob is enabled.

v2: Rebased

Cc Marc-André Lureau <[email protected]>
Cc Vivek Kasireddy <[email protected]>
---
 hw/display/virtio-gpu.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
hw/display/virtio-gpu.c +14 -7
index 1c1ee230b3..01bc4f9565 100644
@@ -1422,16 +1422,23 @@ static int virtio_gpu_post_load(void *opaque, int version_id)
         if (!res) {
             return -EINVAL;
         }
-        scanout->ds = qemu_create_displaysurface_pixman(res->image);
-        if (!scanout->ds) {
-            return -EINVAL;
-        }
+
+        if (res->blob_size) {
+            assert(g->dmabuf.primary[i] != NULL);
+            g->dmabuf.primary[i]->buf.fd = res->dmabuf_fd;
+            dpy_gl_scanout_dmabuf(scanout->con, &g->dmabuf.primary[i]->buf);
+        } else {
+            scanout->ds = qemu_create_displaysurface_pixman(res->image);
+            if (!scanout->ds) {
+                return -EINVAL;
+            }
 #ifdef WIN32
-        qemu_displaysurface_win32_set_handle(scanout->ds, res->handle, 0);
+            qemu_displaysurface_win32_set_handle(scanout->ds, res->handle, 0);
 #endif
+            dpy_gfx_replace_surface(scanout->con, scanout->ds);
+            dpy_gfx_update_full(scanout->con);
+        }
 
-        dpy_gfx_replace_surface(scanout->con, scanout->ds);
-        dpy_gfx_update_full(scanout->con);
         if (scanout->cursor.resource_id) {
             update_cursor(g, &scanout->cursor);
         }
Signature · 1 line
2.34.1
#1 lore raw

Hi

Quoted 8 lines · On Thu, Mar 7, 2024 at 2:27 AM <[email protected]> wrote:

From: Dongwon Kim <[email protected]>

The guest surface needs to be updated with a blob scanout after resumed from saved vm state if blob is enabled.

v2: Rebased

This patch conflicts with the already reviewed (and almost in queue)
patch from https://patchew.org/QEMU/[email protected]/[email protected]/.

There are chances that it solves your problem, since it calls into virtio_gpu_do_set_scanout() which handles blob resources.

Could you check? And if it doesn't fix it, can you apply your solution on top of it?

thanks

Quoted 46 lines
Cc Marc-André Lureau <[email protected]>
Cc Vivek Kasireddy <[email protected]>
---
 hw/display/virtio-gpu.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
hw/display/virtio-gpu.c +14 -8
index 1c1ee230b3..01bc4f9565 100644
@@ -1422,16 +1422,23 @@ static int virtio_gpu_post_load(void *opaque, int version_id)
         if (!res) {
             return -EINVAL;
         }
-        scanout->ds = qemu_create_displaysurface_pixman(res->image);
-        if (!scanout->ds) {
-            return -EINVAL;
-        }
+
+        if (res->blob_size) {
+            assert(g->dmabuf.primary[i] != NULL);
+            g->dmabuf.primary[i]->buf.fd = res->dmabuf_fd;
+            dpy_gl_scanout_dmabuf(scanout->con, &g->dmabuf.primary[i]->buf);
+        } else {
+            scanout->ds = qemu_create_displaysurface_pixman(res->image);
+            if (!scanout->ds) {
+                return -EINVAL;
+            }
 #ifdef WIN32
-        qemu_displaysurface_win32_set_handle(scanout->ds, res->handle, 0);
+            qemu_displaysurface_win32_set_handle(scanout->ds, res->handle, 0);
 #endif
+            dpy_gfx_replace_surface(scanout->con, scanout->ds);
+            dpy_gfx_update_full(scanout->con);
+        }
 
-        dpy_gfx_replace_surface(scanout->con, scanout->ds);
-        dpy_gfx_update_full(scanout->con);
         if (scanout->cursor.resource_id) {
             update_cursor(g, &scanout->cursor);
         }
--

2.34.1

Signature · 1 line
Marc-André Lureau
#2 lore raw

Hi Marc-André,

Ok, seems like your commit would fix the problem I was trying to solve. I will test it and let you know the results.

Quoted 84 lines

-----Original Message-----
From: Marc-André Lureau <[email protected]>
Sent: Tuesday, March 12, 2024 4:35 AM
To: Kim, Dongwon <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v2] virtio-gpu: first surface update with blob scanout after resumed

Hi

Quoted 8 lines · On Thu, Mar 7, 2024 at 2:27 AM <[email protected]> wrote:

From: Dongwon Kim <[email protected]>

The guest surface needs to be updated with a blob scanout after resumed from saved vm state if blob is enabled.

v2: Rebased

This patch conflicts with the already reviewed (and almost in queue) patch from
https://patchew.org/QEMU/20240228122323.962826-1-
[email protected]/20240228122323.962826-3- [email protected]/.

There are chances that it solves your problem, since it calls into virtio_gpu_do_set_scanout() which handles blob resources.

Could you check? And if it doesn't fix it, can you apply your solution on top of it?

thanks

hw/display/virtio-gpu.c static int virtio_gpu_post_load(void *opaque, int

Quoted 12 lines
Cc Marc-André Lureau <[email protected]>
Cc Vivek Kasireddy <[email protected]>
---
 hw/display/virtio-gpu.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
hw/display/virtio-gpu.c index renamed from hw/display/virtio-gpu.c +0 -0

1c1ee230b3..01bc4f9565 100644

hw/display/virtio-gpu.c +0 -0
@@ -1422,16 +1422,23 @@ static int virtio_gpu_post_load(void *opaque, int

version_id)

Quoted 32 lines
hw/display/virtio-gpu.c +15 -8
         if (!res) {
             return -EINVAL;
         }
-        scanout->ds = qemu_create_displaysurface_pixman(res->image);
-        if (!scanout->ds) {
-            return -EINVAL;
-        }
+
+        if (res->blob_size) {
+            assert(g->dmabuf.primary[i] != NULL);
+            g->dmabuf.primary[i]->buf.fd = res->dmabuf_fd;
+            dpy_gl_scanout_dmabuf(scanout->con, &g->dmabuf.primary[i]->buf);
+        } else {
+            scanout->ds = qemu_create_displaysurface_pixman(res->image);
+            if (!scanout->ds) {
+                return -EINVAL;
+            }
 #ifdef WIN32
-        qemu_displaysurface_win32_set_handle(scanout->ds, res->handle, 0);
+            qemu_displaysurface_win32_set_handle(scanout->ds,
+ res->handle, 0);
 #endif
+            dpy_gfx_replace_surface(scanout->con, scanout->ds);
+            dpy_gfx_update_full(scanout->con);
+        }
 
-        dpy_gfx_replace_surface(scanout->con, scanout->ds);
-        dpy_gfx_update_full(scanout->con);
         if (scanout->cursor.resource_id) {
             update_cursor(g, &scanout->cursor);
         }
--
Quoted 3 lines

2.34.1

--
Marc-André Lureau