Commit 8f20660f authored by Ryan Neph's avatar Ryan Neph Committed by Dmitry Osipenko

drm/virtio: exbuf->fence_fd unmodified on interrupted wait

An interrupted dma_fence_wait() becomes an -ERESTARTSYS returned
to userspace ioctl(DRM_IOCTL_VIRTGPU_EXECBUFFER) calls, prompting to
retry the ioctl(), but the passed exbuf->fence_fd has been reset to -1,
making the retry attempt fail at sync_file_get_fence().

The uapi for DRM_IOCTL_VIRTGPU_EXECBUFFER is changed to retain the
passed value for exbuf->fence_fd when returning anything besides a
successful result from the ioctl.

Fixes: 2cd7b6f0 ("drm/virtio: add in/out fence support for explicit synchronization")
Signed-off-by: default avatarRyan Neph <ryanneph@chromium.org>
Reviewed-by: default avatarRob Clark <robdclark@gmail.com>
Reviewed-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
Signed-off-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230203233345.2477767-1-ryanneph@chromium.org
parent 9f8b3706
...@@ -126,7 +126,6 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, ...@@ -126,7 +126,6 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
void __user *user_bo_handles = NULL; void __user *user_bo_handles = NULL;
struct virtio_gpu_object_array *buflist = NULL; struct virtio_gpu_object_array *buflist = NULL;
struct sync_file *sync_file; struct sync_file *sync_file;
int in_fence_fd = exbuf->fence_fd;
int out_fence_fd = -1; int out_fence_fd = -1;
void *buf; void *buf;
uint64_t fence_ctx; uint64_t fence_ctx;
...@@ -152,13 +151,11 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, ...@@ -152,13 +151,11 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
ring_idx = exbuf->ring_idx; ring_idx = exbuf->ring_idx;
} }
exbuf->fence_fd = -1;
virtio_gpu_create_context(dev, file); virtio_gpu_create_context(dev, file);
if (exbuf->flags & VIRTGPU_EXECBUF_FENCE_FD_IN) { if (exbuf->flags & VIRTGPU_EXECBUF_FENCE_FD_IN) {
struct dma_fence *in_fence; struct dma_fence *in_fence;
in_fence = sync_file_get_fence(in_fence_fd); in_fence = sync_file_get_fence(exbuf->fence_fd);
if (!in_fence) if (!in_fence)
return -EINVAL; return -EINVAL;
......
...@@ -64,6 +64,7 @@ struct drm_virtgpu_map { ...@@ -64,6 +64,7 @@ struct drm_virtgpu_map {
__u32 pad; __u32 pad;
}; };
/* fence_fd is modified on success if VIRTGPU_EXECBUF_FENCE_FD_OUT flag is set. */
struct drm_virtgpu_execbuffer { struct drm_virtgpu_execbuffer {
__u32 flags; __u32 flags;
__u32 size; __u32 size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment