[PATCH] drm/syncobj: make lockdep complain on WAIT_FOR_SUBMIT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT can't be used when a reservation
object lock is help or otherwise we can deadlock with page faults.

Make lockdep complain badly about that.

Signed-off-by: Christian König <christian.koenig@xxxxxxx>
---
 drivers/gpu/drm/drm_syncobj.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index 6e74e6745eca..6228e9cd089a 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -387,6 +387,20 @@ int drm_syncobj_find_fence(struct drm_file *file_private,
 	if (!syncobj)
 		return -ENOENT;
 
+	if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT &&
+	    IS_ENABLED(CONFIG_LOCKDEP)) {
+		struct dma_resv robj;
+
+		/* Waiting for userspace with a reservation lock help is illegal
+		 * cause that can deadlock with page faults. Make lockdep
+		 * complain about it early on.
+		 */
+		dma_resv_init(&robj);
+		dma_resv_lock(&robj, NULL);
+		dma_resv_unlock(&robj);
+		dma_resv_fini(&robj);
+	}
+
 	*fence = drm_syncobj_fence_get(syncobj);
 	drm_syncobj_put(syncobj);
 
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux