All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/2] Add vfio display reset handling
@ 2018-04-25  8:01 Tina Zhang
  2018-04-25  8:01 ` [Qemu-devel] [PATCH v2 1/2] console: introduce dpy_gfx_update_full Tina Zhang
  2018-04-25  8:01 ` [Qemu-devel] [PATCH v2 2/2] ui: introduce vfio_display_reset Tina Zhang
  0 siblings, 2 replies; 4+ messages in thread
From: Tina Zhang @ 2018-04-25  8:01 UTC (permalink / raw)
  To: alex.williamson, kraxel, zhenyuw, hang.yuan
  Cc: Tina Zhang, intel-gvt-dev, qemu-devel

vfio display needs to release the invalid display resource and disable
the scanout mode during guest OS reboot, otherwise bugs come out.

Thanks hang.yuan@intel.com for helping root cause the issue.

v1->v2:
 - remove dpy_gfx_switch_surface. (Gerd)
 - add dpy_gfx_update_full. (Gerd)

Tina Zhang (2):
  console: introduce dpy_gfx_update_full
  ui: introduce vfio_display_reset

 hw/vfio/display.c    | 10 ++++++++++
 hw/vfio/pci.c        |  4 ++++
 hw/vfio/pci.h        |  1 +
 include/ui/console.h |  1 +
 ui/console.c         | 10 ++++++++++
 5 files changed, 26 insertions(+)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 1/2] console: introduce dpy_gfx_update_full
  2018-04-25  8:01 [Qemu-devel] [PATCH v2 0/2] Add vfio display reset handling Tina Zhang
@ 2018-04-25  8:01 ` Tina Zhang
  2018-04-25  8:01 ` [Qemu-devel] [PATCH v2 2/2] ui: introduce vfio_display_reset Tina Zhang
  1 sibling, 0 replies; 4+ messages in thread
From: Tina Zhang @ 2018-04-25  8:01 UTC (permalink / raw)
  To: alex.williamson, kraxel, zhenyuw, hang.yuan
  Cc: Tina Zhang, intel-gvt-dev, qemu-devel

dpy_gfx_update_full is used to do the whole display surface update.

This function is proposed by Gerd Hoffmann.

Signed-off-by: Tina Zhang <tina.zhang@intel.com>
---
 include/ui/console.h |  1 +
 ui/console.c         | 10 ++++++++++
 2 files changed, 11 insertions(+)

diff --git a/include/ui/console.h b/include/ui/console.h
index 37a8d68..981b519 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -291,6 +291,7 @@ bool dpy_ui_info_supported(QemuConsole *con);
 int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info);
 
 void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h);
+void dpy_gfx_update_full(QemuConsole *con);
 void dpy_gfx_replace_surface(QemuConsole *con,
                              DisplaySurface *surface);
 void dpy_text_cursor(QemuConsole *con, int x, int y);
diff --git a/ui/console.c b/ui/console.c
index 3fb2f4e..b02510c 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1574,6 +1574,16 @@ void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h)
     }
 }
 
