Commit 29cf1239 authored by Gerd Hoffmann's avatar Gerd Hoffmann

drm/virtio: switch virtio_gpu_wait_ioctl() to gem helper.

Use drm_gem_reservation_object_wait() in virtio_gpu_wait_ioctl().
This also makes the ioctl run lockless.

v9: fix return value.
v5: handle lookup failure.
v2: use reservation_object_test_signaled_rcu for VIRTGPU_WAIT_NOWAIT.
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: default avatarChia-I Wu <olvaffe@gmail.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20190829103301.3539-3-kraxel@redhat.com
parent 889165ad
...@@ -463,25 +463,29 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data, ...@@ -463,25 +463,29 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data,
} }
static int virtio_gpu_wait_ioctl(struct drm_device *dev, void *data, static int virtio_gpu_wait_ioctl(struct drm_device *dev, void *data,
struct drm_file *file) struct drm_file *file)
{ {
struct drm_virtgpu_3d_wait *args = data; struct drm_virtgpu_3d_wait *args = data;
struct drm_gem_object *gobj = NULL; struct drm_gem_object *obj;
struct virtio_gpu_object *qobj = NULL; long timeout = 15 * HZ;
int ret; int ret;
bool nowait = false;
gobj = drm_gem_object_lookup(file, args->handle); obj = drm_gem_object_lookup(file, args->handle);
if (gobj == NULL) if (obj == NULL)
return -ENOENT; return -ENOENT;
qobj = gem_to_virtio_gpu_obj(gobj); if (args->flags & VIRTGPU_WAIT_NOWAIT) {
ret = dma_resv_test_signaled_rcu(obj->resv, true);
if (args->flags & VIRTGPU_WAIT_NOWAIT) } else {
nowait = true; ret = dma_resv_wait_timeout_rcu(obj->resv, true, true,
ret = virtio_gpu_object_wait(qobj, nowait); timeout);
}
if (ret == 0)
ret = -EBUSY;
else if (ret > 0)
ret = 0;
drm_gem_object_put_unlocked(gobj); drm_gem_object_put_unlocked(obj);
return ret; return ret;
} }
......
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