From patchwork Thu Apr 26 08:21:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Tina" X-Patchwork-Id: 10364927 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 594B1601BE for ; Thu, 26 Apr 2018 08:29:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49C2328B24 for ; Thu, 26 Apr 2018 08:29:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DC122908A; Thu, 26 Apr 2018 08:29:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C4F7728B24 for ; Thu, 26 Apr 2018 08:29:47 +0000 (UTC) Received: from localhost ([::1]:40949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBcHj-0005gH-1v for patchwork-qemu-devel@patchwork.kernel.org; Thu, 26 Apr 2018 04:29:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBcEb-0003td-Pr for qemu-devel@nongnu.org; Thu, 26 Apr 2018 04:26:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBcEa-0003Lr-Ua for qemu-devel@nongnu.org; Thu, 26 Apr 2018 04:26:33 -0400 Received: from mga07.intel.com ([134.134.136.100]:55657) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fBcEa-0003LZ-M5 for qemu-devel@nongnu.org; Thu, 26 Apr 2018 04:26:32 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Apr 2018 01:26:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,330,1520924400"; d="scan'208";a="37172043" Received: from tinazhang-linux-1.bj.intel.com ([10.238.158.97]) by orsmga006.jf.intel.com with ESMTP; 26 Apr 2018 01:26:30 -0700 From: Tina Zhang To: alex.williamson@redhat.com, kraxel@redhat.com, zhenyuw@linux.intel.com, hang.yuan@intel.com Date: Thu, 26 Apr 2018 16:21:20 +0800 Message-Id: <1524730880-7154-3-git-send-email-tina.zhang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524730880-7154-1-git-send-email-tina.zhang@intel.com> References: <1524730880-7154-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: 134.134.136.100 Subject: [Qemu-devel] [PATCH v3 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 v2->v3: - Limit vfio_display_reset to dma-buf based vfio display. (Gerd) Changes v1->v2: - Use dpy_gfx_update_full() update screen after reset. (Gerd) - Remove dpy_gfx_switch_surface(). (Gerd) Signed-off-by: Tina Zhang --- hw/vfio/display.c | 10 ++++++++++ hw/vfio/pci.c | 7 +++++++ hw/vfio/pci.h | 1 + 3 files changed, 18 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..648b29d 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3098,11 +3098,18 @@ static void vfio_pci_reset(DeviceState *dev) { PCIDevice *pdev = DO_UPCAST(PCIDevice, qdev, dev); VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev); + VFIODisplay *dpy = vdev->dpy; trace_vfio_pci_reset(vdev->vbasedev.name); vfio_pci_pre_reset(vdev); + /* vfio_display_reset is needed by dma-buf based vfio display */ + if (vdev->display != ON_OFF_AUTO_OFF && dpy && + dpy->dmabuf.primary) { + 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);