qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Tina Zhang <tina.zhang@intel.com>
To: alex.williamson@redhat.com, kraxel@redhat.com,
	zhenyuw@linux.intel.com, hang.yuan@intel.com
Cc: Tina Zhang <tina.zhang@intel.com>,
	intel-gvt-dev@lists.freedesktop.org, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 2/2] ui: introduce vfio_display_reset
Date: Mon, 23 Apr 2018 16:14:38 +0800	[thread overview]
Message-ID: <1524471278-22546-3-git-send-email-tina.zhang@intel.com> (raw)
In-Reply-To: <1524471278-22546-1-git-send-email-tina.zhang@intel.com>

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.

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

diff --git a/hw/vfio/display.c b/hw/vfio/display.c
index 7d727ce..65185c7 100644
--- a/hw/vfio/display.c
+++ b/hw/vfio/display.c
@@ -198,6 +198,26 @@ static void vfio_display_dmabuf_exit(VFIODisplay *dpy)
 }
 
 /* ---------------------------------------------------------------------- */
+void vfio_display_reset(VFIOPCIDevice *vdev)
+{
+    DisplaySurface *surface;
+
+    if (!vdev || !vdev->dpy || !vdev->dpy->con) {
+        return;
+    }
+
+    surface = qemu_console_surface(vdev->dpy->con);
+    if (!surface) {
+        return;
+    }
+
+    /* During reset, disable scanout mode and */
+    /* use QemuConsole DisplaySurface */
+    dpy_gl_scanout_disable(vdev->dpy->con);
+    dpy_gfx_switch_surface(vdev->dpy->con, surface);
+
+    vfio_display_dmabuf_exit(vdev->dpy);
+}
 
 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

  parent reply	other threads:[~2018-04-23  8:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-23  8:14 [Qemu-devel] [PATCH 0/2] Add vfio display reset handling Tina Zhang
2018-04-23  8:14 ` [Qemu-devel] [PATCH 1/2] console: introduce dpy_gfx_switch_surface Tina Zhang
2018-04-23 13:04   ` Gerd Hoffmann
2018-04-23  8:14 ` Tina Zhang [this message]
2018-04-23 13:12   ` [Qemu-devel] [PATCH 2/2] ui: introduce vfio_display_reset Gerd Hoffmann
2018-04-24  6:54     ` Zhang, Tina
2018-04-24  8:16       ` Gerd Hoffmann
2018-04-25  7:23         ` Zhang, Tina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1524471278-22546-3-git-send-email-tina.zhang@intel.com \
    --to=tina.zhang@intel.com \
    --cc=alex.williamson@redhat.com \
    --cc=hang.yuan@intel.com \
    --cc=intel-gvt-dev@lists.freedesktop.org \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhenyuw@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).