From patchwork Mon Dec 11 10:39:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10104685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 09481602D8 for ; Mon, 11 Dec 2017 10:40:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1798029539 for ; Mon, 11 Dec 2017 10:40:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C4A22953D; Mon, 11 Dec 2017 10:40:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9F96529539 for ; Mon, 11 Dec 2017 10:40:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 034296E156; Mon, 11 Dec 2017 10:40:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id D39D66E156; Mon, 11 Dec 2017 10:40:03 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 9946743-1500050 for multiple; Mon, 11 Dec 2017 10:39:54 +0000 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Mon, 11 Dec 2017 10:39:54 +0000 From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm: Give the DRM device's anon_inode a unique lockclass for its mmap_rswem Date: Mon, 11 Dec 2017 10:39:54 +0000 Message-Id: <20171211103954.21213-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.15.1 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Cc: Daniel Vetter , intel-gfx@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Daniel Vetter --- 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; }