@@ -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)
{
@@ -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;
}
@@ -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);
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(+)