Skip to content

Commit 8f20660

Browse files
Ryan Nephdigetx
authored andcommitted
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: 2cd7b6f ("drm/virtio: add in/out fence support for explicit synchronization") Signed-off-by: Ryan Neph <[email protected]> Reviewed-by: Rob Clark <[email protected]> Reviewed-by: Dmitry Osipenko <[email protected]> Signed-off-by: Dmitry Osipenko <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 9f8b370 commit 8f20660

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

drivers/gpu/drm/virtio/virtgpu_ioctl.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
126126
void __user *user_bo_handles = NULL;
127127
struct virtio_gpu_object_array *buflist = NULL;
128128
struct sync_file *sync_file;
129-
int in_fence_fd = exbuf->fence_fd;
130129
int out_fence_fd = -1;
131130
void *buf;
132131
uint64_t fence_ctx;
@@ -152,13 +151,11 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
152151
ring_idx = exbuf->ring_idx;
153152
}
154153

155-
exbuf->fence_fd = -1;
156-
157154
virtio_gpu_create_context(dev, file);
158155
if (exbuf->flags & VIRTGPU_EXECBUF_FENCE_FD_IN) {
159156
struct dma_fence *in_fence;
160157

161-
in_fence = sync_file_get_fence(in_fence_fd);
158+
in_fence = sync_file_get_fence(exbuf->fence_fd);
162159

163160
if (!in_fence)
164161
return -EINVAL;

include/uapi/drm/virtgpu_drm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct drm_virtgpu_map {
6464
__u32 pad;
6565
};
6666

67+
/* fence_fd is modified on success if VIRTGPU_EXECBUF_FENCE_FD_OUT flag is set. */
6768
struct drm_virtgpu_execbuffer {
6869
__u32 flags;
6970
__u32 size;

0 commit comments

Comments
 (0)