[Intel-gfx] [PATCH v14 5/7] vfio: ABI for mdev display dma-buf operation
Gerd Hoffmann
kraxel at redhat.com
Tue Sep 26 07:12:03 UTC 2017
Hi,
[ bringing a private discussion back to the list ]
> The dma-buf's life cycle is handled by user mode and tracked by
> kernel.
> The returned fd in struct vfio_device_query_gfx_plane can be a new
> fd or an old fd of a re-exported dma-buf. Host user mode can check
> the
> value of fd and to see if it needs to create new resource according
> to
> the new fd or just use the existed resource related to the old fd.
Ok, this idea has a fundamental flaw: The life cycle of the dma-buf
and the file handle are not identical. The dma-buf can exist longer
than the file handle in case other references to the dma-buf exist. So
when trying to use the file handle as identifier for the dma-buf you'll
end up with all sorts of strange effects.
So, I'd suggest to use a id instead, and add a ioctl to get a dmabuf
for a given id (incremental patch):
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -538,12 +538,22 @@ struct vfio_device_gfx_plane_info {
__u32 y_pos; /* vertical position of cursor plane, upper
left corner in lines*/
union {
__u32 region_index; /* region index */
- __s32 fd; /* dma-buf fd */
+ __u32 dmabuf_id; /* dma-buf id */
};
};
#define VFIO_DEVICE_QUERY_GFX_PLANE _IO(VFIO_TYPE, VFIO_BASE + 14)
+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)
/* -------- API for Type1 VFIO IOMMU -------- */
[ no changes for a region-based display ]
git branch, kernel, with updated dmabuf patch:
https://www.kraxel.org/cgit/linux/log/?h=gvt-dmabuf-v14
qemu branch:
https://www.kraxel.org/cgit/qemu/log/?h=work/intel-vgpu
cheers,
Gerd
More information about the Intel-gfx
mailing list