Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752421AbdFOICX (ORCPT ); Thu, 15 Jun 2017 04:02:23 -0400 Received: from mga07.intel.com ([134.134.136.100]:60396 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752478AbdFOIBV (ORCPT ); Thu, 15 Jun 2017 04:01:21 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,342,1493708400"; d="scan'208";a="274546916" From: Xiaoguang Chen To: alex.williamson@redhat.com, kraxel@redhat.com, chris@chris-wilson.co.uk, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, zhenyuw@linux.intel.com, zhiyuan.lv@intel.com, intel-gvt-dev@lists.freedesktop.org, zhi.a.wang@intel.com, kevin.tian@intel.com Cc: Xiaoguang Chen Subject: [PATCH v9 5/7] vfio: Define vfio based dma-buf operations Date: Thu, 15 Jun 2017 16:00:09 +0800 Message-Id: <1497513611-2814-6-git-send-email-xiaoguang.chen@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497513611-2814-1-git-send-email-xiaoguang.chen@intel.com> References: <1497513611-2814-1-git-send-email-xiaoguang.chen@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2184 Lines: 81 Here we defined a new ioctl to create a fd for a vfio device based on the input type. Now only one type is supported that is a dma-buf management fd. Two ioctls are defined for the dma-buf management fd: query the vfio vgpu's plane information and create a dma-buf for a plane. Signed-off-by: Xiaoguang Chen --- include/uapi/linux/vfio.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index ae46105..7d86101 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -502,6 +502,63 @@ struct vfio_pci_hot_reset { #define VFIO_DEVICE_PCI_HOT_RESET _IO(VFIO_TYPE, VFIO_BASE + 13) +/** + * VFIO_DEVICE_GET_FD - _IO(VFIO_TYPE, VFIO_BASE + 14, __u32) + * + * Create a fd for a vfio device based on the input type + * Vendor driver should handle this ioctl to create a fd and manage the + * life cycle of this fd. + * + * Return: a fd if vendor support that type, -errno if not supported + */ + +#define VFIO_DEVICE_GET_FD _IO(VFIO_TYPE, VFIO_BASE + 14) + +#define VFIO_DEVICE_DMABUF_MGR_FD 0 /* Supported fd types */ + +struct vfio_dmabuf_mgr_plane_info { + __u64 start; + __u64 drm_format_mod; + __u32 drm_format; + __u32 width; + __u32 height; + __u32 stride; + __u32 size; + __u32 x_pos; + __u32 y_pos; + __u32 padding; +}; + +/* + * VFIO_DMABUF_MGR_QUERY_PLANE - _IO(VFIO_TYPE, VFIO_BASE + 15, + * struct vfio_dmabuf_mgr_query_plane) + * Query plane information + */ +struct vfio_dmabuf_mgr_query_plane { + __u32 argsz; + __u32 flags; + struct vfio_dmabuf_mgr_plane_info plane_info; + __u32 plane_id; +}; + +#define VFIO_DMABUF_MGR_QUERY_PLANE _IO(VFIO_TYPE, VFIO_BASE + 15) + +/* + * VFIO_DMABUF_MGR_CREATE_DMABUF - _IO(VFIO, VFIO_BASE + 16, + * struct vfio_dmabuf_mgr_create_dmabuf) + * + * Create a dma-buf for a plane + */ +struct vfio_dmabuf_mgr_create_dmabuf { + __u32 argsz; + __u32 flags; + struct vfio_dmabuf_mgr_plane_info plane_info; + __u32 plane_id; + __s32 fd; +}; + +#define VFIO_DMABUF_MGR_CREATE_DMABUF _IO(VFIO_TYPE, VFIO_BASE + 16) + /* -------- API for Type1 VFIO IOMMU -------- */ /** -- 2.7.4