Skip to contentSkip to conversation

drm/virtio: locking/reservation fixes

PATCH In review Gerd Hoffmann 2 participants 4 messages Feb 11, 2020 – Feb 12, 2020

Subsystems (4)
lore
Share & tools
lore
author maintainer
#1 lore raw

PATCH 1/2 drm/virtio: fix virtio_gpu_execbuffer_ioctl locking

In reply to Gerd Hoffmann

Lockdep says we can't call vmemdup() while having objects reserved because it needs the mmap semaphore. So reorder the calls reserve the objects later.

---
 drivers/gpu/drm/virtio/virtgpu_ioctl.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/virtio/virtgpu_ioctl.c +10 -10
index 205ec4abae2b..0477d1250f2d 100644
@@ -126,22 +126,22 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
 		bo_handles = NULL;
 	}
 
-	if (buflist) {
-		ret = virtio_gpu_array_lock_resv(buflist);
-		if (ret)
-			goto out_unused_fd;
-	}
-
 	buf = vmemdup_user(u64_to_user_ptr(exbuf->command), exbuf->size);
 	if (IS_ERR(buf)) {
 		ret = PTR_ERR(buf);
-		goto out_unresv;
+		goto out_unused_fd;
+	}
+
+	if (buflist) {
+		ret = virtio_gpu_array_lock_resv(buflist);
+		if (ret)
+			goto out_memdup;
 	}
 
 	out_fence = virtio_gpu_fence_alloc(vgdev);
 	if(!out_fence) {
 		ret = -ENOMEM;
-		goto out_memdup;
+		goto out_unresv;
 	}
 
 	if (out_fence_fd >= 0) {
@@ -160,11 +160,11 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
 			      vfpriv->ctx_id, buflist, out_fence);
 	return 0;
 
-out_memdup:
-	kvfree(buf);
 out_unresv:
 	if (buflist)
 		virtio_gpu_array_unlock_resv(buflist);
+out_memdup:
+	kvfree(buf);
 out_unused_fd:
 	kvfree(bo_handles);
 	if (buflist)
Signature · 1 line
2.18.2
author maintainer
#2 lore raw

PATCH 2/2 drm/virtio: fix virtio_gpu_cursor_plane_update().

In reply to Gerd Hoffmann

Add missing virtio_gpu_array_lock_resv() call.

---
 drivers/gpu/drm/virtio/virtgpu_plane.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/virtio/virtgpu_plane.c +1 -0
index ac42c84d2d7f..d1c3f5fbfee4 100644
@@ -260,6 +260,7 @@ static void virtio_gpu_cursor_plane_update(struct drm_plane *plane,
 		if (!objs)
 			return;
 		virtio_gpu_array_add_obj(objs, vgfb->base.obj[0]);
+		virtio_gpu_array_lock_resv(objs);
 		virtio_gpu_cmd_transfer_to_host_2d
 			(vgdev, 0,
 			 plane->state->crtc_w,
Signature · 1 line
2.18.2

Gerd Hoffmann

author maintainer
#0 lore raw

cover drm/virtio: locking/reservation fixes

Gerd Hoffmann (2):
drm/virtio: fix virtio_gpu_execbuffer_ioctl locking drm/virtio: fix virtio_gpu_cursor_plane_update().

 drivers/gpu/drm/virtio/virtgpu_ioctl.c | 20 ++++++++++----------
 drivers/gpu/drm/virtio/virtgpu_plane.c |  1 +
 2 files changed, 11 insertions(+), 10 deletions(-)
Signature · 6 lines
2.18.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
reviewer Reviewed-by on the v1 series
#3 lore raw

The fixes look reasonable.

Quoted 7 lines · Gerd Hoffmann

Gerd Hoffmann (2):
drm/virtio: fix virtio_gpu_execbuffer_ioctl locking drm/virtio: fix virtio_gpu_cursor_plane_update().

Quoted 7 lines
 drivers/gpu/drm/virtio/virtgpu_ioctl.c | 20 ++++++++++----------
 drivers/gpu/drm/virtio/virtgpu_plane.c |  1 +
 2 files changed, 11 insertions(+), 10 deletions(-)

--
2.18.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel