[PATCH v2] virtio-gpu: first surface update with blob scanout after resumed

dongwon.kim@intel.com posted 1 patch 1 month, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20240306222535.3236855-1-dongwon.kim@intel.com
Maintainers: Gerd Hoffmann <kraxel@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>
hw/display/virtio-gpu.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
[PATCH v2] virtio-gpu: first surface update with blob scanout after resumed
Posted by dongwon.kim@intel.com 1 month, 3 weeks ago
From: Dongwon Kim <dongwon.kim@intel.com>

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 <marcandre.lureau@redhat.com>
Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
---
 hw/display/virtio-gpu.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 1c1ee230b3..01bc4f9565 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -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


Re: [PATCH v2] virtio-gpu: first surface update with blob scanout after resumed
Posted by Marc-André Lureau 1 month, 2 weeks ago
Hi

On Thu, Mar 7, 2024 at 2:27 AM <dongwon.kim@intel.com> wrote:
>
> From: Dongwon Kim <dongwon.kim@intel.com>
>
> 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-marcandre.lureau@redhat.com/20240228122323.962826-3-marcandre.lureau@redhat.com/.

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

> Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
> Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
> Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
> ---
>  hw/display/virtio-gpu.c | 21 ++++++++++++++-------
>  1 file changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> index 1c1ee230b3..01bc4f9565 100644
> --- a/hw/display/virtio-gpu.c
> +++ b/hw/display/virtio-gpu.c
> @@ -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
>
>


-- 
Marc-André Lureau
RE: [PATCH v2] virtio-gpu: first surface update with blob scanout after resumed
Posted by Kim, Dongwon 1 month, 2 weeks ago
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.

> -----Original Message-----
> From: Marc-André Lureau <marcandre.lureau@gmail.com>
> Sent: Tuesday, March 12, 2024 4:35 AM
> To: Kim, Dongwon <dongwon.kim@intel.com>
> Cc: qemu-devel@nongnu.org
> Subject: Re: [PATCH v2] virtio-gpu: first surface update with blob scanout after
> resumed
> 
> Hi
> 
> On Thu, Mar 7, 2024 at 2:27 AM <dongwon.kim@intel.com> wrote:
> >
> > From: Dongwon Kim <dongwon.kim@intel.com>
> >
> > 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-
> marcandre.lureau@redhat.com/20240228122323.962826-3-
> marcandre.lureau@redhat.com/.
> 
> 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
> 
> > Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
> > Cc: Vivek Kasireddy <vivek.kasireddy@intel.com>
> > Signed-off-by: Dongwon Kim <dongwon.kim@intel.com>
> > ---
> >  hw/display/virtio-gpu.c | 21 ++++++++++++++-------
> >  1 file changed, 14 insertions(+), 7 deletions(-)
> >
> > diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index
> > 1c1ee230b3..01bc4f9565 100644
> > --- a/hw/display/virtio-gpu.c
> > +++ b/hw/display/virtio-gpu.c
> > @@ -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
> >
> >
> 
> 
> --
> Marc-André Lureau