From patchwork Fri Jun 17 07:33:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 9182729 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 C1D166075D for ; Fri, 17 Jun 2016 07:33:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B229D25E13 for ; Fri, 17 Jun 2016 07:33:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6F432839E; Fri, 17 Jun 2016 07:33:51 +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 3DCF425E13 for ; Fri, 17 Jun 2016 07:33:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8DE126EAF9; Fri, 17 Jun 2016 07:33:47 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id CE0E16E1CC for ; Fri, 17 Jun 2016 07:33:44 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id m124so16468126wme.3 for ; Fri, 17 Jun 2016 00:33:44 -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=EYG+cG1l5SEK7CjYNo2AUGpAj6/39ZXd+/mE2ZfotcQ=; b=foM8YjnUD/ZC47Fg78HWXCgxC4A6lqWy/oid6IbsczId3HSyt2gmRrWFCXHYx1dnH8 4e2aVrLMfzNDYcB1Ny8OmwxNfVd+fIOZ78BQsP0W+ZrdCUhkeUI+qy/zXP5AEeUFCzHv jpCxf2LuGRRyxxmNNu+7YZj5e9eY7Tyo8BUCA= 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=EYG+cG1l5SEK7CjYNo2AUGpAj6/39ZXd+/mE2ZfotcQ=; b=H1AM16KAPYsAOcWbnVBjfmKBZi3I9ZtLsMcSwlowi0UQx1uUU6cZFrATopWevyM5LY Y0dosYVC/as/19yde+mAAu6FhE7Izgwh83E6tlX+57NPM+s9rabps0eRLjajtCPjY72P 63DS3KVS5JY/WeN71V3DktcZ4qlGKIoBDPwuTjjAP5anBnFllkNS+iHY5Taw6EKTD9iS 9AA9lKu9tOpWIW5V1PijXRnZCel7ERLZx9JBZo5F6phemm261vgPs6zvLidSVIs2wC7W 8AZPnxFfuQkK8V9vDDNOkZEbCMjUalmHNGIzIC0XbQAYFqzj+PRv1MsAiuDGAWlc/mTc Wv8w== X-Gm-Message-State: ALyK8tJx11Jte9aZH1QQ0XxsJ3F2WuyC3e4PJVpATVNlZbUzNWBiJGG7x9NajApX+NUPhg== X-Received: by 10.194.153.98 with SMTP id vf2mr799337wjb.72.1466148822936; Fri, 17 Jun 2016 00:33:42 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:56b5:0:ac27:b86c:7764:9429]) by smtp.gmail.com with ESMTPSA id s67sm1475049wmf.3.2016.06.17.00.33.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jun 2016 00:33:42 -0700 (PDT) From: Daniel Vetter To: DRI Development Date: Fri, 17 Jun 2016 09:33:19 +0200 Message-Id: <1466148814-8194-2-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1466148814-8194-1-git-send-email-daniel.vetter@ffwll.ch> References: <1466148814-8194-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter , Daniel Vetter , Intel Graphics Development Subject: [Intel-gfx] [PATCH 01/16] 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. v2: Review from Chris: - remove spurious newline. - fix file_priv->master like for the !file_priv->is_master case. Cc: Chris Wilson Reviewed-by: Chris Wilson Signed-off-by: Daniel Vetter --- drivers/gpu/drm/drm_auth.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c index e015a7edb154..54ad64a6d052 100644 --- a/drivers/gpu/drm/drm_auth.c +++ b/drivers/gpu/drm/drm_auth.c @@ -246,11 +246,13 @@ 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; + if (!drm_core_check_feature(dev, DRIVER_MODESET)) { /* * Since the master is disappearing, so is the * possibility to lock. @@ -264,15 +266,15 @@ 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); + } +out: /* drop the master reference held by the file priv */ if (file_priv->master) drm_master_put(&file_priv->master);