]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
drm/virtio: add uapi for in and out explicit fences
authorRobert Foss <robert.foss@collabora.com>
Mon, 12 Nov 2018 16:51:55 +0000 (17:51 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 14 Nov 2018 13:21:01 +0000 (14:21 +0100)
Add a new field called fence_fd that will be used by userspace to send
in-fences to the kernel and receive out-fences created by the kernel.

This uapi enables virtio to take advantage of explicit synchronization of
dma-bufs.

There are two new flags:

* VIRTGPU_EXECBUF_FENCE_FD_IN to be used when passing an in-fence fd.
* VIRTGPU_EXECBUF_FENCE_FD_OUT to be used when requesting an out-fence fd

The execbuffer IOCTL is now read-write to allow the userspace to read the
out-fence.

On error -1 should be returned in the fence_fd field.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
Signed-off-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20181112165157.32765-3-robert.foss@collabora.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
drivers/gpu/drm/virtio/virtgpu_ioctl.c
include/uapi/drm/virtgpu_drm.h

index d69fc356df0aa3168100dd87dd5ae7c0d81e3ac8..3d497835b0f5a73252f283cceaa04fc76e773af8 100644 (file)
@@ -119,6 +119,11 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
        if (vgdev->has_virgl_3d == false)
                return -ENOSYS;
 
+       if ((exbuf->flags & ~VIRTGPU_EXECBUF_FLAGS))
+               return -EINVAL;
+
+       exbuf->fence_fd = -1;
+
        INIT_LIST_HEAD(&validate_list);
        if (exbuf->num_bo_handles) {
 
index 9a781f0611df0280be7d952258f486f805f27528..91062f4ac7c5175285eb7eea4d32eab3e22456a2 100644 (file)
@@ -47,6 +47,13 @@ extern "C" {
 #define DRM_VIRTGPU_WAIT     0x08
 #define DRM_VIRTGPU_GET_CAPS  0x09
 
+#define VIRTGPU_EXECBUF_FENCE_FD_IN    0x01
+#define VIRTGPU_EXECBUF_FENCE_FD_OUT   0x02
+#define VIRTGPU_EXECBUF_FLAGS  (\
+               VIRTGPU_EXECBUF_FENCE_FD_IN |\
+               VIRTGPU_EXECBUF_FENCE_FD_OUT |\
+               0)
+
 struct drm_virtgpu_map {
        __u64 offset; /* use for mmap system call */
        __u32 handle;
@@ -54,12 +61,12 @@ struct drm_virtgpu_map {
 };
 
 struct drm_virtgpu_execbuffer {
-       __u32           flags;          /* for future use */
+       __u32 flags;
        __u32 size;
        __u64 command; /* void* */
        __u64 bo_handles;
        __u32 num_bo_handles;
-       __u32 pad;
+       __s32 fence_fd;
 };
 
 #define VIRTGPU_PARAM_3D_FEATURES 1 /* do we have 3D features in the hw */
@@ -137,7 +144,7 @@ struct drm_virtgpu_get_caps {
        DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_MAP, struct drm_virtgpu_map)
 
 #define DRM_IOCTL_VIRTGPU_EXECBUFFER \
-       DRM_IOW(DRM_COMMAND_BASE + DRM_VIRTGPU_EXECBUFFER,\
+       DRM_IOWR(DRM_COMMAND_BASE + DRM_VIRTGPU_EXECBUFFER,\
                struct drm_virtgpu_execbuffer)
 
 #define DRM_IOCTL_VIRTGPU_GETPARAM \