All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: Give the DRM device's anon_inode a unique lockclass for its mmap_rswem
@ 2017-12-11 10:39 Chris Wilson
  2017-12-11 11:58 ` ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Chris Wilson @ 2017-12-11 10:39 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter, intel-gfx

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@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-12-11 17:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-11 10:39 [PATCH] drm: Give the DRM device's anon_inode a unique lockclass for its mmap_rswem Chris Wilson
2017-12-11 11:58 ` ✓ Fi.CI.BAT: success for " Patchwork
2017-12-11 13:15 ` ✓ Fi.CI.IGT: " Patchwork
2017-12-11 17:20 ` [PATCH] " Daniel Vetter
2017-12-11 17:27   ` Chris Wilson
2017-12-11 17:44     ` Daniel Vetter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.