From patchwork Sat May 30 12:46:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 11580253 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 300E2913 for ; Sat, 30 May 2020 12:49:57 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0B6D820723 for ; Sat, 30 May 2020 12:49:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G/FM61mc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B6D820723 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5DD766E02D; Sat, 30 May 2020 12:49:53 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9190E6E02D for ; Sat, 30 May 2020 12:49:52 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id u13so6424810wml.1 for ; Sat, 30 May 2020 05:49:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hmxVmoI76gZ6HFsVjw9FdZncjRj0/3D0XfcO5gLq/DA=; b=G/FM61mcLUa425OC9NWcqJo01rDkyCzrPNbl6ZwUgbWRREyVQj63Q+Tq1PiCj6Lu7x BKoihsFub8ONKGrlZPbFByqPw1Psu2NsDlOKUCKfmzA5Gy3u/tg5TI221xlxpUCiFU7n IamL8dfpDHRck19utdNbbBqK+pJ9XEH+l+YP8weC4mTZerpCCuLW0/cKuzVW8f54q9c2 USgGL2ht5v4nLRtubvaM5MJgv6JQEyEkmPs7Swt5/SMJF80GTEHMrvAHDicHjynP3dOz GSqgT4SjSncCqrgCAaIktcwEZZp6HeRovsDYNVeuy2bAabxyTjww14O/2mL6rh3h8igB GCEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hmxVmoI76gZ6HFsVjw9FdZncjRj0/3D0XfcO5gLq/DA=; b=uBlHj2LnAuqAVTZK5ehfPUtWZyqkrt4QMeDcYzNYInNyEnXcehhzPWvlcGV8C2dJaO u1lXPwJKhKYhWBkW3jItt5Phq+avwfSCa9yc4aTar41xY203WffknYrfhXQiAvnjeJhg /KqMO/xXLH8cuCjOLv5iXtTnnJX2hYQmsj7LxN753gWidw5/vJdv1XOyZhRuae9hjyIj 0pGvsphT9SH6Gu16F1irTjIhEHR5s2DSCHGjE1a+D8UvkalkRnJtleNJn9pNPn89pw0d KeDT9wF8UFiopr9DwnXKFpEH3tyafpRnx1G6WBkJ9Abv+6KV4elZGRWYWOFnzwYQWMxK 8iDw== X-Gm-Message-State: AOAM532eIhHiNQ65pZDynNnZRt37sGxnoutH8zSDBzuBVDJXl9Xoq46G Zythx+nEGQiq03EGb1MI+fF2EJPF X-Google-Smtp-Source: ABdhPJzjP6srZZrUaLYcHv69ySBdYuyymiDsF6iIcaU+PkNrRJZ4jZL8wPGwTWAnueG1WqBg/bMiPQ== X-Received: by 2002:a1c:305:: with SMTP id 5mr12883454wmd.60.1590842990860; Sat, 30 May 2020 05:49:50 -0700 (PDT) Received: from localhost.localdomain (cpc91192-cmbg18-2-0-cust374.5-4.cable.virginm.net. [80.6.113.119]) by smtp.gmail.com with ESMTPSA id q128sm3355051wma.38.2020.05.30.05.49.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 May 2020 05:49:49 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 1/2] drm: vmwgfx: remove drm_driver::master_set() return typ Date: Sat, 30 May 2020 13:46:39 +0100 Message-Id: <20200530124640.4176323-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , emil.l.velikov@gmail.com, Roland Scheidegger , VMware Graphics , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The function always returns zero (success). Ideally we'll remove it all together - although that's requires a little more work. For now, we can drop the return type and simplify the drm core code surrounding it. v2: remove redundant assignment (Sam) Cc: David Airlie Cc: Daniel Vetter Cc: VMware Graphics Cc: Roland Scheidegger Signed-off-by: Emil Velikov Cc: Sam Ravnborg Reviewed-by: Sam Ravnborg Reviewed-by: Roland Scheidegger --- VMWare team, I'm planning to push this via drm-misc. Review, ack and comments are appreciated. --- drivers/gpu/drm/drm_auth.c | 32 +++++++---------------------- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 8 +++----- include/drm/drm_drv.h | 4 ++-- 3 files changed, 12 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c index 74ce0c29c960..4c723e3a689c 100644 --- a/drivers/gpu/drm/drm_auth.c +++ b/drivers/gpu/drm/drm_auth.c @@ -122,27 +122,19 @@ struct drm_master *drm_master_create(struct drm_device *dev) return master; } -static int drm_set_master(struct drm_device *dev, struct drm_file *fpriv, - bool new_master) +static void drm_set_master(struct drm_device *dev, struct drm_file *fpriv, + bool new_master) { - int ret = 0; - dev->master = drm_master_get(fpriv->master); - if (dev->driver->master_set) { - ret = dev->driver->master_set(dev, fpriv, new_master); - if (unlikely(ret != 0)) { - drm_master_put(&dev->master); - } - } + if (dev->driver->master_set) + dev->driver->master_set(dev, fpriv, new_master); - fpriv->was_master = (ret == 0); - return ret; + fpriv->was_master = true; } static int drm_new_set_master(struct drm_device *dev, struct drm_file *fpriv) { struct drm_master *old_master; - int ret; lockdep_assert_held_once(&dev->master_mutex); @@ -157,22 +149,12 @@ static int drm_new_set_master(struct drm_device *dev, struct drm_file *fpriv) fpriv->is_master = 1; fpriv->authenticated = 1; - ret = drm_set_master(dev, fpriv, true); - if (ret) - goto out_err; + drm_set_master(dev, fpriv, true); if (old_master) drm_master_put(&old_master); return 0; - -out_err: - /* drop references and restore old master on failure */ - drm_master_put(&fpriv->master); - fpriv->master = old_master; - fpriv->is_master = 0; - - return ret; } /* @@ -265,7 +247,7 @@ int drm_setmaster_ioctl(struct drm_device *dev, void *data, goto out_unlock; } - ret = drm_set_master(dev, file_priv, false); + drm_set_master(dev, file_priv, false); out_unlock: mutex_unlock(&dev->master_mutex); return ret; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index c2247a893ed4..470428387878 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -1129,9 +1129,9 @@ static long vmw_compat_ioctl(struct file *filp, unsigned int cmd, } #endif -static int vmw_master_set(struct drm_device *dev, - struct drm_file *file_priv, - bool from_open) +static void vmw_master_set(struct drm_device *dev, + struct drm_file *file_priv, + bool from_open) { /* * Inform a new master that the layout may have changed while @@ -1139,8 +1139,6 @@ static int vmw_master_set(struct drm_device *dev, */ if (!from_open) drm_sysfs_hotplug_event(dev); - - return 0; } static void vmw_master_drop(struct drm_device *dev, diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h index bb924cddc09c..835c38a76ef6 100644 --- a/include/drm/drm_drv.h +++ b/include/drm/drm_drv.h @@ -311,8 +311,8 @@ struct drm_driver { * * Called whenever the minor master is set. Only used by vmwgfx. */ - int (*master_set)(struct drm_device *dev, struct drm_file *file_priv, - bool from_open); + void (*master_set)(struct drm_device *dev, struct drm_file *file_priv, + bool from_open); /** * @master_drop: * From patchwork Sat May 30 12:46:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 11580255 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 79F2D913 for ; Sat, 30 May 2020 12:50:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 564CF20723 for ; Sat, 30 May 2020 12:50:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I8EzHOob" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 564CF20723 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D1EBA6E06E; Sat, 30 May 2020 12:49:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8FFD26E065 for ; Sat, 30 May 2020 12:49:53 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id x6so6772242wrm.13 for ; Sat, 30 May 2020 05:49:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bEajEsUU5sqnyngtbsEKYRXXKL/xXjIafgFONtJKFRw=; b=I8EzHOobYmhKKdrBFbspCbDO983WtNT5tpPF677DTMjVjRDmHdoWIISfh8g9q3rFXf lMrzqDMfcLzy1s2SMrJNzXAPQa1AcSzcUrFiRjrMtNw6c65u3U56oeO2uNuzwYgyKX6s /t3jsIiSPlwCBv9uD5s0c8ZtobpzZHaIcKJsFFXoXuoZXuAy43Z2tzFBOGSIqKTZTMn7 aF2cmdJNAJGgLEqrcVKHfHuN9MxDxeEYEH7yC97ciTtc+Kgqu4O2dAfcSOo9V73QHXbs WuzXnk5Mm3YEXyCqfDOScMUZAV5jaGIzIx/1vd3fDV3SIHnOWuDuxMAGgn5wdXc1Jgtl 0g4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bEajEsUU5sqnyngtbsEKYRXXKL/xXjIafgFONtJKFRw=; b=Trsbp0jFcvaXaARklQ2XuKJhEnBNKDZFrwSQ5N4btCC12HtopViwSkSaDBDpb1DA82 zAJhI0UvJ7wjBqrLKGzAu+/fd0W60SwLsM/VwPa0XGiO5l++POtVnjHd+WH7ZFC7v3uV E98RJIRohbvYGDDyBc9jhQVS5mTDqmi9rnyTkVD6/ULXVqAnWq+sb7UDw5+k58nv/N/y gYL11McuXAAx5T6Hbb+vZbaSDir3N968S/f06KdSm1PvKXcl3rX4iOmuH5zx1r6Qeniz cqHVkQqK+tIiYHEnIHxAWJ3Jrciq+AmAHIn5nRYGFuD8SljcdGtVtud48iAO8wqeRLoT WxBw== X-Gm-Message-State: AOAM532P2QJL8tbxcZwV2h6TWnYbGbntYQkiDAEnVAncSKw/HPv+8UJV 2/fLdpasrnQy4JzM9o2Wz2gFZrim X-Google-Smtp-Source: ABdhPJx7GegisxEkqG/RLX1P0cHxgInS2fRhUwsRF7PtVZ8MIFyOT2nCFtCLrALr7o45bZVao8zEmA== X-Received: by 2002:adf:f790:: with SMTP id q16mr13483066wrp.399.1590842991981; Sat, 30 May 2020 05:49:51 -0700 (PDT) Received: from localhost.localdomain (cpc91192-cmbg18-2-0-cust374.5-4.cable.virginm.net. [80.6.113.119]) by smtp.gmail.com with ESMTPSA id q128sm3355051wma.38.2020.05.30.05.49.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 May 2020 05:49:51 -0700 (PDT) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 2/2] drm/auth: make drm_{set,drop]master_ioctl symmetrical Date: Sat, 30 May 2020 13:46:40 +0100 Message-Id: <20200530124640.4176323-2-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200530124640.4176323-1-emil.l.velikov@gmail.com> References: <20200530124640.4176323-1-emil.l.velikov@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , Sam Ravnborg , emil.l.velikov@gmail.com, Colin Ian King Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently the ret handling is all over the place - with two redundant assignments and another one addressed earlier. Use the exact same flow in both functions. v2: straighten the code flow, instead of just removing the assignments Cc: David Airlie Cc: Daniel Vetter Cc: Sam Ravnborg Cc: Colin Ian King Signed-off-by: Emil Velikov Reviewed-by: Sam Ravnborg --- Colin, pretty sure that this should address couple of Coverity warnings. Yet I didn't check their web UI thingy. --- drivers/gpu/drm/drm_auth.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c index 4c723e3a689c..f2d46b7ac6f9 100644 --- a/drivers/gpu/drm/drm_auth.c +++ b/drivers/gpu/drm/drm_auth.c @@ -215,7 +215,7 @@ drm_master_check_perm(struct drm_device *dev, struct drm_file *file_priv) int drm_setmaster_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv) { - int ret = 0; + int ret; mutex_lock(&dev->master_mutex); @@ -272,12 +272,15 @@ int drm_dropmaster_ioctl(struct drm_device *dev, void *data, if (ret) goto out_unlock; - ret = -EINVAL; - if (!drm_is_current_master(file_priv)) + if (!drm_is_current_master(file_priv)) { + ret = -EINVAL; goto out_unlock; + } - if (!dev->master) + if (!dev->master) { + ret = -EINVAL; goto out_unlock; + } if (file_priv->master->lessor != NULL) { DRM_DEBUG_LEASE("Attempt to drop lessee %d as master\n", file_priv->master->lessee_id); @@ -285,7 +288,6 @@ int drm_dropmaster_ioctl(struct drm_device *dev, void *data, goto out_unlock; } - ret = 0; drm_drop_master(dev, file_priv); out_unlock: mutex_unlock(&dev->master_mutex);