From nobody Wed May 8 19:43:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524471756621250.04812974352592; Mon, 23 Apr 2018 01:22:36 -0700 (PDT) Received: from localhost ([::1]:53840 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fAWk7-0008Oq-QG for importer@patchew.org; Mon, 23 Apr 2018 04:22:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fAWhm-0006xR-Rp for qemu-devel@nongnu.org; Mon, 23 Apr 2018 04:20:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fAWhj-0001On-N6 for qemu-devel@nongnu.org; Mon, 23 Apr 2018 04:20:10 -0400 Received: from mga01.intel.com ([192.55.52.88]:41385) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fAWhj-0001Ng-9J for qemu-devel@nongnu.org; Mon, 23 Apr 2018 04:20:07 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Apr 2018 01:20:05 -0700 Received: from tinazhang-linux-1.bj.intel.com ([10.238.158.97]) by orsmga007.jf.intel.com with ESMTP; 23 Apr 2018 01:20:00 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,317,1520924400"; d="scan'208";a="35411515" From: Tina Zhang To: alex.williamson@redhat.com, kraxel@redhat.com, zhenyuw@linux.intel.com, hang.yuan@intel.com Date: Mon, 23 Apr 2018 16:14:37 +0800 Message-Id: <1524471278-22546-2-git-send-email-tina.zhang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524471278-22546-1-git-send-email-tina.zhang@intel.com> References: <1524471278-22546-1-git-send-email-tina.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.88 Subject: [Qemu-devel] [PATCH 1/2] console: introduce dpy_gfx_switch_surface X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gvt-dev@lists.freedesktop.org, qemu-devel@nongnu.org, Tina Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" dpy_gfx_switch_surface is used to ask each valid DisplayChangeListener of a QemuConsole to switch to another DisplaySurface. Signed-off-by: Tina Zhang --- include/ui/console.h | 2 ++ ui/console.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/ui/console.h b/include/ui/console.h index 37a8d68..434033d 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -293,6 +293,8 @@ 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_replace_surface(QemuConsole *con, DisplaySurface *surface); +void dpy_gfx_switch_surface(QemuConsole *con, + DisplaySurface *surface); void dpy_text_cursor(QemuConsole *con, int x, int y); void dpy_text_update(QemuConsole *con, int x, int y, int w, int h); void dpy_text_resize(QemuConsole *con, int w, int h); diff --git a/ui/console.c b/ui/console.c index 3fb2f4e..2deb38b 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1595,6 +1595,22 @@ void dpy_gfx_replace_surface(QemuConsole *con, qemu_free_displaysurface(old_surface); } =20 +void dpy_gfx_switch_surface(QemuConsole *con, + DisplaySurface *surface) +{ + DisplayState *s =3D con->ds; + DisplayChangeListener *dcl; + + QLIST_FOREACH(dcl, &s->listeners, next) { + if (con !=3D (dcl->con ? dcl->con : active_console)) { + continue; + } + if (dcl->ops->dpy_gfx_switch) { + dcl->ops->dpy_gfx_switch(dcl, surface); + } + } +} + bool dpy_gfx_check_format(QemuConsole *con, pixman_format_code_t format) { --=20 2.7.4 From nobody Wed May 8 19:43:34 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524471765469754.2942856926336; Mon, 23 Apr 2018 01:22:45 -0700 (PDT) Received: from localhost ([::1]:53841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fAWkE-0008Tv-CV for importer@patchew.org; Mon, 23 Apr 2018 04:22:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fAWhv-00077T-FD for qemu-devel@nongnu.org; Mon, 23 Apr 2018 04:20:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fAWhp-0001UR-Pl for qemu-devel@nongnu.org; Mon, 23 Apr 2018 04:20:19 -0400 Received: from mga17.intel.com ([192.55.52.151]:24988) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fAWhp-0001SM-DZ for qemu-devel@nongnu.org; Mon, 23 Apr 2018 04:20:13 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Apr 2018 01:20:11 -0700 Received: from tinazhang-linux-1.bj.intel.com ([10.238.158.97]) by orsmga007.jf.intel.com with ESMTP; 23 Apr 2018 01:20:05 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,317,1520924400"; d="scan'208";a="35411532" From: Tina Zhang To: alex.williamson@redhat.com, kraxel@redhat.com, zhenyuw@linux.intel.com, hang.yuan@intel.com Date: Mon, 23 Apr 2018 16:14:38 +0800 Message-Id: <1524471278-22546-3-git-send-email-tina.zhang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524471278-22546-1-git-send-email-tina.zhang@intel.com> References: <1524471278-22546-1-git-send-email-tina.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.151 Subject: [Qemu-devel] [PATCH 2/2] ui: introduce vfio_display_reset X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gvt-dev@lists.freedesktop.org, qemu-devel@nongnu.org, Tina Zhang Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 --- 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) } =20 /* ---------------------------------------------------------------------- = */ +void vfio_display_reset(VFIOPCIDevice *vdev) +{ + DisplaySurface *surface; + + if (!vdev || !vdev->dpy || !vdev->dpy->con) { + return; + } + + surface =3D 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); +} =20 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) =20 vfio_pci_pre_reset(vdev); =20 + if (vdev->display !=3D 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); =20 +void vfio_display_reset(VFIOPCIDevice *vdev); int vfio_display_probe(VFIOPCIDevice *vdev, Error **errp); void vfio_display_finalize(VFIOPCIDevice *vdev); =20 --=20 2.7.4