From patchwork Mon Jul 17 09:35:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 9844671 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 653B86037F for ; Mon, 17 Jul 2017 10:49:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56CA727F81 for ; Mon, 17 Jul 2017 10:49:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B7662841D; Mon, 17 Jul 2017 10:49:14 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable 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 5F35927F81 for ; Mon, 17 Jul 2017 10:49:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 85B6989E19; Mon, 17 Jul 2017 10:49:12 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org X-Greylist: delayed 4440 seconds by postgrey-1.35 at gabe; Mon, 17 Jul 2017 10:49:11 UTC Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9800D89E19 for ; Mon, 17 Jul 2017 10:49:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=l7Xh0ipnXbLdIN2XGP0ftj8pgSAd96xG4Fh08gUreOI=; b=NTRLwPsXiKK2YrKgO6znDf1vC ekolPzs/eqGioFBkKAm8rMBkmniIs3R1dk8mFiKDw0bucK5TrUxyEH56k337255Ln7lFHi9itWkJc CXh689fB5VHpZSUFfPa1tk2pxwmXOPCJxfvQaKvVaYUT1qa3zngizjlNd9acTRfD0NNwYakiHwv+m eoinI1Gz9mfFpFoEPzAucw96a7ROChnp+kWj7sE+rfy50Wl70nWoP4NUar2OIR4tp7W7bNIMFCTSD yxg0nn+1aLlJilN7czn/B2l4Z+/MT7g67KAhlnrcaSscQr2txDIyimWmFWTzS43gNSX8gaV22q5I7 4iuk5ZyKg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1dX2Qg-0007Yl-Fg; Mon, 17 Jul 2017 09:35:02 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 55E572017409E; Mon, 17 Jul 2017 11:35:00 +0200 (CEST) Date: Mon, 17 Jul 2017 11:35:00 +0200 From: Peter Zijlstra To: Daniel Vetter Message-ID: <20170717093500.2zckgdzsfqctgild@hirez.programming.kicks-ass.net> References: <20170715095328.25671-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170715095328.25671-1-daniel.vetter@ffwll.ch> User-Agent: NeoMutt/20170609 (1.8.3) Cc: Jiri Slaby , Intel Graphics Development , DRI Development , Hans de Goede , Ingo Molnar , Ben Skeggs , Daniel Vetter Subject: Re: [Intel-gfx] [PATCH] drm: Don't complain too much about struct_mutex. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP On Sat, Jul 15, 2017 at 11:53:28AM +0200, Daniel Vetter wrote: > A more complete solution would be to do the mutex_init in the drm core > only for legacy drivers, plus add it to each modern driver that still > needs it, which would also give each its own lockdep key. Trying to do > that dynamically doesn't work, because lockdep requires it's keys to > be statically allocated. Would something like the below work? Its not pretty, but would give each user of drm_dev_init() its own key. diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 37b8ad3e30d8..06cc32012728 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -478,9 +478,10 @@ static void drm_fs_inode_free(struct inode *inode) * RETURNS: * 0 on success, or error code on failure. */ -int drm_dev_init(struct drm_device *dev, - struct drm_driver *driver, - struct device *parent) +int __drm_dev_init(struct drm_device *dev, + struct drm_driver *driver, + struct device *parent, + struct lock_class_key *key) { int ret; @@ -496,7 +497,7 @@ int drm_dev_init(struct drm_device *dev, spin_lock_init(&dev->buf_lock); spin_lock_init(&dev->event_lock); - mutex_init(&dev->struct_mutex); + __mutex_init(&dev->struct_mutex, "&dev->struct_mutex", key); mutex_init(&dev->filelist_mutex); mutex_init(&dev->ctxlist_mutex); mutex_init(&dev->master_mutex); diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index 53b98321df9b..cda11e97024e 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -531,9 +531,17 @@ void drm_printk(const char *level, unsigned int category, const char *format, ...); extern unsigned int drm_debug; -int drm_dev_init(struct drm_device *dev, - struct drm_driver *driver, - struct device *parent); +int __drm_dev_init(struct drm_device *dev, + struct drm_driver *driver, + struct device *parent, + struct lock_class_key *key); + +#define drm_dev_init(_dev, _driver, _parent) \ +({ \ + static struct lock_class_key __key; \ + __drm_dev_init((_dev), (_driver), (_parent), &__key); \ +}) + void drm_dev_fini(struct drm_device *dev); struct drm_device *drm_dev_alloc(struct drm_driver *driver,