From patchwork Thu Aug 7 13:04:15 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 4691131 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 993B39F37E for ; Thu, 7 Aug 2014 13:04:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 796D0200F3 for ; Thu, 7 Aug 2014 13:04:38 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 5D164201DC for ; Thu, 7 Aug 2014 13:04:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7A4FC6E77C; Thu, 7 Aug 2014 06:04:34 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [87.106.93.118]) by gabe.freedesktop.org (Postfix) with ESMTP id BCB576E77B; Thu, 7 Aug 2014 06:04:32 -0700 (PDT) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from nuc-i3427.intel.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 28780594-1500048 for multiple; Thu, 07 Aug 2014 14:05:24 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH] drm: Restore drm_file->is_master Date: Thu, 7 Aug 2014 14:04:15 +0100 Message-Id: <1407416655-15981-1-git-send-email-chris@chris-wilson.co.uk> X-Mailer: git-send-email 1.9.1 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Cc: Alex Deucher , Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 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-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Despite the claims of commit 48ba813701eb14b3008edefef4a0789b328e278c Author: David Herrmann Date: Tue Jul 22 18:46:09 2014 +0200 drm: drop redundant drm_file->is_master drm_file->is_master is not synomous with having drm_file->master == drm_file->minor->master. This is because drm_file->master is the same for all drm_files of the same generation and so when there is a master, every drm_file believes itself to be the master. Confusion ensues and things go pear shaped when one file is closed and there is no master anymore. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82283 Signed-off-by: Chris Wilson Cc: Alex Deucher Cc: Daniel Vetter Cc: David Herrmann --- drivers/gpu/drm/drm_drv.c | 5 ++--- drivers/gpu/drm/drm_fops.c | 12 ++++++------ include/drm/drmP.h | 3 ++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index a1863d8..76cdb51 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -198,6 +198,7 @@ int drm_setmaster_ioctl(struct drm_device *dev, void *data, if (unlikely(ret != 0)) drm_master_put(&file_priv->minor->master); } + file_priv->is_master = ret == 0; out_unlock: mutex_unlock(&dev->master_mutex); @@ -213,13 +214,11 @@ int drm_dropmaster_ioctl(struct drm_device *dev, void *data, if (!drm_is_master(file_priv)) goto out_unlock; - if (!file_priv->minor->master) - goto out_unlock; - ret = 0; if (dev->driver->master_drop) dev->driver->master_drop(dev, file_priv, false); drm_master_put(&file_priv->minor->master); + file_priv->is_master = false; out_unlock: mutex_unlock(&dev->master_mutex); diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index c0166ba..083f7b9 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c @@ -196,6 +196,7 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor) /* take another reference for the copy in the local file priv */ priv->master = drm_master_get(priv->minor->master); + priv->is_master = true; priv->authenticated = 1; if (dev->driver->master_create) { @@ -434,12 +435,11 @@ int drm_release(struct inode *inode, struct file *filp) } 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); - } + /* 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); + file_priv->is_master = false; } /* drop the master reference held by the file priv */ diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 0ffce5c..70a6598 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -378,6 +378,7 @@ struct drm_prime_file_private { /** File private data */ struct drm_file { + bool is_master:1; unsigned authenticated :1; /* true when the client has asked us to expose stereo 3D mode flags */ unsigned stereo_allowed :1; @@ -1177,7 +1178,7 @@ static inline bool drm_is_primary_client(const struct drm_file *file_priv) */ static inline bool drm_is_master(const struct drm_file *file) { - return file->master && file->master == file->minor->master; + return file->is_master; } /******************************************************************/