From nobody Wed Nov 5 16:55:56 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 15371651607261008.0715180436479; Sun, 16 Sep 2018 23:19:20 -0700 (PDT) Received: from localhost ([::1]:33853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1msH-0000ku-WC for importer@patchew.org; Mon, 17 Sep 2018 02:19:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47710) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1mqq-00009V-HN for qemu-devel@nongnu.org; Mon, 17 Sep 2018 02:17:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g1mqm-0002px-G0 for qemu-devel@nongnu.org; Mon, 17 Sep 2018 02:17:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59660) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g1mqm-0002or-8k for qemu-devel@nongnu.org; Mon, 17 Sep 2018 02:17:36 -0400 Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 880D23082123 for ; Mon, 17 Sep 2018 06:17:35 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-56.phx2.redhat.com [10.3.116.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62C448AD57; Mon, 17 Sep 2018 06:17:31 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DB46A50E12; Mon, 17 Sep 2018 08:17:29 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 17 Sep 2018 08:17:28 +0200 Message-Id: <20180917061729.22407-2-kraxel@redhat.com> In-Reply-To: <20180917061729.22407-1-kraxel@redhat.com> References: <20180917061729.22407-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 17 Sep 2018 06:17:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/2] stubs: add ramfb 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: Paolo Bonzini , Alex Williamson , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Needed to make sure code using ramfb (vfio) compiles properly even on platforms without fw_cfg (and therefore no ramfb) support. Signed-off-by: Gerd Hoffmann --- stubs/ramfb.c | 13 +++++++++++++ stubs/Makefile.objs | 1 + 2 files changed, 14 insertions(+) create mode 100644 stubs/ramfb.c diff --git a/stubs/ramfb.c b/stubs/ramfb.c new file mode 100644 index 0000000000..48143f3354 --- /dev/null +++ b/stubs/ramfb.c @@ -0,0 +1,13 @@ +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "hw/display/ramfb.h" + +void ramfb_display_update(QemuConsole *con, RAMFBState *s) +{ +} + +RAMFBState *ramfb_setup(Error **errp) +{ + error_setg(errp, "ramfb support not available"); + return NULL; +} diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index 53d3f32cb2..5dd0aeeec6 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -43,3 +43,4 @@ stub-obj-y +=3D xen-common.o stub-obj-y +=3D xen-hvm.o stub-obj-y +=3D pci-host-piix.o stub-obj-y +=3D ram-block.o +stub-obj-y +=3D ramfb.o --=20 2.9.3 From nobody Wed Nov 5 16:55:56 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 153716525290137.44027250661111; Sun, 16 Sep 2018 23:20:52 -0700 (PDT) Received: from localhost ([::1]:33868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1mtv-0001kV-Or for importer@patchew.org; Mon, 17 Sep 2018 02:20:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1mqq-00009X-Hj for qemu-devel@nongnu.org; Mon, 17 Sep 2018 02:17:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g1mqn-0002rT-Jh for qemu-devel@nongnu.org; Mon, 17 Sep 2018 02:17:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35930) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g1mqn-0002qt-BA for qemu-devel@nongnu.org; Mon, 17 Sep 2018 02:17:37 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AFBBBC0587DF for ; Mon, 17 Sep 2018 06:17:36 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-56.phx2.redhat.com [10.3.116.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 615526014B; Mon, 17 Sep 2018 06:17:31 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E92C450E18; Mon, 17 Sep 2018 08:17:29 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 17 Sep 2018 08:17:29 +0200 Message-Id: <20180917061729.22407-3-kraxel@redhat.com> In-Reply-To: <20180917061729.22407-1-kraxel@redhat.com> References: <20180917061729.22407-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 17 Sep 2018 06:17:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/2] hw/vfio/display: add ramfb support 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: Paolo Bonzini , Alex Williamson , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" So we have a boot display when using a vgpu as primary display. ramfb depends on a fw_cfg file. fw_cfg files can not be added and removed at runtime, therefore a ramfb-enabled vfio device can't be hotplugged. Add a nohotplug variant of the vfio-pci device (as child class). Add the ramfb property to the nohotplug variant only. So to enable the vgpu display with boot support use this: -device vfio-pci-nohotplug,display=3Don,ramfb=3Don,sysfsdev=3D... Signed-off-by: Gerd Hoffmann --- hw/vfio/pci.h | 1 + include/hw/vfio/vfio-common.h | 2 ++ hw/vfio/display.c | 12 ++++++++++++ hw/vfio/pci.c | 25 +++++++++++++++++++++++++ 4 files changed, 40 insertions(+) diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h index 52b065421a..904e286586 100644 --- a/hw/vfio/pci.h +++ b/hw/vfio/pci.h @@ -149,6 +149,7 @@ typedef struct VFIOPCIDevice { #define VFIO_FEATURE_ENABLE_IGD_OPREGION \ (1 << VFIO_FEATURE_ENABLE_IGD_OPREGION_BIT) OnOffAuto display; + bool enable_ramfb; int32_t bootindex; uint32_t igd_gms; OffAutoPCIBAR msix_relo; diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 821def0565..0d85a0a6f8 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -26,6 +26,7 @@ #include "qemu/queue.h" #include "qemu/notify.h" #include "ui/console.h" +#include "hw/display/ramfb.h" #ifdef CONFIG_LINUX #include #endif @@ -146,6 +147,7 @@ typedef struct VFIODMABuf { =20 typedef struct VFIODisplay { QemuConsole *con; + RAMFBState *ramfb; struct { VFIORegion buffer; DisplaySurface *surface; diff --git a/hw/vfio/display.c b/hw/vfio/display.c index 59c0e5d1d7..dead30e626 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -124,6 +124,9 @@ static void vfio_display_dmabuf_update(void *opaque) =20 primary =3D vfio_display_get_dmabuf(vdev, DRM_PLANE_TYPE_PRIMARY); if (primary =3D=3D NULL) { + if (dpy->ramfb) { + ramfb_display_update(dpy->con, dpy->ramfb); + } return; } =20 @@ -181,6 +184,9 @@ static int vfio_display_dmabuf_init(VFIOPCIDevice *vdev= , Error **errp) vdev->dpy->con =3D graphic_console_init(DEVICE(vdev), 0, &vfio_display_dmabuf_ops, vdev); + if (vdev->enable_ramfb) { + vdev->dpy->ramfb =3D ramfb_setup(errp); + } return 0; } =20 @@ -228,6 +234,9 @@ static void vfio_display_region_update(void *opaque) return; } if (!plane.drm_format || !plane.size) { + if (dpy->ramfb) { + ramfb_display_update(dpy->con, dpy->ramfb); + } return; } format =3D qemu_drm_format_to_pixman(plane.drm_format); @@ -300,6 +309,9 @@ static int vfio_display_region_init(VFIOPCIDevice *vdev= , Error **errp) vdev->dpy->con =3D graphic_console_init(DEVICE(vdev), 0, &vfio_display_region_ops, vdev); + if (vdev->enable_ramfb) { + vdev->dpy->ramfb =3D ramfb_setup(errp); + } return 0; } =20 diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 866f0deeb7..a0047f4942 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -3067,6 +3067,10 @@ static void vfio_realize(PCIDevice *pdev, Error **er= rp) goto out_teardown; } } + if (vdev->enable_ramfb && vdev->dpy =3D=3D NULL) { + error_setg(errp, "ramfb=3Don requires display=3Don"); + goto out_teardown; + } =20 vfio_register_err_notifier(vdev); vfio_register_req_notifier(vdev); @@ -3258,9 +3262,30 @@ static const TypeInfo vfio_pci_dev_info =3D { }, }; =20 +static Property vfio_pci_dev_nohotplug_properties[] =3D { + DEFINE_PROP_BOOL("ramfb", VFIOPCIDevice, enable_ramfb, false), + DEFINE_PROP_END_OF_LIST(), +}; + +static void vfio_pci_nohotplug_dev_class_init(ObjectClass *klass, void *da= ta) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->props =3D vfio_pci_dev_nohotplug_properties; + dc->hotpluggable =3D false; +} + +static const TypeInfo vfio_pci_nohotplug_dev_info =3D { + .name =3D "vfio-pci-nohotplug", + .parent =3D "vfio-pci", + .instance_size =3D sizeof(VFIOPCIDevice), + .class_init =3D vfio_pci_nohotplug_dev_class_init, +}; + static void register_vfio_pci_dev_type(void) { type_register_static(&vfio_pci_dev_info); + type_register_static(&vfio_pci_nohotplug_dev_info); } =20 type_init(register_vfio_pci_dev_type) --=20 2.9.3