linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Deliver vGPU page flip event to userspace
@ 2019-05-27  8:43 Tina Zhang
  2019-05-27  8:43 ` [PATCH 1/2] vfio: ABI for setting mdev display flip eventfd Tina Zhang
  2019-05-27  8:43 ` [PATCH 2/2] drm/i915/gvt: Support delivering page flip event to userspace Tina Zhang
  0 siblings, 2 replies; 10+ messages in thread
From: Tina Zhang @ 2019-05-27  8:43 UTC (permalink / raw)
  Cc: Tina Zhang, intel-gvt-dev, kvm, linux-kernel, kraxel, zhenyuw,
	alex.williamson, hang.yuan, zhiyuan.lv

This series introduces VFIO_DEVICE_SET_GFX_FLIP_EVENTFD ioctl command to
set the eventfd based signaling mechanism in vfio display. vGPU can use
this eventfd to deliver the framebuffer page flip event to userspace.


Tina Zhang (2):
  vfio: ABI for setting mdev display flip eventfd
  drm/i915/gvt: Support delivering page flip event to userspace

 drivers/gpu/drm/i915/gvt/dmabuf.c   | 31 +++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/gvt/dmabuf.h   |  1 +
 drivers/gpu/drm/i915/gvt/gvt.c      |  1 +
 drivers/gpu/drm/i915/gvt/gvt.h      |  2 ++
 drivers/gpu/drm/i915/gvt/handlers.c |  2 ++
 drivers/gpu/drm/i915/gvt/kvmgt.c    |  7 +++++++
 include/uapi/linux/vfio.h           | 12 +++++++++++
 7 files changed, 56 insertions(+)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/2] vfio: ABI for setting mdev display flip eventfd
  2019-05-27  8:43 [PATCH 0/2] Deliver vGPU page flip event to userspace Tina Zhang
@ 2019-05-27  8:43 ` Tina Zhang
  2019-05-27  9:07   ` Zhenyu Wang
  2019-05-27 14:04   ` Alex Williamson
  2019-05-27  8:43 ` [PATCH 2/2] drm/i915/gvt: Support delivering page flip event to userspace Tina Zhang
  1 sibling, 2 replies; 10+ messages in thread
From: Tina Zhang @ 2019-05-27  8:43 UTC (permalink / raw)
  Cc: Tina Zhang, intel-gvt-dev, kvm, linux-kernel, kraxel, zhenyuw,
	alex.williamson, hang.yuan, zhiyuan.lv

Add VFIO_DEVICE_SET_GFX_FLIP_EVENTFD ioctl command to set eventfd
based signaling mechanism to deliver vGPU framebuffer page flip
event to userspace.

Signed-off-by: Tina Zhang <tina.zhang@intel.com>
---
 include/uapi/linux/vfio.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index 02bb7ad6e986..27300597717f 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -696,6 +696,18 @@ struct vfio_device_ioeventfd {
 
 #define VFIO_DEVICE_IOEVENTFD		_IO(VFIO_TYPE, VFIO_BASE + 16)
 
+/**
+ * VFIO_DEVICE_SET_GFX_FLIP_EVENTFD - _IOW(VFIO_TYPE, VFIO_BASE + 17, __s32)
+ *
+ * Set eventfd based signaling mechanism to deliver vGPU framebuffer page
+ * flip event to userspace. A value of -1 is used to stop the page flip
+ * delivering.
+ *
+ * Return: 0 on success, -errno on failure.
+ */
+
+#define VFIO_DEVICE_SET_GFX_FLIP_EVENTFD _IO(VFIO_TYPE, VFIO_BASE + 17)
+
 /* -------- API for Type1 VFIO IOMMU -------- */
 
 /**
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] drm/i915/gvt: Support delivering page flip event to userspace
  2019-05-27  8:43 [PATCH 0/2] Deliver vGPU page flip event to userspace Tina Zhang
  2019-05-27  8:43 ` [PATCH 1/2] vfio: ABI for setting mdev display flip eventfd Tina Zhang
@ 2019-05-27  8:43 ` Tina Zhang
  2019-05-27  9:11   ` Zhenyu Wang
  1 sibling, 1 reply; 10+ messages in thread
From: Tina Zhang @ 2019-05-27  8:43 UTC (permalink / raw)
  Cc: Tina Zhang, intel-gvt-dev, kvm, linux-kernel, kraxel, zhenyuw,
	alex.williamson, hang.yuan, zhiyuan.lv

Use the eventfd based signaling mechanism provided by vfio/display
to deliver vGPU framebuffer page flip event to userspace.

Signed-off-by: Tina Zhang <tina.zhang@intel.com>
---
 drivers/gpu/drm/i915/gvt/dmabuf.c   | 31 +++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/gvt/dmabuf.h   |  1 +
 drivers/gpu/drm/i915/gvt/gvt.c      |  1 +
 drivers/gpu/drm/i915/gvt/gvt.h      |  2 ++
 drivers/gpu/drm/i915/gvt/handlers.c |  2 ++
 drivers/gpu/drm/i915/gvt/kvmgt.c    |  7 +++++++
 6 files changed, 44 insertions(+)

diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.c b/drivers/gpu/drm/i915/gvt/dmabuf.c
index 4e1e425189ba..f2ed45616d72 100644
--- a/drivers/gpu/drm/i915/gvt/dmabuf.c
+++ b/drivers/gpu/drm/i915/gvt/dmabuf.c
@@ -538,6 +538,35 @@ int intel_vgpu_get_dmabuf(struct intel_vgpu *vgpu, unsigned int dmabuf_id)
 	return ret;
 }
 
+static void release_flip_eventfd_ctx(struct intel_vgpu *vgpu)
+{
+	struct eventfd_ctx **trigger = &vgpu->page_flip_trigger;
+
+	if (*trigger) {
+		eventfd_ctx_put(*trigger);
+		*trigger = NULL;
+	}
+}
+
+int intel_vgpu_set_flip_eventfd(struct intel_vgpu *vgpu, int fd)
+{
+	struct eventfd_ctx *trigger;
+
+	if (fd == -1) {
+		release_flip_eventfd_ctx(vgpu);
+	} else if (fd >= 0) {
+		trigger = eventfd_ctx_fdget(fd);
+		if (IS_ERR(trigger)) {
+			gvt_vgpu_err("eventfd_ctx_fdget failed\n");
+			return PTR_ERR(trigger);
+		}
+		vgpu->page_flip_trigger = trigger;
+	} else
+		return -EINVAL;
+
+	return 0;
+}
+
 void intel_vgpu_dmabuf_cleanup(struct intel_vgpu *vgpu)
 {
 	struct list_head *pos, *n;
@@ -561,4 +590,6 @@ void intel_vgpu_dmabuf_cleanup(struct intel_vgpu *vgpu)
 
 	}
 	mutex_unlock(&vgpu->dmabuf_lock);
+
+	release_flip_eventfd_ctx(vgpu);
 }
diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.h b/drivers/gpu/drm/i915/gvt/dmabuf.h
index 5f8f03fb1d1b..4d9caa3732d2 100644
--- a/drivers/gpu/drm/i915/gvt/dmabuf.h
+++ b/drivers/gpu/drm/i915/gvt/dmabuf.h
@@ -62,6 +62,7 @@ struct intel_vgpu_dmabuf_obj {
 
 int intel_vgpu_query_plane(struct intel_vgpu *vgpu, void *args);
 int intel_vgpu_get_dmabuf(struct intel_vgpu *vgpu, unsigned int dmabuf_id);
+int intel_vgpu_set_flip_eventfd(struct intel_vgpu *vgpu, int fd);
 void intel_vgpu_dmabuf_cleanup(struct intel_vgpu *vgpu);
 
 #endif
diff --git a/drivers/gpu/drm/i915/gvt/gvt.c b/drivers/gpu/drm/i915/gvt/gvt.c
index 43f4242062dd..7fd4afa432ef 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.c
+++ b/drivers/gpu/drm/i915/gvt/gvt.c
@@ -184,6 +184,7 @@ static const struct intel_gvt_ops intel_gvt_ops = {
 	.get_gvt_attrs = intel_get_gvt_attrs,
 	.vgpu_query_plane = intel_vgpu_query_plane,
 	.vgpu_get_dmabuf = intel_vgpu_get_dmabuf,
+	.vgpu_set_flip_eventfd = intel_vgpu_set_flip_eventfd,
 	.write_protect_handler = intel_vgpu_page_track_handler,
 	.emulate_hotplug = intel_vgpu_emulate_hotplug,
 };
diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h
index f5a328b5290a..86ca223f9a60 100644
--- a/drivers/gpu/drm/i915/gvt/gvt.h
+++ b/drivers/gpu/drm/i915/gvt/gvt.h
@@ -229,6 +229,7 @@ struct intel_vgpu {
 	struct completion vblank_done;
 
 	u32 scan_nonprivbb;
+	struct eventfd_ctx *page_flip_trigger;
 };
 
 /* validating GM healthy status*/
@@ -570,6 +571,7 @@ struct intel_gvt_ops {
 			struct attribute_group ***intel_vgpu_type_groups);
 	int (*vgpu_query_plane)(struct intel_vgpu *vgpu, void *);
 	int (*vgpu_get_dmabuf)(struct intel_vgpu *vgpu, unsigned int);
+	int (*vgpu_set_flip_eventfd)(struct intel_vgpu *vgpu, int fd);
 	int (*write_protect_handler)(struct intel_vgpu *, u64, void *,
 				     unsigned int);
 	void (*emulate_hotplug)(struct intel_vgpu *vgpu, bool connected);
diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/gvt/handlers.c
index 18f01eeb2510..1b5455888bdf 100644
--- a/drivers/gpu/drm/i915/gvt/handlers.c
+++ b/drivers/gpu/drm/i915/gvt/handlers.c
@@ -763,6 +763,8 @@ static int pri_surf_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
 	else
 		set_bit(event, vgpu->irq.flip_done_event[pipe]);
 
+	eventfd_signal(vgpu->page_flip_trigger, 1);
+
 	return 0;
 }
 
diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
index a68addf95c23..00c75bd76bc0 100644
--- a/drivers/gpu/drm/i915/gvt/kvmgt.c
+++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
@@ -1547,6 +1547,13 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
 		dmabuf_fd = intel_gvt_ops->vgpu_get_dmabuf(vgpu, dmabuf_id);
 		return dmabuf_fd;
 
+	} else if (cmd == VFIO_DEVICE_SET_GFX_FLIP_EVENTFD) {
+		__s32 event_fd;
+
+		if (get_user(event_fd, (__s32 __user *)arg))
+			return -EFAULT;
+
+		return intel_gvt_ops->vgpu_set_flip_eventfd(vgpu, event_fd);
 	}
 
 	return -ENOTTY;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] vfio: ABI for setting mdev display flip eventfd
  2019-05-27  8:43 ` [PATCH 1/2] vfio: ABI for setting mdev display flip eventfd Tina Zhang
@ 2019-05-27  9:07   ` Zhenyu Wang
  2019-05-27 12:22     ` Gerd Hoffmann
  2019-05-27 14:04   ` Alex Williamson
  1 sibling, 1 reply; 10+ messages in thread
From: Zhenyu Wang @ 2019-05-27  9:07 UTC (permalink / raw)
  To: Tina Zhang
  Cc: intel-gvt-dev, kvm, linux-kernel, kraxel, zhenyuw,
	alex.williamson, hang.yuan, zhiyuan.lv

[-- Attachment #1: Type: text/plain, Size: 1355 bytes --]

On 2019.05.27 16:43:11 +0800, Tina Zhang wrote:
> Add VFIO_DEVICE_SET_GFX_FLIP_EVENTFD ioctl command to set eventfd
> based signaling mechanism to deliver vGPU framebuffer page flip
> event to userspace.
>

Should we add probe to see if driver can support gfx flip event?

> Signed-off-by: Tina Zhang <tina.zhang@intel.com>
> ---
>  include/uapi/linux/vfio.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
> index 02bb7ad6e986..27300597717f 100644
> --- a/include/uapi/linux/vfio.h
> +++ b/include/uapi/linux/vfio.h
> @@ -696,6 +696,18 @@ struct vfio_device_ioeventfd {
>  
>  #define VFIO_DEVICE_IOEVENTFD		_IO(VFIO_TYPE, VFIO_BASE + 16)
>  
> +/**
> + * VFIO_DEVICE_SET_GFX_FLIP_EVENTFD - _IOW(VFIO_TYPE, VFIO_BASE + 17, __s32)
> + *
> + * Set eventfd based signaling mechanism to deliver vGPU framebuffer page
> + * flip event to userspace. A value of -1 is used to stop the page flip
> + * delivering.
> + *
> + * Return: 0 on success, -errno on failure.
> + */
> +
> +#define VFIO_DEVICE_SET_GFX_FLIP_EVENTFD _IO(VFIO_TYPE, VFIO_BASE + 17)
> +
>  /* -------- API for Type1 VFIO IOMMU -------- */
>  
>  /**
> -- 
> 2.17.1
> 

-- 
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] drm/i915/gvt: Support delivering page flip event to userspace
  2019-05-27  8:43 ` [PATCH 2/2] drm/i915/gvt: Support delivering page flip event to userspace Tina Zhang
@ 2019-05-27  9:11   ` Zhenyu Wang
  0 siblings, 0 replies; 10+ messages in thread
From: Zhenyu Wang @ 2019-05-27  9:11 UTC (permalink / raw)
  To: Tina Zhang
  Cc: intel-gvt-dev, kvm, linux-kernel, kraxel, zhenyuw,
	alex.williamson, hang.yuan, zhiyuan.lv

[-- Attachment #1: Type: text/plain, Size: 5531 bytes --]

On 2019.05.27 16:43:12 +0800, Tina Zhang wrote:
> Use the eventfd based signaling mechanism provided by vfio/display
> to deliver vGPU framebuffer page flip event to userspace.
> 
> Signed-off-by: Tina Zhang <tina.zhang@intel.com>
> ---
>  drivers/gpu/drm/i915/gvt/dmabuf.c   | 31 +++++++++++++++++++++++++++++
>  drivers/gpu/drm/i915/gvt/dmabuf.h   |  1 +
>  drivers/gpu/drm/i915/gvt/gvt.c      |  1 +
>  drivers/gpu/drm/i915/gvt/gvt.h      |  2 ++
>  drivers/gpu/drm/i915/gvt/handlers.c |  2 ++
>  drivers/gpu/drm/i915/gvt/kvmgt.c    |  7 +++++++
>  6 files changed, 44 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.c b/drivers/gpu/drm/i915/gvt/dmabuf.c
> index 4e1e425189ba..f2ed45616d72 100644
> --- a/drivers/gpu/drm/i915/gvt/dmabuf.c
> +++ b/drivers/gpu/drm/i915/gvt/dmabuf.c
> @@ -538,6 +538,35 @@ int intel_vgpu_get_dmabuf(struct intel_vgpu *vgpu, unsigned int dmabuf_id)
>  	return ret;
>  }
>  
> +static void release_flip_eventfd_ctx(struct intel_vgpu *vgpu)
> +{
> +	struct eventfd_ctx **trigger = &vgpu->page_flip_trigger;
> +
> +	if (*trigger) {
> +		eventfd_ctx_put(*trigger);
> +		*trigger = NULL;
> +	}

Why so twisted?

        if (vgpu->page_flip_trigger) {
                eventfd_ctx_put(vgpu->page_flip_trigger);
		vgpu->page_flip_trigger = NULL;
        }

> +}
> +
> +int intel_vgpu_set_flip_eventfd(struct intel_vgpu *vgpu, int fd)
> +{
> +	struct eventfd_ctx *trigger;
> +
> +	if (fd == -1) {
> +		release_flip_eventfd_ctx(vgpu);
> +	} else if (fd >= 0) {
> +		trigger = eventfd_ctx_fdget(fd);
> +		if (IS_ERR(trigger)) {
> +			gvt_vgpu_err("eventfd_ctx_fdget failed\n");
> +			return PTR_ERR(trigger);
> +		}
> +		vgpu->page_flip_trigger = trigger;
> +	} else
> +		return -EINVAL;

Better put (fd < 0) check earlier in ioctl handler to simplify this.

> +
> +	return 0;
> +}
> +
>  void intel_vgpu_dmabuf_cleanup(struct intel_vgpu *vgpu)
>  {
>  	struct list_head *pos, *n;
> @@ -561,4 +590,6 @@ void intel_vgpu_dmabuf_cleanup(struct intel_vgpu *vgpu)
>  
>  	}
>  	mutex_unlock(&vgpu->dmabuf_lock);
> +
> +	release_flip_eventfd_ctx(vgpu);
>  }
> diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.h b/drivers/gpu/drm/i915/gvt/dmabuf.h
> index 5f8f03fb1d1b..4d9caa3732d2 100644
> --- a/drivers/gpu/drm/i915/gvt/dmabuf.h
> +++ b/drivers/gpu/drm/i915/gvt/dmabuf.h
> @@ -62,6 +62,7 @@ struct intel_vgpu_dmabuf_obj {
>  
>  int intel_vgpu_query_plane(struct intel_vgpu *vgpu, void *args);
>  int intel_vgpu_get_dmabuf(struct intel_vgpu *vgpu, unsigned int dmabuf_id);
> +int intel_vgpu_set_flip_eventfd(struct intel_vgpu *vgpu, int fd);
>  void intel_vgpu_dmabuf_cleanup(struct intel_vgpu *vgpu);
>  
>  #endif
> diff --git a/drivers/gpu/drm/i915/gvt/gvt.c b/drivers/gpu/drm/i915/gvt/gvt.c
> index 43f4242062dd..7fd4afa432ef 100644
> --- a/drivers/gpu/drm/i915/gvt/gvt.c
> +++ b/drivers/gpu/drm/i915/gvt/gvt.c
> @@ -184,6 +184,7 @@ static const struct intel_gvt_ops intel_gvt_ops = {
>  	.get_gvt_attrs = intel_get_gvt_attrs,
>  	.vgpu_query_plane = intel_vgpu_query_plane,
>  	.vgpu_get_dmabuf = intel_vgpu_get_dmabuf,
> +	.vgpu_set_flip_eventfd = intel_vgpu_set_flip_eventfd,
>  	.write_protect_handler = intel_vgpu_page_track_handler,
>  	.emulate_hotplug = intel_vgpu_emulate_hotplug,
>  };
> diff --git a/drivers/gpu/drm/i915/gvt/gvt.h b/drivers/gpu/drm/i915/gvt/gvt.h
> index f5a328b5290a..86ca223f9a60 100644
> --- a/drivers/gpu/drm/i915/gvt/gvt.h
> +++ b/drivers/gpu/drm/i915/gvt/gvt.h
> @@ -229,6 +229,7 @@ struct intel_vgpu {
>  	struct completion vblank_done;
>  
>  	u32 scan_nonprivbb;
> +	struct eventfd_ctx *page_flip_trigger;
>  };
>  
>  /* validating GM healthy status*/
> @@ -570,6 +571,7 @@ struct intel_gvt_ops {
>  			struct attribute_group ***intel_vgpu_type_groups);
>  	int (*vgpu_query_plane)(struct intel_vgpu *vgpu, void *);
>  	int (*vgpu_get_dmabuf)(struct intel_vgpu *vgpu, unsigned int);
> +	int (*vgpu_set_flip_eventfd)(struct intel_vgpu *vgpu, int fd);
>  	int (*write_protect_handler)(struct intel_vgpu *, u64, void *,
>  				     unsigned int);
>  	void (*emulate_hotplug)(struct intel_vgpu *vgpu, bool connected);
> diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/gvt/handlers.c
> index 18f01eeb2510..1b5455888bdf 100644
> --- a/drivers/gpu/drm/i915/gvt/handlers.c
> +++ b/drivers/gpu/drm/i915/gvt/handlers.c
> @@ -763,6 +763,8 @@ static int pri_surf_mmio_write(struct intel_vgpu *vgpu, unsigned int offset,
>  	else
>  		set_bit(event, vgpu->irq.flip_done_event[pipe]);
>  
> +	eventfd_signal(vgpu->page_flip_trigger, 1);

Need to check if page_flip_trigger is armed or not.

> +
>  	return 0;
>  }
>  
> diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c
> index a68addf95c23..00c75bd76bc0 100644
> --- a/drivers/gpu/drm/i915/gvt/kvmgt.c
> +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c
> @@ -1547,6 +1547,13 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd,
>  		dmabuf_fd = intel_gvt_ops->vgpu_get_dmabuf(vgpu, dmabuf_id);
>  		return dmabuf_fd;
>  
> +	} else if (cmd == VFIO_DEVICE_SET_GFX_FLIP_EVENTFD) {
> +		__s32 event_fd;
> +
> +		if (get_user(event_fd, (__s32 __user *)arg))
> +			return -EFAULT;
> +
> +		return intel_gvt_ops->vgpu_set_flip_eventfd(vgpu, event_fd);
>  	}
>  
>  	return -ENOTTY;
> -- 
> 2.17.1
> 

-- 
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] vfio: ABI for setting mdev display flip eventfd
  2019-05-27  9:07   ` Zhenyu Wang
@ 2019-05-27 12:22     ` Gerd Hoffmann
  2019-05-28  2:51       ` Zhenyu Wang
  0 siblings, 1 reply; 10+ messages in thread
From: Gerd Hoffmann @ 2019-05-27 12:22 UTC (permalink / raw)
  To: Zhenyu Wang
  Cc: Tina Zhang, intel-gvt-dev, kvm, linux-kernel, alex.williamson,
	hang.yuan, zhiyuan.lv

On Mon, May 27, 2019 at 05:07:41PM +0800, Zhenyu Wang wrote:
> On 2019.05.27 16:43:11 +0800, Tina Zhang wrote:
> > Add VFIO_DEVICE_SET_GFX_FLIP_EVENTFD ioctl command to set eventfd
> > based signaling mechanism to deliver vGPU framebuffer page flip
> > event to userspace.
> 
> Should we add probe to see if driver can support gfx flip event?

Userspace can simply call VFIO_DEVICE_SET_GFX_FLIP_EVENTFD and see if it
worked.  If so -> use the eventfd.  Otherwise take the fallback path
(timer based polling).  I can't see any advantage a separate feature
probe steps adds.

cheers,
  Gerd


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] vfio: ABI for setting mdev display flip eventfd
  2019-05-27  8:43 ` [PATCH 1/2] vfio: ABI for setting mdev display flip eventfd Tina Zhang
  2019-05-27  9:07   ` Zhenyu Wang
@ 2019-05-27 14:04   ` Alex Williamson
  2019-05-28  1:42     ` Zhang, Tina
  1 sibling, 1 reply; 10+ messages in thread
From: Alex Williamson @ 2019-05-27 14:04 UTC (permalink / raw)
  To: Tina Zhang
  Cc: intel-gvt-dev, kvm, linux-kernel, kraxel, zhenyuw, hang.yuan, zhiyuan.lv

On Mon, 27 May 2019 16:43:11 +0800
Tina Zhang <tina.zhang@intel.com> wrote:

> Add VFIO_DEVICE_SET_GFX_FLIP_EVENTFD ioctl command to set eventfd
> based signaling mechanism to deliver vGPU framebuffer page flip
> event to userspace.
> 
> Signed-off-by: Tina Zhang <tina.zhang@intel.com>
> ---
>  include/uapi/linux/vfio.h | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
> index 02bb7ad6e986..27300597717f 100644
> --- a/include/uapi/linux/vfio.h
> +++ b/include/uapi/linux/vfio.h
> @@ -696,6 +696,18 @@ struct vfio_device_ioeventfd {
>  
>  #define VFIO_DEVICE_IOEVENTFD		_IO(VFIO_TYPE, VFIO_BASE + 16)
>  
> +/**
> + * VFIO_DEVICE_SET_GFX_FLIP_EVENTFD - _IOW(VFIO_TYPE, VFIO_BASE + 17, __s32)
> + *
> + * Set eventfd based signaling mechanism to deliver vGPU framebuffer page
> + * flip event to userspace. A value of -1 is used to stop the page flip
> + * delivering.
> + *
> + * Return: 0 on success, -errno on failure.
> + */
> +
> +#define VFIO_DEVICE_SET_GFX_FLIP_EVENTFD _IO(VFIO_TYPE, VFIO_BASE + 17)
> +
>  /* -------- API for Type1 VFIO IOMMU -------- */
>  
>  /**

Why can't we use VFIO_DEVICE_SET_IRQS for this?  We can add a
capability to vfio_irq_info in the same way that we did for regions to
describe device specific IRQ support.  Thanks,

Alex

^ permalink raw reply	[flat|nested] 10+ messages in thread

* RE: [PATCH 1/2] vfio: ABI for setting mdev display flip eventfd
  2019-05-27 14:04   ` Alex Williamson
