[PATCH] drm: Give the DRM device's anon_inode a unique lockclass for its mmap_rswem

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

 



Teach lockdep to track the device's internal mmapping separately
from the generic lockclass over all other inodes. Since this is device
private we wish to allow a different locking hierarchy than is typified
by the requirement for the mmap_rwsem being the outermost lock for
handling pagefaults. By giving the internal mmap_rwsem a distinct
lockclass, lockdep can identify it and learn/enforce its distinct locking
requirements.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104209
Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
Cc: Daniel Vetter <daniel.vetter@xxxxxxxx>
---
 drivers/gpu/drm/drm_drv.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 9acc1e157813..21ad06c3d684 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -393,6 +393,7 @@ static struct file_system_type drm_fs_type = {
 
 static struct inode *drm_fs_inode_new(void)
 {
+	static struct lock_class_key lockclass;
 	struct inode *inode;
 	int r;
 
@@ -403,8 +404,22 @@ static struct inode *drm_fs_inode_new(void)
 	}
 
 	inode = alloc_anon_inode(drm_fs_mnt->mnt_sb);
-	if (IS_ERR(inode))
+	if (IS_ERR(inode)) {
 		simple_release_fs(&drm_fs_mnt, &drm_fs_cnt);
+		return inode;
+	}
+
+	/*
+	 * Teach lockdep to track the device's internal mmapping separately
+	 * from all other inodes. Since this is device private we wish to
+	 * allow a different locking hierarchy than is typified by the
+	 * requirement for the mmap_rwsem being the outermost lock for
+	 * handling pagefaults. By giving the internal mmap_rwsem a distinct
+	 * lockclass, lockdep can identify it and thereby learn and enforce its
+	 * distinct locking requirements.
+	 */
+	lockdep_set_class_and_name(&inode->i_mapping->i_mmap_rwsem,
+				   &lockclass, "drm_fs_inode");
 
 	return inode;
 }
-- 
2.15.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