From nobody Fri Oct 24 22:13:27 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 1519721927555518.5207265442749; Tue, 27 Feb 2018 00:58:47 -0800 (PST) Received: from localhost ([::1]:35596 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqb5y-0008QX-EF for importer@patchew.org; Tue, 27 Feb 2018 03:58:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55141) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eqazt-0003SN-HP for qemu-devel@nongnu.org; Tue, 27 Feb 2018 03:52:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eqazn-000822-41 for qemu-devel@nongnu.org; Tue, 27 Feb 2018 03:52:29 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57320 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 1eqazm-000819-Oo for qemu-devel@nongnu.org; Tue, 27 Feb 2018 03:52:23 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 464088D75D; Tue, 27 Feb 2018 08:52: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 D34301C724; Tue, 27 Feb 2018 08:52:17 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4696317538; Tue, 27 Feb 2018 09:52:10 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 27 Feb 2018 09:52:07 +0100 Message-Id: <20180227085209.19151-6-kraxel@redhat.com> In-Reply-To: <20180227085209.19151-1-kraxel@redhat.com> References: <20180227085209.19151-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 27 Feb 2018 08:52:22 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 27 Feb 2018 08:52:22 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 v5 5/7] 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. Adds a new vfio-pci-display device, which will export a display and is not hotpluggable. Signed-off-by: Gerd Hoffmann --- hw/vfio/pci.h | 3 +++ hw/vfio/display.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ hw/vfio/pci.c | 30 ++++++++++++++++++++++++++++++ hw/vfio/Makefile.objs | 2 +- 4 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 hw/vfio/display.c diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index f4aa13e021..fe2a7aeb4c 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) + bool display; int32_t bootindex; uint32_t igd_gms; OffAutoPCIBAR msix_relo; @@ -174,4 +175,6 @@ int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev, struct vfio_region_info *info, Error **errp); =20 +int vfio_display_probe(VFIOPCIDevice *vdev, Error **errp); + #endif /* HW_VFIO_VFIO_PCI_H */ diff --git a/hw/vfio/display.c b/hw/vfio/display.c new file mode 100644 index 0000000000..d9b4d07f20 --- /dev/null +++ b/hw/vfio/display.c @@ -0,0 +1,47 @@ +/* + * 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; + } + + error_setg(errp, "vfio: device doesn't support any (known) display met= hod"); + return -1; +} diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 033cc8dea1..d9d668a12b 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) { + 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); @@ -3120,6 +3127,13 @@ static void vfio_instance_init(Object *obj) pci_dev->cap_present |=3D QEMU_PCI_CAP_EXPRESS; } =20 +static void vfio_display_instance_init(Object *obj) +{ + VFIOPCIDevice *vdev =3D DO_UPCAST(VFIOPCIDevice, pdev, PCI_DEVICE(obj)= ); + + vdev->display =3D true; +} + static Property vfio_pci_dev_properties[] =3D { DEFINE_PROP_PCI_HOST_DEVADDR("host", VFIOPCIDevice, host), DEFINE_PROP_STRING("sysfsdev", VFIOPCIDevice, vbasedev.sysfsdev), @@ -3178,6 +3192,13 @@ static void vfio_pci_dev_class_init(ObjectClass *kla= ss, void *data) pdc->config_write =3D vfio_pci_write_config; } =20 +static void vfio_pci_display_dev_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->hotpluggable =3D false; +} + static const TypeInfo vfio_pci_dev_info =3D { .name =3D "vfio-pci", .parent =3D TYPE_PCI_DEVICE, @@ -3192,9 +3213,18 @@ static const TypeInfo vfio_pci_dev_info =3D { }, }; =20 +static const TypeInfo vfio_pci_display_dev_info =3D { + .name =3D "vfio-pci-display", + .parent =3D "vfio-pci", + .instance_size =3D sizeof(VFIOPCIDevice), + .class_init =3D vfio_pci_display_dev_class_init, + .instance_init =3D vfio_display_instance_init, +}; + static void register_vfio_pci_dev_type(void) { type_register_static(&vfio_pci_dev_info); + type_register_static(&vfio_pci_display_dev_info); } =20 type_init(register_vfio_pci_dev_type) 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