Deliver vGPU page flip events to userspace
Subsystems (5)
v2 cover Deliver vGPU page flip events to userspace
This series tries to send the vGPU page flip events to userspace, which can be used by QEMU UI for rendering and display with the latest guest framebuffers.
v2: Use VFIO irq chain to get eventfds from userspace instead of adding a new ABI. (Alex)
v1: https://patchwork.kernel.org/cover/10962341/
Tina Zhang (3):
vfio: Use capability chains to handle device specific irq drm/i915/gvt: Leverage irq capability chain to get eventfd drm/i915/gvt: Send plane flip events to user space
drivers/gpu/drm/i915/gvt/display.c | 10 +- drivers/gpu/drm/i915/gvt/gvt.h | 4 + drivers/gpu/drm/i915/gvt/handlers.c | 20 ++- drivers/gpu/drm/i915/gvt/hypercall.h | 1 + drivers/gpu/drm/i915/gvt/kvmgt.c | 208 +++++++++++++++++++++++++-- drivers/gpu/drm/i915/gvt/mpt.h | 16 +++ include/uapi/linux/vfio.h | 23 ++- 7 files changed, 268 insertions(+), 14 deletions(-)
Signature · 1 line
2.17.1
RFC PATCH v2 1/3 vfio: Use capability chains to handle device specific irq
Caps the number of irqs with fixed indexes and uses capability chains to chain device specific irqs.
VFIO vGPU leverages this mechanism to trigger primary plane and cursor plane page flip event to the user space.
--- include/uapi/linux/vfio.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
include/uapi/linux/vfio.h +22 -1
@@ -444,11 +444,31 @@ struct vfio_irq_info {#define VFIO_IRQ_INFO_MASKABLE (1 << 1)#define VFIO_IRQ_INFO_AUTOMASKED (1 << 2)#define VFIO_IRQ_INFO_NORESIZE (1 << 3) +#define VFIO_IRQ_INFO_FLAG_CAPS (1 << 4)/* Info supports caps */ __u32 index;/* IRQ index */ +__u32 cap_offset;/* Offset within info struct of first cap */ __u32 count;/* Number of IRQs within this index */ };#define VFIO_DEVICE_GET_IRQ_INFO _IO(VFIO_TYPE, VFIO_BASE + 9) +/* +* The irq type capability allows irqs unique to a specific device or +* class of devices to be exposed. +* +* The structures below define version 1 of this capability. +*/ +#define VFIO_IRQ_INFO_CAP_TYPE 3 + +struct vfio_irq_info_cap_type { +struct vfio_info_cap_header header; +__u32 type;/* global per bus driver */ +__u32 subtype;/* type specific */ +}; + +#define VFIO_IRQ_TYPE_GFX (1) +#define VFIO_IRQ_SUBTYPE_GFX_PRI_PLANE_FLIP (1) +#define VFIO_IRQ_SUBTYPE_GFX_CUR_PLANE_FLIP (2) +/** * VFIO_DEVICE_SET_IRQS - _IOW(VFIO_TYPE, VFIO_BASE + 10, struct vfio_irq_set) *
@@ -550,7 +570,8 @@ enum {VFIO_PCI_MSIX_IRQ_INDEX ,VFIO_PCI_ERR_IRQ_INDEX ,VFIO_PCI_REQ_IRQ_INDEX , - VFIO_PCI_NUM_IRQS +VFIO_PCI_NUM_IRQS =5 /* Fixed user ABI, IRQ indexes >=5 use */ + /* device specific cap to define content */ };/*
Signature · 1 line
2.17.1
RFC PATCH v2 2/3 drm/i915/gvt: Leverage irq capability chain to get eventfd
In reply to Tina ZhangGVT-g display model leverages vfio irq capability chain to get eventfd from the user space. With the eventfd, GVT-g display model in kernel can deliver a plane update event to user space.
--- drivers/gpu/drm/i915/gvt/display.c | 10 +- drivers/gpu/drm/i915/gvt/gvt.h | 4 + drivers/gpu/drm/i915/gvt/hypercall.h | 1 + drivers/gpu/drm/i915/gvt/kvmgt.c | 208 +++++++++++++++++++++++++-- drivers/gpu/drm/i915/gvt/mpt.h | 16 +++ 5 files changed, 229 insertions(+), 10 deletions(-)
drivers/gpu/drm/i915/gvt/display.c +8 -2
@@ -506,16 +506,22 @@ void intel_vgpu_clean_display(struct intel_vgpu *vgpu)int intel_vgpu_init_display (struct intel_vgpu *vgpu,u64 resolution) {struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv; +int ret;intel_vgpu_init_i2c_edid (vgpu);if (IS_SKYLAKE (dev_priv) ||IS_KABYLAKE (dev_priv) ||IS_COFFEELAKE (dev_priv)) -return setup_virtual_dp_monitor (vgpu,PORT_D ,GVT_DP_D , + ret =setup_virtual_dp_monitor (vgpu,PORT_D ,GVT_DP_D , resolution);else -return setup_virtual_dp_monitor (vgpu,PORT_B ,GVT_DP_B , + ret =setup_virtual_dp_monitor (vgpu,PORT_B ,GVT_DP_B , resolution); + +if (ret ==0 ) +intel_gvt_hypervisor_register_display_irq (vgpu); + +return ret; }/**
drivers/gpu/drm/i915/gvt/gvt.h +4 -0
@@ -201,8 +201,12 @@ struct intel_vgpu {struct mdev_device *mdev;struct vfio_region *region;int num_regions; +struct vfio_irq *irq; +int num_irqs;struct eventfd_ctx *intx_trigger;struct eventfd_ctx *msi_trigger; +struct eventfd_ctx *pri_flip_trigger; +struct eventfd_ctx *cur_flip_trigger;/* * Two caches are used to avoid mapping duplicated pages (eg.
drivers/gpu/drm/i915/gvt/hypercall.h +1 -0
@@ -68,6 +68,7 @@ struct intel_gvt_mpt { bool map);int (*set_opregion)(void *vgpu);int (*set_edid)(void *vgpu,int port_num); +int (*register_display_irq)(void *vgpu);int (*get_vfio_device)(void *vgpu);void (*put_vfio_device)(void *vgpu);bool (*is_valid_gfn)(unsigned long handle,unsigned long gfn);
drivers/gpu/drm/i915/gvt/kvmgt.c +200 -8
289 lines not on this page · raw message
drivers/gpu/drm/i915/gvt/mpt.h +16 -0
@@ -330,6 +330,22 @@ static inline int intel_gvt_hypervisor_set_edid(struct intel_vgpu *vgpu,return intel_gvt_host.mpt->set_edid (vgpu, port_num); } +/** +* intel_gvt_hypervisor_set_irq - register vgpu specific irq +* @vgpu: a vGPU +* @port_num: display port number +* +* Returns: +* Zero on success, negative error code if failed. +*/ +static inline int intel_gvt_hypervisor_register_display_irq (struct intel_vgpu *vgpu) +{ +if (!intel_gvt_host.mpt->register_display_irq) +return 0 ; + +return intel_gvt_host.mpt->register_display_irq (vgpu); +} +/** * intel_gvt_hypervisor_get_vfio_device - increase vfio device ref count * @vgpu: a vGPU
Signature · 1 line
2.17.1
RFC PATCH v2 3/3 drm/i915/gvt: Send plane flip events to user space
In reply to Tina ZhangSend the primary plane and the cursor plane flip events to user space.
--- drivers/gpu/drm/i915/gvt/handlers.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/gvt/handlers.c +17 -3
@@ -763,6 +763,20 @@ static int pri_surf_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,else set_bit (event, vgpu->irq.flip_done_event[pipe]); +if (vgpu->vdev.pri_flip_trigger) +eventfd_signal (vgpu->vdev.pri_flip_trigger,1 ); + +return 0 ; +} + +static int cur_surf_mmio_write (struct intel_vgpu *vgpu,unsigned int offset, +void *p_data,unsigned int bytes) +{ +write_vreg (vgpu, offset, p_data, bytes); + +if (vgpu->vdev.cur_flip_trigger) +eventfd_signal (vgpu->vdev.cur_flip_trigger,1 ); +return 0 ; }
@@ -1969,9 +1983,9 @@ static int init_generic_mmio_info(struct intel_gvt *gvt)MMIO_D (CURPOS (PIPE_B ),D_ALL );MMIO_D (CURPOS (PIPE_C ),D_ALL ); -MMIO_D (CURBASE (PIPE_A ),D_ALL ); -MMIO_D (CURBASE (PIPE_B ),D_ALL ); -MMIO_D (CURBASE (PIPE_C ),D_ALL ); +MMIO_DH (CURBASE (PIPE_A ),D_ALL ,NULL , cur_surf_mmio_write); +MMIO_DH (CURBASE (PIPE_B ),D_ALL ,NULL , cur_surf_mmio_write); +MMIO_DH (CURBASE (PIPE_C ),D_ALL ,NULL , cur_surf_mmio_write);MMIO_D (CUR_FBC_CTL (PIPE_A ),D_ALL );MMIO_D (CUR_FBC_CTL (PIPE_B ),D_ALL );
Signature · 1 line
2.17.1
Re: [RFC PATCH v2 1/3] vfio: Use capability chains to handle device specific irq
In reply to Tina ZhangQuoted 16 lines · Tina Zhang
Caps the number of irqs with fixed indexes and uses capability chains to chain device specific irqs.
VFIO vGPU leverages this mechanism to trigger primary plane and cursor plane page flip event to the user space.
Signed-off-by Tina Zhang <[email protected]>--- include/uapi/linux/vfio.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)include/uapi/linux/vfio.h +0
-0
include/uapi/linux/vfio.h struct vfio_irq_info { · line 450
Quoted 7 lines
include/uapi/linux/vfio.h +2
-0@@ -444,11 +444,31 @@ struct vfio_irq_info {#define VFIO_IRQ_INFO_MASKABLE (1 << 1)#define VFIO_IRQ_INFO_AUTOMASKED (1 << 2)#define VFIO_IRQ_INFO_NORESIZE (1 << 3) +#define VFIO_IRQ_INFO_FLAG_CAPS (1 << 4)/* Info supports caps */ __u32 index;/* IRQ index */ +__u32 cap_offset;/* Offset within info struct of first cap */ __u32 count;/* Number of IRQs within this index */
This would break ABI for get irq info. I think irq cap chain can just follow vfio_irq_info.
Quoted 11 lines
include/uapi/linux/vfio.h +8
-0};#define VFIO_DEVICE_GET_IRQ_INFO _IO(VFIO_TYPE, VFIO_BASE + 9) +/* +* The irq type capability allows irqs unique to a specific device or +* class of devices to be exposed. +* +* The structures below define version 1 of this capability. +*/ +#define VFIO_IRQ_INFO_CAP_TYPE 3 +
include/uapi/linux/vfio.h struct vfio_irq_info { · line 471
Quoted 10 lines
include/uapi/linux/vfio.h +10
-0+struct vfio_irq_info_cap_type { +struct vfio_info_cap_header header; +__u32 type;/* global per bus driver */ +__u32 subtype;/* type specific */ +}; + +#define VFIO_IRQ_TYPE_GFX (1) +#define VFIO_IRQ_SUBTYPE_GFX_PRI_PLANE_FLIP (1) +#define VFIO_IRQ_SUBTYPE_GFX_CUR_PLANE_FLIP (2) +
Really need to split for different planes? I'd like a VFIO_IRQ_SUBTYPE_GFX_DISPLAY_EVENT so user space can probe change for all.
Quoted 16 lines
include/uapi/linux/vfio.h +2
-1/** * VFIO_DEVICE_SET_IRQS - _IOW(VFIO_TYPE, VFIO_BASE + 10, struct vfio_irq_set) * @@ -550,7 +570,8 @@ enum {VFIO_PCI_MSIX_IRQ_INDEX ,VFIO_PCI_ERR_IRQ_INDEX ,VFIO_PCI_REQ_IRQ_INDEX , - VFIO_PCI_NUM_IRQS +VFIO_PCI_NUM_IRQS =5 /* Fixed user ABI, IRQ indexes >=5 use */ + /* device specific cap to define content */ };/* Signature · 1 line
2.17.1
Signature · 3 lines
Open Source Technology Center, Intel ltd. $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
RE: [RFC PATCH v2 1/3] vfio: Use capability chains to handle device specific irq
Quoted 61 lines
-----Original Message-----
From: Zhenyu Wang [mailto:[email protected]]
Sent: Wednesday, June 5, 2019 12:05 PM
To: Zhang, Tina <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; Lv, Zhiyuan <[email protected]>; Wang, Zhi A <[email protected]>; Tian, Kevin <[email protected]>; Yuan, Hang <[email protected]>; [email protected]
Subject: Re: [RFC PATCH v2 1/3] vfio: Use capability chains to handle device specific irqQuoted 16 lines · Tina Zhang
Caps the number of irqs with fixed indexes and uses capability chains to chain device specific irqs.
VFIO vGPU leverages this mechanism to trigger primary plane and cursor plane page flip event to the user space.
Signed-off-by Tina Zhang <[email protected]>--- include/uapi/linux/vfio.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)include/uapi/linux/vfio.h +0
-0include/uapi/linux/vfio.h struct vfio_irq_info { · line 447
Quoted 4 lines
include/uapi/linux/vfio.h +1
-0@@ -444,11 +444,31 @@ struct vfio_irq_info {#define VFIO_IRQ_INFO_MASKABLE (1 << 1)#define VFIO_IRQ_INFO_AUTOMASKED (1 << 2)#define VFIO_IRQ_INFO_NORESIZE (1 << 3) +#define VFIO_IRQ_INFO_FLAG_CAPS (1 << 4)/* Info supports caps */
include/uapi/linux/vfio.h struct vfio_irq_info { · line 450
Quoted 3 lines
include/uapi/linux/vfio.h +1
-0__u32 index;/* IRQ index */ +__u32 cap_offset;/* Offset within info struct of first cap */ __u32 count;/* Number of IRQs within this index */ This would break ABI for get irq info. I think irq cap chain can just follow
vfio_irq_info.include/uapi/linux/vfio.h struct vfio_irq_info { · line 452
Quoted 2 lines
include/uapi/linux/vfio.h +0
-0};#define VFIO_DEVICE_GET_IRQ_INFO _IO(VFIO_TYPE, VFIO_BASE +9)
Quoted 15 lines
include/uapi/linux/vfio.h +14
-0+/* +* The irq type capability allows irqs unique to a specific device or +* class of devices to be exposed. +* +* The structures below define version 1 of this capability. +*/ +#define VFIO_IRQ_INFO_CAP_TYPE 3 + +struct vfio_irq_info_cap_type { +struct vfio_info_cap_header header; +__u32 type;/* global per bus driver */ +__u32 subtype;/* type specific */ +}; +
Quoted 8 lines
include/uapi/linux/vfio.h struct vfio_irq_info { · line 471
Quoted 4 lines
include/uapi/linux/vfio.h +4
-0+#define VFIO_IRQ_TYPE_GFX (1) +#define VFIO_IRQ_SUBTYPE_GFX_PRI_PLANE_FLIP (1) +#define VFIO_IRQ_SUBTYPE_GFX_CUR_PLANE_FLIP (2) +Really need to split for different planes? I'd like a
VFIO_IRQ_SUBTYPE_GFX_DISPLAY_EVENT
so user space can probe change for all.
User space can choose to user different handlers according to the specific event. For example, user space might not want to handle every cursor event due to performance consideration. Besides, it can reduce the probe times, as we don't need to probe twice to make sure if both cursor plane and primary plane have been updated. Thanks.
BR,
Tina
Quoted 24 lines
include/uapi/linux/vfio.h struct vfio_irq_info { · line 472
Quoted 3 lines
include/uapi/linux/vfio.h +0
-0/** * VFIO_DEVICE_SET_IRQS - _IOW(VFIO_TYPE, VFIO_BASE + 10, struct
vfio_irq_set)include/uapi/linux/vfio.h enum { · line 573
Quoted 7 lines
include/uapi/linux/vfio.h +1
-1* @@ -550,7 +570,8 @@ enum {VFIO_PCI_MSIX_IRQ_INDEX ,VFIO_PCI_ERR_IRQ_INDEX ,VFIO_PCI_REQ_IRQ_INDEX , -VFIO_PCI_NUM_IRQS +VFIO_PCI_NUM_IRQS =5 /* Fixed user ABI, IRQ indexes >=5 use */
Quoted 7 lines
include/uapi/linux/vfio.h +1
-1+/* device specific cap to define content */ };/* -- 2.17.1
--
Open Source Technology Center, Intel ltd.$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
Re: [RFC PATCH v2 1/3] vfio: Use capability chains to handle device specific irq
Hi,
Quoted 9 lines
Quoted 3 lines
Really need to split for different planes? I'd like a
VFIO_IRQ_SUBTYPE_GFX_DISPLAY_EVENT
so user space can probe change for all.User space can choose to user different handlers according to the specific event. For example, user space might not want to handle every cursor event due to performance consideration. Besides, it can reduce the probe times, as we don't need to probe twice to make sure if both cursor plane and primary plane have been updated.
I'd suggest to use the value passed via eventfd for that, i.e. instead of sending "1" unconditionally send a mask of changed planes.
cheers,
Gerd
RE: [RFC PATCH v2 1/3] vfio: Use capability chains to handle device specific irq
Quoted 9 lines
From: [email protected]
Sent: Wednesday, June 5, 2019 6:10 PMHi,
Quoted 3 lines
Quoted 3 lines
Really need to split for different planes? I'd like a
VFIO_IRQ_SUBTYPE_GFX_DISPLAY_EVENT
so user space can probe change for all.
Quoted 9 lines
Quoted 5 lines
User space can choose to user different handlers according to the specific event. For example, user space might not want to handle every cursor event due to performance consideration. Besides, it can reduce the probe times, as we don't need to probe twice to make sure if both cursor plane and primary plane have been updated.
I'd suggest to use the value passed via eventfd for that, i.e. instead of sending "1" unconditionally send a mask of changed planes.
sounds reasonable.
RE: [RFC PATCH v2 1/3] vfio: Use capability chains to handle device specific irq
In reply to [email protected]Quoted 21 lines
-----Original Message-----
From: intel-gvt-dev [mailto:[email protected]] On Behalf Of [email protected]
Sent: Wednesday, June 5, 2019 6:10 PM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; linux- [email protected]; Zhenyu Wang <[email protected]>; Yuan, Hang <[email protected]>; [email protected]; Lv, Zhiyuan <[email protected]>; [email protected]; Wang, Zhi A <[email protected]>
Subject: Re: [RFC PATCH v2 1/3] vfio: Use capability chains to handle device specific irqHi,
Quoted 3 lines
Quoted 3 lines
Really need to split for different planes? I'd like a
VFIO_IRQ_SUBTYPE_GFX_DISPLAY_EVENT
so user space can probe change for all.
Quoted 8 lines
Quoted 5 lines
User space can choose to user different handlers according to the specific event. For example, user space might not want to handle every cursor event due to performance consideration. Besides, it can reduce the probe times, as we don't need to probe twice to make sure if both cursor plane and primary plane have been updated.
I'd suggest to use the value passed via eventfd for that, i.e. instead of sending "1" unconditionally send a mask of changed planes.
If there is only one eventfd working for GFX_DISPLAY, should it be VFIO_IRQ_INFO_EVENTFD and VFIO_IRQ_INFO_AUTOMASKED? i.e. after signaling, the interrupt is automatically masked and the user space needs to unmask the line to receive new irq event.
BR,
Tina
Quoted 8 lines
cheers,
Gerd_______________________________________________
intel-gvt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev
Re: [RFC PATCH v2 1/3] vfio: Use capability chains to handle device specific irq
Quoted 25 lines · Tina
Quoted 25 lines
-----Original Message-----
From: intel-gvt-dev [mailto:[email protected]] On Behalf Of [email protected]
Sent: Wednesday, June 5, 2019 6:10 PM
To: Zhang, Tina <[email protected]>
Cc: Tian, Kevin <[email protected]>; [email protected]; linux- [email protected]; Zhenyu Wang <[email protected]>; Yuan, Hang <[email protected]>; [email protected]; Lv, Zhiyuan <[email protected]>; [email protected]; Wang, Zhi A <[email protected]>
Subject: Re: [RFC PATCH v2 1/3] vfio: Use capability chains to handle device specific irqHi,
Quoted 9 lines
Quoted 3 lines
Really need to split for different planes? I'd like a
VFIO_IRQ_SUBTYPE_GFX_DISPLAY_EVENT
so user space can probe change for all.User space can choose to user different handlers according to the specific event. For example, user space might not want to handle every cursor event due to performance consideration. Besides, it can reduce the probe times, as we don't need to probe twice to make sure if both cursor plane and primary plane have been updated.
Quoted 6 lines
Quoted 2 lines
I'd suggest to use the value passed via eventfd for that, i.e. instead of sending "1" unconditionally send a mask of changed planes.
If there is only one eventfd working for
GFX_DISPLAY, should it beVFIO_IRQ_INFO_EVENTFDandVFIO_IRQ_INFO_AUTOMASKED? i.e. after signaling, the interrupt is automatically masked and the user space needs to unmask the line to receive new irq event.
If there's any way at all the interrupt is rate limited already, I'd suggest not to use automasked. This flag is generally intended for cases where we need to mask a host interrupt and don't have a generic or efficient way to determine acknowledgement of the interrupt and therefore require an explicit unmask. If the events here are not at a high frequency or you can tell by other interactions that they've been acted upon, I'd suggest to handle these as an edge triggered interrupt w/o automasked. Thanks,
Alex