Skip to content

Commit

Permalink
drm/virtio: switch virtio_gpu_wait_ioctl() to gem helper.
Browse files Browse the repository at this point in the history
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: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20190829103301.3539-3-kraxel@redhat.com
  • Loading branch information
Gerd Hoffmann committed Sep 4, 2019
1 parent 889165a commit 29cf123
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions drivers/gpu/drm/virtio/virtgpu_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
struct drm_file *file)
struct drm_file *file)
{
struct drm_virtgpu_3d_wait *args = data;
struct drm_gem_object *gobj = NULL;
struct virtio_gpu_object *qobj = NULL;
struct drm_gem_object *obj;
long timeout = 15 * HZ;
int ret;
bool nowait = false;

gobj = drm_gem_object_lookup(file, args->handle);
if (gobj == NULL)
obj = drm_gem_object_lookup(file, args->handle);
if (obj == NULL)
return -ENOENT;

qobj = gem_to_virtio_gpu_obj(gobj);

if (args->flags & VIRTGPU_WAIT_NOWAIT)
nowait = true;
ret = virtio_gpu_object_wait(qobj, nowait);
if (args->flags & VIRTGPU_WAIT_NOWAIT) {
ret = dma_resv_test_signaled_rcu(obj->resv, true);
} else {
ret = dma_resv_wait_timeout_rcu(obj->resv, true, true,
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;
}

Expand Down

0 comments on commit 29cf123

Please sign in to comment.