@ 2019-05-28  1:42     ` Zhang, Tina
  2019-05-28  4:18       ` Alex Williamson
  0 siblings, 1 reply; 10+ messages in thread
From: Zhang, Tina @ 2019-05-28  1:42 UTC (permalink / raw)
  To: Alex Williamson
  Cc: kvm, linux-kernel, zhenyuw, Yuan, Hang, kraxel, intel-gvt-dev,
	Lv, Zhiyuan



> -----Original Message-----
> From: intel-gvt-dev [mailto:intel-gvt-dev-bounces@lists.freedesktop.org] On
> Behalf Of Alex Williamson
> Sent: Monday, May 27, 2019 10:05 PM
> To: Zhang, Tina <tina.zhang@intel.com>
> Cc: kvm@vger.kernel.org; linux-kernel@vger.kernel.org;
> zhenyuw@linux.intel.com; Yuan, Hang <hang.yuan@intel.com>;
> kraxel@redhat.com; intel-gvt-dev@lists.freedesktop.org; Lv, Zhiyuan
> <zhiyuan.lv@intel.com>
> Subject: Re: [PATCH 1/2] vfio: ABI for setting mdev display flip eventfd
> 
> On Mon, 27 May 2019 16:43:11 +0800
> Tina Zhang <tina.zhang@intel.com> wrote:
> 
> > Add VFIO_DEVICE_SET_GFX_FLIP_EVENTFD ioctl command to set eventfd
> > based signaling mechanism to deliver vGPU framebuffer page flip event
> > to userspace.
> >
> > Signed-off-by: Tina Zhang <tina.zhang@intel.com>
> > ---
> >  include/uapi/linux/vfio.h | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
> > index 02bb7ad6e986..27300597717f 100644
> > --- a/include/uapi/linux/vfio.h
> > +++ b/include/uapi/linux/vfio.h
> > @@ -696,6 +696,18 @@ struct vfio_device_ioeventfd {
> >
> >  #define VFIO_DEVICE_IOEVENTFD		_IO(VFIO_TYPE, VFIO_BASE +
> 16)
> >
> > +/**
> > + * VFIO_DEVICE_SET_GFX_FLIP_EVENTFD - _IOW(VFIO_TYPE, VFIO_BASE
> + 17,
> > +__s32)
> > + *
> > + * Set eventfd based signaling mechanism to deliver vGPU framebuffer
> > +page
> > + * flip event to userspace. A value of -1 is used to stop the page
> > +flip
> > + * delivering.
> > + *
> > + * Return: 0 on success, -errno on failure.
> > + */
> > +
> > +#define VFIO_DEVICE_SET_GFX_FLIP_EVENTFD _IO(VFIO_TYPE,
> VFIO_BASE +
> > +17)
> > +
> >  /* -------- API for Type1 VFIO IOMMU -------- */
> >
> >  /**
> 
> Why can't we use VFIO_DEVICE_SET_IRQS for this?  We can add a capability
> to vfio_irq_info in the same way that we did for regions to describe device
> specific IRQ support.  Thanks,
Add a new kind of index, like this?
enum {
        VFIO_PCI_INTX_IRQ_INDEX,
        VFIO_PCI_MSI_IRQ_INDEX,
        VFIO_PCI_MSIX_IRQ_INDEX,
        VFIO_PCI_ERR_IRQ_INDEX,
        VFIO_PCI_REQ_IRQ_INDEX,
+      VFIO_PCI_GFX_FLIP_EVENT_INDEX,
        VFIO_PCI_NUM_IRQS
};
Perhaps this is what we don't want. This VFIO_PCI_GFX_FLIP_EVENT_INDEX is specific to graphics card and it's actually an event which is reported by INTX/MSI/ MSIX IRQ.
Thanks.

BR,
Tina
> 
> Alex
> _______________________________________________
> intel-gvt-dev mailing list
> intel-gvt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] vfio: ABI for setting mdev display flip eventfd
  2019-05-27 12:22     ` Gerd Hoffmann
@ 2019-05-28  2:51       ` Zhenyu Wang
  0 siblings, 0 replies; 10+ messages in thread
From: Zhenyu Wang @ 2019-05-28  2:51 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: Tina Zhang, intel-gvt-dev, kvm, linux-kernel, alex.williamson,
	hang.yuan, zhiyuan.lv

[-- Attachment #1: Type: text/plain, Size: 1135 bytes --]

On 2019.05.27 14:22:37 +0200, Gerd Hoffmann wrote:
> On Mon, May 27, 2019 at 05:07:41PM +0800, Zhenyu Wang wrote:
> > On 2019.05.27 16:43:11 +0800, Tina Zhang wrote:
> > > Add VFIO_DEVICE_SET_GFX_FLIP_EVENTFD ioctl command to set eventfd
> > > based signaling mechanism to deliver vGPU framebuffer page flip
> > > event to userspace.
> > 
> > Should we add probe to see if driver can support gfx flip event?
> 
> Userspace can simply call VFIO_DEVICE_SET_GFX_FLIP_EVENTFD and see if it
> worked.  If so -> use the eventfd.  Otherwise take the fallback path
> (timer based polling).  I can't see any advantage a separate feature
> probe steps adds.
> 

Then we need to define error return which means driver doesn't support
e.g -ENOTTY, and driver shouldn't return that for other possible
failure, so user space won't get confused.

I think if we can define this as generic display event notification?
Not necessarily just for flip, just a display change notification to
let user space query current state.

-- 
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] vfio: ABI for setting mdev display flip eventfd
  2019-05-28  1:42     ` Zhang, Tina
@ 2019-05-28  4:18       ` Alex Williamson
  0 siblings, 0 replies; 10+ messages in thread
From: Alex Williamson @ 2019-05-28  4:18 UTC (permalink / raw)
  To: Zhang, Tina
  Cc: kvm, linux-kernel, zhenyuw, Yuan, Hang, kraxel, intel-gvt-dev,
	Lv, Zhiyuan

On Tue, 28 May 2019 01:42:57 +0000
"Zhang, Tina" <tina.zhang@intel.com> wrote:

> > -----Original Message-----
> > From: intel-gvt-dev [mailto:intel-gvt-dev-bounces@lists.freedesktop.org] On
> > Behalf Of Alex Williamson
> > Sent: Monday, May 27, 2019 10:05 PM
> > To: Zhang, Tina <tina.zhang@intel.com>
> > Cc: kvm@vger.kernel.org; linux-kernel@vger.kernel.org;
> > zhenyuw@linux.intel.com; Yuan, Hang <hang.yuan@intel.com>;
> > kraxel@redhat.com; intel-gvt-dev@lists.freedesktop.org; Lv, Zhiyuan
> > <zhiyuan.lv@intel.com>
> > Subject: Re: [PATCH 1/2] vfio: ABI for setting mdev display flip eventfd
> > 
> > On Mon, 27 May 2019 16:43:11 +0800
> > Tina Zhang <tina.zhang@intel.com> wrote:
> >   
> > > Add VFIO_DEVICE_SET_GFX_FLIP_EVENTFD ioctl command to set eventfd
> > > based signaling mechanism to deliver vGPU framebuffer page flip event
> > > to userspace.
> > >
> > > Signed-off-by: Tina Zhang <tina.zhang@intel.com>
> > > ---
> > >  include/uapi/linux/vfio.h | 12 ++++++++++++
> > >  1 file changed, 12 insertions(+)
> > >
> > > diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
> > > index 02bb7ad6e986..27300597717f 100644
> > > --- a/include/uapi/linux/vfio.h
> > > +++ b/include/uapi/linux/vfio.h
> > > @@ -696,6 +696,18 @@ struct vfio_device_ioeventfd {
> > >
> > >  #define VFIO_DEVICE_IOEVENTFD		_IO(VFIO_TYPE, VFIO_BASE +  
> > 16)  
> > >
> > > +/**
> > > + * VFIO_DEVICE_SET_GFX_FLIP_EVENTFD - _IOW(VFIO_TYPE, VFIO_BASE  
> > + 17,  
> > > +__s32)
> > > + *
> > > + * Set eventfd based signaling mechanism to deliver vGPU framebuffer
> > > +page
> > > + * flip event to userspace. A value of -1 is used to stop the page
> > > +flip
> > > + * delivering.
> > > + *
> > > + * Return: 0 on success, -errno on failure.
> > > + */
> > > +
> > > +#define VFIO_DEVICE_SET_GFX_FLIP_EVENTFD _IO(VFIO_TYPE,  
> > VFIO_BASE +  
> > > +17)
> > > +
> > >  /* -------- API for Type1 VFIO IOMMU -------- */
> > >
> > >  /**  
> > 
> > Why can't we use VFIO_DEVICE_SET_IRQS for this?  We can add a capability
> > to vfio_irq_info in the same way that we did for regions to describe device
> > specific IRQ support.  Thanks,  
> Add a new kind of index, like this?
> enum {
>         VFIO_PCI_INTX_IRQ_INDEX,
>         VFIO_PCI_MSI_IRQ_INDEX,
>         VFIO_PCI_MSIX_IRQ_INDEX,
>         VFIO_PCI_ERR_IRQ_INDEX,
>         VFIO_PCI_REQ_IRQ_INDEX,
> +      VFIO_PCI_GFX_FLIP_EVENT_INDEX,
>         VFIO_PCI_NUM_IRQS
> };
> Perhaps this is what we don't want. This
> VFIO_PCI_GFX_FLIP_EVENT_INDEX is specific to graphics card and it's
> actually an event which is reported by INTX/MSI/ MSIX IRQ. Thanks.

Right, that is not what I'm suggesting.  What I'm looking for is a
similar conversion to what we did for regions, where we extended the
data returned in GET_REGION_INFO to include capabilities
(c84982adb23b), capped the number of regions we define with fixed
indexes (c7bb4cb40f89), and added device specific regions, such as IGD
OpRegion (5846ff54e87d) and IGD host and LPC bridges (f572a960a15e).
The same thing should happen here, the current value of
VFIO_PCI_NUM_IRQS becomes fixed and part of the vfio-pci ABI,
vfio_irq_info is extended with capability support following the same
mechanism, headers, and helpers we use for regions, then the mdev device
simply exposes the extended (and backwards compatible) API without
requiring a device specific ioctl.  Thanks,

Alex

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-05-28  4:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-27  8:43 [PATCH 0/2] Deliver vGPU page flip event to userspace Tina Zhang
2019-05-27  8:43 ` [PATCH 1/2] vfio: ABI for setting mdev display flip eventfd Tina Zhang
2019-05-27  9:07   ` Zhenyu Wang
2019-05-27 12:22     ` Gerd Hoffmann
2019-05-28  2:51       ` Zhenyu Wang
2019-05-27 14:04   ` Alex Williamson
2019-05-28  1:42     ` Zhang, Tina
2019-05-28  4:18       ` Alex Williamson
2019-05-27  8:43 ` [PATCH 2/2] drm/i915/gvt: Support delivering page flip event to userspace Tina Zhang
2019-05-27  9:11   ` Zhenyu Wang

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).