From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752329AbdKIPaN (ORCPT ); Thu, 9 Nov 2017 10:30:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57702 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750940AbdKIPaL (ORCPT ); Thu, 9 Nov 2017 10:30:11 -0500 Date: Thu, 9 Nov 2017 08:29:56 -0700 From: Alex Williamson To: Tina Zhang Cc: kraxel@redhat.com, chris@chris-wilson.co.uk, joonas.lahtinen@linux.intel.com, zhenyuw@linux.intel.com, zhiyuan.lv@intel.com, zhi.a.wang@intel.com, kevin.tian@intel.com, daniel@ffwll.ch, kwankhede@nvidia.com, hang.yuan@intel.com, intel-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, linux-kernel@vger.kernel.org, Daniel Vetter Subject: Re: [PATCH v17 5/6] vfio: ABI for mdev display dma-buf operation Message-ID: <20171109082956.2c490080@t450s.home> In-Reply-To: <1510220042-4931-6-git-send-email-tina.zhang@intel.com> References: <1510220042-4931-1-git-send-email-tina.zhang@intel.com> <1510220042-4931-6-git-send-email-tina.zhang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 09 Nov 2017 15:30:11 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 9 Nov 2017 17:34:01 +0800 Tina Zhang 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. > > v17: > - modify VFIO_DEVICE_GET_GFX_DMABUF interface. (Alex) > > 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 > Cc: Gerd Hoffmann > Cc: Alex Williamson > Cc: Daniel Vetter > --- > include/uapi/linux/vfio.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 64 insertions(+) > > diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h > index ae46105..88b2de7d 100644 > --- a/include/uapi/linux/vfio.h > +++ b/include/uapi/linux/vfio.h > @@ -502,6 +502,70 @@ 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. > + * > + * Note: > + * 1. Plane could be disabled by guest. In that case, success will be > + * returned with zero-initialized drm_format, size, width and height > + * fields. > + * 2. x_hot/y_hot is set to 0xFFFFFFFF if no hotspot information available > + * > + * Return: 0 on success, -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, __u32) > + * > + * Retrieve a 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. > + */ > + > +#define _IO(VFIO_TYPE, VFIO_BASE + 15) > + > /* -------- API for Type1 VFIO IOMMU -------- */ > > /** Return value is described incorrectly for VFIO_DEVICE_GET_GFX_DMABUF, struct vfio_device_gfx_plane_info lacks the head field we've been discussing. Thanks, Alex