intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Tina Zhang <tina.zhang@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	kwankhede@nvidia.com, zhiyuan.lv@intel.com,
	intel-gvt-dev@lists.freedesktop.org, kraxel@redhat.com
Subject: Re: [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation
Date: Sun, 5 Nov 2017 19:39:22 -0700	[thread overview]
Message-ID: <20171105193922.5dc9356a@t450s.home> (raw)
In-Reply-To: <1509934758-5003-6-git-send-email-tina.zhang@intel.com>

On Mon,  6 Nov 2017 10:19:17 +0800
Tina Zhang <tina.zhang@intel.com> wrote:

> Add VFIO_DEVICE_QUERY_GFX_PLANE ioctl command to let user query and get
> a plane and its related information. So far, two types of buffers are
> supported: buffers based on dma-buf and buffers based on region.
> 
> This ioctl can be invoked with:
> 1) either DMABUF or REGION flag. Vendor driver returns a plane_info
> successfully only when the specific kind of buffer is supported.
> 2) flag PROBE. And at the same time either DMABUF or REGION must be set,
> so that vendor driver can return success only when the specific kind of
> buffer is supported.
> 
> Add VFIO_DEVICE_GET_GFX_DMABUF ioctl command to let user get an exposed
> dma-buf fd of a specific dmabuf_id which was returned in VFIO_DEVICE_QUERY
> _GFX_PLANE ioctl command.
> 
> The life cycle of an exposed MDEV buffer is handled by userspace and
> tracked by kernel space. The returned dmabuf_id in struct vfio_device_
> query_gfx_plane can be a new id of a new exposed buffer or an old id of
> a re-exported buffer. Host user can check the value of dmabuf_id to see
> if it needs to create new resources according to the new exposed buffer
> or just re-use the existing resource related to the old buffer.
> 
> v16:
> - add x_hot and y_hot fields. (Gerd)
> - add comments for VFIO_DEVICE_GET_GFX_DMABUF. (Alex)
> - rebase to 4.14.0-rc6.
> 
> v15:
> - add a ioctl to get a dmabuf for a given dmabuf id. (Gerd)
> 
> v14:
> - add PROBE, DMABUF and REGION flags. (Alex)
> 
> v12:
> - add drm_format_mod back. (Gerd and Zhenyu)
> - add region_index. (Gerd)
> 
> v11:
> - rename plane_type to drm_plane_type. (Gerd)
> - move fields of vfio_device_query_gfx_plane to vfio_device_gfx_plane_info.
>   (Gerd)
> - remove drm_format_mod, start fields. (Daniel)
> - remove plane_id.
> 
> v10:
> - refine the ABI API VFIO_DEVICE_QUERY_GFX_PLANE. (Alex) (Gerd)
> 
> v3:
> - add a field gvt_plane_info in the drm_i915_gem_obj structure to save
>   the decoded plane information to avoid look up while need the plane
>   info. (Gerd)
> 
> Signed-off-by: Tina Zhang <tina.zhang@intel.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> ---
>  include/uapi/linux/vfio.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 68 insertions(+)
> 
> diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
> index ae46105..6c55668 100644
> --- a/include/uapi/linux/vfio.h
> +++ b/include/uapi/linux/vfio.h
> @@ -502,6 +502,74 @@ struct vfio_pci_hot_reset {
>  
>  #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE, VFIO_BASE + 13)
>  
> +/**
> + * VFIO_DEVICE_QUERY_GFX_PLANE - _IOW(VFIO_TYPE, VFIO_BASE + 14,
> + *                                    struct vfio_device_query_gfx_plane)
> + *
> + * Set the drm_plane_type and flags, then retrieve the gfx plane info.
> + *
> + * flags supported:
> + * - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_DMABUF are set
> + *   to ask if the mdev supports dma-buf. 0 on support, -EINVAL on no
> + *   support for dma-buf.
> + * - VFIO_GFX_PLANE_TYPE_PROBE and VFIO_GFX_PLANE_TYPE_REGION are set
> + *   to ask if the mdev supports region. 0 on support, -EINVAL on no
> + *   support for region.
> + * - VFIO_GFX_PLANE_TYPE_DMABUF or VFIO_GFX_PLANE_TYPE_REGION is set
> + *   with each call to query the plane info.
> + * - Others are invalid and return -EINVAL.
> + *
> + * Return: 0 on success, -ENODEV with all out fields zero on mdev
> + * device initialization, -errno on other failure.
> + */
> +struct vfio_device_gfx_plane_info {
> +	__u32 argsz;
> +	__u32 flags;
> +#define VFIO_GFX_PLANE_TYPE_PROBE (1 << 0)
> +#define VFIO_GFX_PLANE_TYPE_DMABUF (1 << 1)
> +#define VFIO_GFX_PLANE_TYPE_REGION (1 << 2)
> +	/* in */
> +	__u32 drm_plane_type;	/* type of plane: DRM_PLANE_TYPE_* */
> +	/* out */
> +	__u32 drm_format;	/* drm format of plane */
> +	__u64 drm_format_mod;   /* tiled mode */
> +	__u32 width;	/* width of plane */
> +	__u32 height;	/* height of plane */
> +	__u32 stride;	/* stride of plane */
> +	__u32 size;	/* size of plane in bytes, align on page*/
> +	__u32 x_pos;	/* horizontal position of cursor plane */
> +	__u32 y_pos;	/* vertical position of cursor plane*/
> +	__u32 x_hot;    /* horizontal position of cursor hotspot */
> +	__u32 y_hot;    /* vertical position of cursor hotspot */
> +	union {
> +		__u32 region_index;	/* region index */
> +		__u32 dmabuf_id;	/* dma-buf id */
> +	};
> +};
> +
> +#define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14)
> +
> +/**
> + * VFIO_DEVICE_GET_GFX_DMABUF - _IOW(VFIO_TYPE, VFIO_BASE + 15,
> + *				    struct vfio_device_gfx_dmabuf_fd)
> + *
> + * Retrieve dmabuf_fd of an exposed guest framebuffer referenced by dmabuf_id
> + * which is returned from VFIO_DEVICE_QUERY_GFX_PLANE as a token of the
> + * exposed guest framebuffer.
> + *
> + * Return: 0 on success, -errno on failure.
> + */
> +struct vfio_device_gfx_dmabuf_fd {
> +	__u32 argsz;
> +	__u32 flags;
> +	/* in */
> +	__u32 dmabuf_id;
> +	/* out */
> +	__s32 dmabuf_fd;
> +};
> +
> +#define VFIO_DEVICE_GET_GFX_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 15)
> +

I thought we had agreed to make this behave similar to
VFIO_GROUP_GET_DEVICE_FD, the ioctl would take a __u32 dmabuf_id and
return the file descriptor as the ioctl return value.  Thanks,

Alex
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2017-11-06  2:39 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-06  2:19 [PATCH v16 0/6] drm/i915/gvt: Dma-buf support for GVT-g Tina Zhang
2017-11-06  2:19 ` [PATCH v16 1/6] drm/i915/gvt: Add framebuffer decoder support Tina Zhang
2017-11-06  8:48   ` Gerd Hoffmann
2017-11-06  9:07     ` Zhang, Tina
2017-11-06  2:19 ` [PATCH v16 2/6] drm: Introduce RGB 64-bit 16:16:16:16 float format Tina Zhang
2017-11-06  2:19 ` [PATCH v16 3/6] drm/i915/gvt: Add " Tina Zhang
2017-11-06  2:19 ` [PATCH v16 4/6] drm/i915/gvt: Add opregion support Tina Zhang
2017-11-06  2:19 ` [PATCH v16 5/6] vfio: ABI for mdev display dma-buf operation Tina Zhang
2017-11-06  2:39   ` Alex Williamson [this message]
2017-11-06  6:58     ` Zhang, Tina
2017-11-06  9:05       ` Gerd Hoffmann
2017-11-06 20:36         ` Alex Williamson
2017-11-07  5:00           ` Zhang, Tina
2017-11-06  9:01   ` Gerd Hoffmann
2017-11-07  5:44     ` Zhang, Tina
2017-11-07  8:03       ` Gerd Hoffmann
2017-11-07 16:48         ` Alex Williamson
2017-11-08  8:25           ` Gerd Hoffmann
2017-11-08 21:19             ` Alex Williamson
2017-11-08  5:21         ` Zhang, Tina
2017-11-06  2:19 ` [PATCH v16 6/6] drm/i915/gvt: Dmabuf support for GVT-g Tina Zhang
2017-11-06  2:26 ` ✗ Fi.CI.BAT: failure for drm/i915/gvt: Dma-buf " Patchwork

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=20171105193922.5dc9356a@t450s.home \
    --to=alex.williamson@redhat.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-gvt-dev@lists.freedesktop.org \
    --cc=kraxel@redhat.com \
    --cc=kwankhede@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tina.zhang@intel.com \
    --cc=zhiyuan.lv@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).