diff options
author | Gurchetan Singh <gurchetansingh@chromium.org> | 2020-02-24 16:07:59 -0800 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2020-02-25 09:48:42 +0100 |
commit | d2a983b220ac6628c53e4cf27a7335d1d29ce5e9 (patch) | |
tree | 3cf52944bdec5e786c8b7767b8c4567cc5bb77dc /drivers/gpu/drm/virtio/virtgpu_kms.c | |
parent | 40cadedd20a5fefba7ebca7cee7a8743a55e2509 (diff) | |
download | linux-d2a983b220ac6628c53e4cf27a7335d1d29ce5e9.tar.bz2 |
drm/virtio: track whether or not a context has been initiated
Use an boolean variable to track whether a context has been
initiated.
v5: Fix possible race and sleep via mutex (olv)
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
Link: http://patchwork.freedesktop.org/patch/msgid/20200225000800.2966-3-gurchetansingh@chromium.org
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/virtio/virtgpu_kms.c')
-rw-r--r-- | drivers/gpu/drm/virtio/virtgpu_kms.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index f7e3712502ca..424729cb81d1 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -258,6 +258,8 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file) if (!vfpriv) return -ENOMEM; + mutex_init(&vfpriv->context_lock); + handle = ida_alloc(&vgdev->ctx_id_ida, GFP_KERNEL); if (handle < 0) { kfree(vfpriv); @@ -281,6 +283,7 @@ void virtio_gpu_driver_postclose(struct drm_device *dev, struct drm_file *file) vfpriv = file->driver_priv; virtio_gpu_context_destroy(vgdev, vfpriv->ctx_id); + mutex_destroy(&vfpriv->context_lock); kfree(vfpriv); file->driver_priv = NULL; } |