+void dpy_gfx_update_full(QemuConsole *con)
+{
+    if (!con->surface) {
+        return;
+    }
+    dpy_gfx_update(con, 0, 0,
+                   surface_width(con->surface),
+                   surface_height(con->surface));
+}
+
 void dpy_gfx_replace_surface(QemuConsole *con,
                              DisplaySurface *surface)
 {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH v2 2/2] ui: introduce vfio_display_reset
  2018-04-25  8:01 [Qemu-devel] [PATCH v2 0/2] Add vfio display reset handling Tina Zhang
  2018-04-25  8:01 ` [Qemu-devel] [PATCH v2 1/2] console: introduce dpy_gfx_update_full Tina Zhang
@ 2018-04-25  8:01 ` Tina Zhang
  2018-04-25 11:46   ` Gerd Hoffmann
  1 sibling, 1 reply; 4+ messages in thread
From: Tina Zhang @ 2018-04-25  8:01 UTC (permalink / raw)
  To: alex.williamson, kraxel, zhenyuw, hang.yuan
  Cc: Tina Zhang, intel-gvt-dev, qemu-devel

During guest OS reboot, guest framebuffer is invalid. It will cause
bugs, if the invalid guest framebuffer is still used by host.

This patch is to introduce vfio_display_reset which is invoked
during vfio display reset. This vfio_display_reset function is used
to release the invalid display resource, disable scanout mode and
replace the invalid surface with QemuConsole's DisplaySurafce.

This patch can fix the GPU hang issue caused by gd_egl_draw during
guest OS reboot.

Changes v1->v2:
 - Use dpy_gfx_update_full() to update screen after reset. (Gerd)
 - Remove dpy_gfx_switch_surface(). (Gerd)

Signed-off-by: Tina Zhang <tina.zhang@intel.com>
---
 hw/vfio/display.c | 10 ++++++++++
 hw/vfio/pci.c     |  4 ++++
 hw/vfio/pci.h     |  1 +
 3 files changed, 15 insertions(+)

diff --git a/hw/vfio/display.c b/hw/vfio/display.c
index 7d727ce..dc4b1e9 100644
--- a/hw/vfio/display.c
+++ b/hw/vfio/display.c
@@ -198,6 +198,16 @@ static void vfio_display_dmabuf_exit(VFIODisplay *dpy)
 }
 
 /* ---------------------------------------------------------------------- */
+void vfio_display_reset(VFIOPCIDevice *vdev)
+{
+    if (!vdev || !vdev->dpy || !vdev->dpy->con) {
+        return;
+    }
+
+    dpy_gl_scanout_disable(vdev->dpy->con);
+    vfio_display_dmabuf_exit(vdev->dpy);
+    dpy_gfx_update_full(vdev->dpy->con);
+}
 
 static void vfio_display_region_update(void *opaque)
 {
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index b9bc6cd..4947fe3 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -3103,6 +3103,10 @@ static void vfio_pci_reset(DeviceState *dev)
 
     vfio_pci_pre_reset(vdev);
 
+    if (vdev->display != ON_OFF_AUTO_OFF) {
+        vfio_display_reset(vdev);
+    }
+
     if (vdev->resetfn && !vdev->resetfn(vdev)) {
         goto post_reset;
     }
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index 629c875..59ab775 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -176,6 +176,7 @@ int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
                                struct vfio_region_info *info,
                                Error **errp);
 
+void vfio_display_reset(VFIOPCIDevice *vdev);
 int vfio_display_probe(VFIOPCIDevice *vdev, Error **errp);
 void vfio_display_finalize(VFIOPCIDevice *vdev);
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH v2 2/2] ui: introduce vfio_display_reset
  2018-04-25  8:01 ` [Qemu-devel] [PATCH v2 2/2] ui: introduce vfio_display_reset Tina Zhang
@ 2018-04-25 11:46   ` Gerd Hoffmann
  0 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2018-04-25 11:46 UTC (permalink / raw)
  To: Tina Zhang; +Cc: alex.williamson, zhenyuw, hang.yuan, intel-gvt-dev, qemu-devel

>  /* ---------------------------------------------------------------------- */
> +void vfio_display_reset(VFIOPCIDevice *vdev)
> +{
> +    if (!vdev || !vdev->dpy || !vdev->dpy->con) {
> +        return;
> +    }
> +
> +    dpy_gl_scanout_disable(vdev->dpy->con);

This should not be called with a region-based vfio display.
Please add a check.

Otherwise looks fine to me.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-25 11:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-25  8:01 [Qemu-devel] [PATCH v2 0/2] Add vfio display reset handling Tina Zhang
2018-04-25  8:01 ` [Qemu-devel] [PATCH v2 1/2] console: introduce dpy_gfx_update_full Tina Zhang
2018-04-25  8:01 ` [Qemu-devel] [PATCH v2 2/2] ui: introduce vfio_display_reset Tina Zhang
2018-04-25 11:46   ` Gerd Hoffmann

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.