From patchwork Tue Jun 14 18:51:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 9176507 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 947CD60772 for ; Tue, 14 Jun 2016 18:51:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BF6C2793B for ; Tue, 14 Jun 2016 18:51:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70E432824A; Tue, 14 Jun 2016 18:51:44 +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=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E6C02793B for ; Tue, 14 Jun 2016 18:51:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9B9986E800; Tue, 14 Jun 2016 18:51:28 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id B95F46E809 for ; Tue, 14 Jun 2016 18:51:25 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id r5so647743wmr.0 for ; Tue, 14 Jun 2016 11:51:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V+oEysOQuSTBIAFx2YYxktpuuawop3PAfpymnyrKiNY=; b=DZ0kOuOuzx6dTvBRZ9MFyAlkiBmlbnp9N8vRL+gH5d6xqTFRs1F0AulyMVLO+yK8M9 eG+i7JK86IgeVKk198PLw+HGt4SC+ACWAQxl2P/uHPX+9GeI/C5hQug5nhbWci9yZK19 K0xLqLr3y2CaqihGC8/bZCHlF6GB4bTVLyinI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V+oEysOQuSTBIAFx2YYxktpuuawop3PAfpymnyrKiNY=; b=aCMZqY71FuKNWdapal5AwM7fS4FixgEMh6m1mJSXHEX5C2acGXXHQfwlt+o/lcYcat 9M3noyNv2GCSlv+ARQjRW5w1SI4E6RLX69WKFbdFEC3WCQHmlWH3vDQCq+e6gvhuDzxG vna33RBKeaVsx48hQxLbX2QIKWR5ynVJJoUiwSpjqblq0yhR/A/wLdz2J/woEtyoZTD5 jqjzfHcJNz+uWuLRsHo3f3sLOo0E+5B+KWjtxIwHSEZKsY/NarXDetZecGaRahB8oUnu 5DtCZ9h0XybiKi5OyoeAN5ar5r1jAQFF9q0KrWtMgg13jVLgs2Mh0RA24zbisRDp/UhB MMfw== X-Gm-Message-State: ALyK8tKOOwSbE4CIczNumeKVfFSdBTLZpwF2cBOKsItxk98lbeKCs6mHYj13dz3vnAQCDA== X-Received: by 10.194.21.39 with SMTP id s7mr7771407wje.24.1465930283920; Tue, 14 Jun 2016 11:51:23 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:56b5:0:ac27:b86c:7764:9429]) by smtp.gmail.com with ESMTPSA id xs9sm31416882wjc.11.2016.06.14.11.51.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Jun 2016 11:51:23 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Tue, 14 Jun 2016 20:51:02 +0200 Message-Id: <1465930269-7883-8-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1465930269-7883-1-git-send-email-daniel.vetter@ffwll.ch> References: <1465930269-7883-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Intel Graphics Development , Daniel Vetter Subject: [Intel-gfx] [PATCH 07/14] drm: Only do the hw.lock cleanup in master_relase for !MODESET 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Another place gone where modern drivers could have hit dev->struct_mutex. To avoid too deeply nesting control flow rework it a bit. Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_auth.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c index e015a7edb154..a58b2eb0d004 100644 --- a/drivers/gpu/drm/drm_auth.c +++ b/drivers/gpu/drm/drm_auth.c @@ -246,11 +246,14 @@ int drm_master_open(struct drm_file *file_priv) void drm_master_release(struct drm_file *file_priv) { struct drm_device *dev = file_priv->minor->dev; + struct drm_master *master = file_priv->master; + mutex_lock(&dev->master_mutex); - if (file_priv->is_master) { - struct drm_master *master = file_priv->master; + if (!file_priv->is_master) + goto out_unlock; + if (!drm_core_check_feature(dev, DRIVER_MODESET)) { /* * Since the master is disappearing, so is the * possibility to lock. @@ -264,19 +267,20 @@ void drm_master_release(struct drm_file *file_priv) wake_up_interruptible_all(&master->lock.lock_queue); } mutex_unlock(&dev->struct_mutex); + } - if (file_priv->minor->master == file_priv->master) { - /* drop the reference held my the minor */ - if (dev->driver->master_drop) - dev->driver->master_drop(dev, file_priv, true); - drm_master_put(&file_priv->minor->master); - } + if (file_priv->minor->master == file_priv->master) { + /* drop the reference held my the minor */ + if (dev->driver->master_drop) + dev->driver->master_drop(dev, file_priv, true); + drm_master_put(&file_priv->minor->master); } /* drop the master reference held by the file priv */ if (file_priv->master) drm_master_put(&file_priv->master); file_priv->is_master = 0; +out_unlock: mutex_unlock(&dev->master_mutex); }