From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Alex Williamson <alex.williamson@redhat.com>,
Tina Zhang <tina.zhang@intel.com>,
intel-gvt-dev@lists.freedesktop.org,
Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [RfC PATCH 4/6] vfio/display: core & wireup
Date: Tue, 10 Oct 2017 16:03:32 +0200 [thread overview]
Message-ID: <20171010140334.8231-5-kraxel@redhat.com> (raw)
In-Reply-To: <20171010140334.8231-1-kraxel@redhat.com>
Infrastructure for display support. Must be enabled
using x-display property for now.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/vfio/pci.h | 4 ++++
hw/vfio/display.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
hw/vfio/pci.c | 9 +++++++++
hw/vfio/Makefile.objs | 2 +-
4 files changed, 60 insertions(+), 1 deletion(-)
create mode 100644 hw/vfio/display.c
diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
index 502a5755b9..3c1b0a33ab 100644
--- a/hw/vfio/pci.h
+++ b/hw/vfio/pci.h
@@ -132,6 +132,8 @@ typedef struct VFIOPCIDevice {
#define VFIO_FEATURE_ENABLE_IGD_OPREGION_BIT 2
#define VFIO_FEATURE_ENABLE_IGD_OPREGION \
(1 << VFIO_FEATURE_ENABLE_IGD_OPREGION_BIT)
+#define VFIO_FEATURE_ENABLE_DISPLAY_BIT 3
+#define VFIO_FEATURE_ENABLE_DISPLAY (1 << VFIO_FEATURE_ENABLE_DISPLAY_BIT)
int32_t bootindex;
uint32_t igd_gms;
uint8_t pm_cap;
@@ -171,4 +173,6 @@ int vfio_pci_igd_opregion_init(VFIOPCIDevice *vdev,
struct vfio_region_info *info,
Error **errp);
+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..064ec95f3e
--- /dev/null
+++ b/hw/vfio/display.c
@@ -0,0 +1,46 @@
+/*
+ * 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 <linux/vfio.h>
+#include <sys/ioctl.h>
+
+#include "sysemu/sysemu.h"
+#include "ui/console.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 = sizeof(probe);
+ probe.flags = VFIO_GFX_PLANE_TYPE_PROBE | VFIO_GFX_PLANE_TYPE_DMABUF;
+ ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_QUERY_GFX_PLANE, &probe);
+ if (ret == 0) {
+ error_setg(errp, "vfio-display: dmabuf support not implemented yet");
+ return -1;
+ }
+
+ memset(&probe, 0, sizeof(probe));
+ probe.argsz = sizeof(probe);
+ probe.flags = VFIO_GFX_PLANE_TYPE_PROBE | VFIO_GFX_PLANE_TYPE_REGION;
+ ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_QUERY_GFX_PLANE, &probe);
+ if (ret == 0) {
+ error_setg(errp, "vfio-display: region support not implemented yet");
+ return -1;
+ }
+
+ error_setg(errp, "vfio: device doesn't support any (known) display method");
+ return -1;
+}
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 9e86db7c3b..91ac7258a3 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2873,6 +2873,13 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
}
}
+ if (vdev->features & VFIO_FEATURE_ENABLE_DISPLAY) {
+ ret = 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);
@@ -2985,6 +2992,8 @@ static Property vfio_pci_dev_properties[] = {
VFIO_FEATURE_ENABLE_REQ_BIT, true),
DEFINE_PROP_BIT("x-igd-opregion", VFIOPCIDevice, features,
VFIO_FEATURE_ENABLE_IGD_OPREGION_BIT, false),
+ DEFINE_PROP_BIT("x-display", VFIOPCIDevice, features,
+ VFIO_FEATURE_ENABLE_DISPLAY_BIT, false),
DEFINE_PROP_BOOL("x-no-mmap", VFIOPCIDevice, vbasedev.no_mmap, false),
DEFINE_PROP_BOOL("x-no-kvm-intx", VFIOPCIDevice, no_kvm_intx, false),
DEFINE_PROP_BOOL("x-no-kvm-msi", VFIOPCIDevice, no_kvm_msi, false),
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) += common.o
-obj-$(CONFIG_PCI) += pci.o pci-quirks.o
+obj-$(CONFIG_PCI) += pci.o pci-quirks.o display.o
obj-$(CONFIG_VFIO_CCW) += ccw.o
obj-$(CONFIG_SOFTMMU) += platform.o
obj-$(CONFIG_VFIO_XGMAC) += calxeda-xgmac.o
--
2.9.3
next prev parent reply other threads:[~2017-10-10 14:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-10 14:03 [Qemu-devel] [RfC PATCH 0/6] vfio: add display support Gerd Hoffmann
2017-10-10 14:03 ` [Qemu-devel] [RfC PATCH 1/6] headers: update linux-headers/linux/vfio.h (intel-gvt kernel patches, v15) Gerd Hoffmann
2017-10-10 14:03 ` [Qemu-devel] [RfC PATCH 2/6] headers: add drm/drm_fourcc.h to standard-headers Gerd Hoffmann
2017-10-10 14:03 ` [Qemu-devel] [RfC PATCH 3/6] ui/pixman: add qemu_drm_format_to_pixman() Gerd Hoffmann
2017-10-10 14:03 ` Gerd Hoffmann [this message]
2017-10-10 14:03 ` [Qemu-devel] [RfC PATCH 5/6] vfio/display: adding region support Gerd Hoffmann
2017-10-10 20:27 ` Alex Williamson
2017-10-11 10:47 ` Gerd Hoffmann
2017-10-11 16:55 ` Alex Williamson
2017-11-10 10:48 ` Gerd Hoffmann
2017-10-10 14:03 ` [Qemu-devel] [RfC PATCH 6/6] vfio/display: add dmabuf support (v15) Gerd Hoffmann
2017-10-10 20:27 ` Alex Williamson
2017-10-11 7:01 ` Gerd Hoffmann
2017-10-10 14:20 ` [Qemu-devel] [RfC PATCH 0/6] vfio: add display support no-reply
2017-10-10 14:23 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171010140334.8231-5-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=intel-gvt-dev@lists.freedesktop.org \
--cc=qemu-devel@nongnu.org \
--cc=tina.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).