From nobody Fri Oct 24 12:46:25 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519821215904698.8910780077449; Wed, 28 Feb 2018 04:33:35 -0800 (PST) Received: from localhost ([::1]:43712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er0vO-0003kI-KH for importer@patchew.org; Wed, 28 Feb 2018 07:33:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er0tK-0002Xi-SE for qemu-devel@nongnu.org; Wed, 28 Feb 2018 07:31:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1er0tG-0000WX-UW for qemu-devel@nongnu.org; Wed, 28 Feb 2018 07:31:26 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60196 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1er0tG-0000VL-PO for qemu-devel@nongnu.org; Wed, 28 Feb 2018 07:31:22 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6023F402290A; Wed, 28 Feb 2018 12:31:22 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-147.ams2.redhat.com [10.36.116.147]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4E81213AEF5; Wed, 28 Feb 2018 12:31:21 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 188CE960; Wed, 28 Feb 2018 13:31:11 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 28 Feb 2018 13:31:08 +0100 Message-Id: <20180228123110.6507-8-kraxel@redhat.com> In-Reply-To: <20180228123110.6507-1-kraxel@redhat.com> References: <20180228123110.6507-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 28 Feb 2018 12:31:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 28 Feb 2018 12:31:22 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v6 7/9] vfio/display: core & wireup 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: Alex Williamson , Gerd Hoffmann , intel-gvt-dev@lists.freedesktop.org, Kirti Wankhede , 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" Infrastructure for display support. Must be enabled using 'display' property. Signed-off-by: Gerd Hoffmann --- hw/vfio/pci.h | 4 ++++ hw/vfio/display.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ hw/vfio/pci.c | 10 +++++++++ hw/vfio/Makefile.objs | 2 +- 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 hw/vfio/display.c diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index f4aa13e021..a846cf6237 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -133,6 +133,7 @@ typedef struct VFIOPCIDevice { #define VFIO_FEATURE_ENABLE_IGD_OPREGION_BIT 2 #define VFIO_FEATURE_ENABLE_IGD_OPREGION \ (1 << VFIO_FEATURE_ENABLE_IGD_OPREGION_BIT) + OnOffAuto display; int32_t bootindex; uint32_t igd_gms; OffAutoPCIBAR msix_relo; @@ -174,4 +175,7 @@ int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, struct vfio_region_info *info, Error **errp); =20 +int vfio_display_probe(VFIOPCIDevice *vdev, Error **errp); +void vfio_display_finalize(VFIOPCIDevice *vdev); + #endif /* HW_VFIO_VFIO_PCI_H */ diff --git a/hw/vfio/display.c b/hw/vfio/display.c new file mode 100644 index 0000000000..3e997f8a44 --- /dev/null +++ b/hw/vfio/display.c @@ -0,0 +1,56 @@ +/* + * display support for mdev based vgpu devices + * + * Copyright Red Hat, Inc. 2017 + * + * Authors: + * Gerd Hoffmann + * + * This work is licensed under the terms of the GNU GPL, version 2. See + * the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include +#include + +#include "sysemu/sysemu.h" +#include "ui/console.h" +#include "qapi/error.h" +#include "pci.h" + +int vfio_display_probe(VFIOPCIDevice *vdev, Error **errp) +{ + struct vfio_device_gfx_plane_info probe; + int ret; + + memset(&probe, 0, sizeof(probe)); + probe.argsz =3D sizeof(probe); + probe.flags =3D VFIO_GFX_PLANE_TYPE_PROBE | VFIO_GFX_PLANE_TYPE_DMABUF; + ret =3D ioctl(vdev->vbasedev.fd, VFIO_DEVICE_QUERY_GFX_PLANE, &probe); + if (ret =3D=3D 0) { + error_setg(errp, "vfio-display: dmabuf support not implemented yet= "); + return -1; + } + + memset(&probe, 0, sizeof(probe)); + probe.argsz =3D sizeof(probe); + probe.flags =3D VFIO_GFX_PLANE_TYPE_PROBE | VFIO_GFX_PLANE_TYPE_REGION; + ret =3D ioctl(vdev->vbasedev.fd, VFIO_DEVICE_QUERY_GFX_PLANE, &probe); + if (ret =3D=3D 0) { + error_setg(errp, "vfio-display: region support not implemented yet= "); + return -1; + } + + if (vdev->display =3D=3D ON_OFF_AUTO_AUTO) { + /* not an error in automatic mode */ + return 0; + } + + error_setg(errp, "vfio: device doesn't support any (known) display met= hod"); + return -1; +} + +void vfio_display_finalize(VFIOPCIDevice *vdev) +{ +} diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 033cc8dea1..20f93bef74 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3015,6 +3015,13 @@ static void vfio_realize(PCIDevice *pdev, Error **er= rp) } } =20 + if (vdev->display !=3D ON_OFF_AUTO_OFF) { + ret =3D vfio_display_probe(vdev, errp); + if (ret) { + goto out_teardown; + } + } + vfio_register_err_notifier(vdev); vfio_register_req_notifier(vdev); vfio_setup_resetfn_quirk(vdev); @@ -3035,6 +3042,7 @@ static void vfio_instance_finalize(Object *obj) VFIOPCIDevice *vdev =3D DO_UPCAST(VFIOPCIDevice, pdev, pci_dev); VFIOGroup *group =3D vdev->vbasedev.group; =20 + vfio_display_finalize(vdev); vfio_bars_finalize(vdev); g_free(vdev->emulated_config_bits); g_free(vdev->rom); @@ -3123,6 +3131,8 @@ static void vfio_instance_init(Object *obj) static Property vfio_pci_dev_properties[] =3D { DEFINE_PROP_PCI_HOST_DEVADDR("host", VFIOPCIDevice, host), DEFINE_PROP_STRING("sysfsdev", VFIOPCIDevice, vbasedev.sysfsdev), + DEFINE_PROP_ON_OFF_AUTO("display", VFIOPCIDevice, + display, ON_OFF_AUTO_AUTO), DEFINE_PROP_UINT32("x-intx-mmap-timeout-ms", VFIOPCIDevice, intx.mmap_timeout, 1100), DEFINE_PROP_BIT("x-vga", VFIOPCIDevice, features, diff --git a/hw/vfio/Makefile.objs b/hw/vfio/Makefile.objs index c3ab9097f1..a2e7a0a7cf 100644 --- a/hw/vfio/Makefile.objs +++ b/hw/vfio/Makefile.objs @@ -1,6 +1,6 @@ ifeq ($(CONFIG_LINUX), y) obj-$(CONFIG_SOFTMMU) +=3D common.o -obj-$(CONFIG_PCI) +=3D pci.o pci-quirks.o +obj-$(CONFIG_PCI) +=3D pci.o pci-quirks.o display.o obj-$(CONFIG_VFIO_CCW) +=3D ccw.o obj-$(CONFIG_SOFTMMU) +=3D platform.o obj-$(CONFIG_VFIO_XGMAC) +=3D calxeda-xgmac.o --=20 2.9.3