From: Thomas Zimmermann <tzimmermann@suse.de>
To: airlied@gmail.com, daniel@ffwll.ch,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
cai.huoqing@linux.dev
Cc: Thomas Zimmermann <tzimmermann@suse.de>, dri-devel@lists.freedesktop.org
Subject: [PATCH 11/14] drm: Remove locking for legacy ioctls and DRM_UNLOCKED
Date: Wed, 22 Nov 2023 13:09:40 +0100 [thread overview]
Message-ID: <20231122122449.11588-12-tzimmermann@suse.de> (raw)
In-Reply-To: <20231122122449.11588-1-tzimmermann@suse.de>
Modern DRM drivers acquire ioctl locks by themselves. Legacy ioctls
for user-space mode setting used to acquire drm_global_mutex. After
removing the ioctl entry points, also remove the locking code. The only
legacy ioctl without global locking was VBLANK_WAIT, which has been
removed as well. Hence remove the related DRM_UNLOCKED flag.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
---
drivers/gpu/drm/drm_ioc32.c | 2 +-
drivers/gpu/drm/drm_ioctl.c | 23 +++++++----------------
include/drm/drm_ioctl.h | 11 -----------
3 files changed, 8 insertions(+), 28 deletions(-)
diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
index 910cadf14756e..129e2b91dbfe7 100644
--- a/drivers/gpu/drm/drm_ioc32.c
+++ b/drivers/gpu/drm/drm_ioc32.c
@@ -273,7 +273,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
req.request.type = req32.request.type;
req.request.sequence = req32.request.sequence;
req.request.signal = req32.request.signal;
- err = drm_ioctl_kernel(file, drm_wait_vblank_ioctl, &req, DRM_UNLOCKED);
+ err = drm_ioctl_kernel(file, drm_wait_vblank_ioctl, &req, 0);
req32.reply.type = req.reply.type;
req32.reply.sequence = req.reply.sequence;
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 9c6326b908e74..1cf1de342d6aa 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -583,7 +583,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH),
- DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank_ioctl, DRM_UNLOCKED),
+ DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank_ioctl, 0),
DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
@@ -716,7 +716,7 @@ long drm_ioctl_kernel(struct file *file, drm_ioctl_t *func, void *kdata,
{
struct drm_file *file_priv = file->private_data;
struct drm_device *dev = file_priv->minor->dev;
- int retcode;
+ int ret;
/* Update drm_file owner if fd was passed along. */
drm_file_update_pid(file_priv);
@@ -724,20 +724,11 @@ long drm_ioctl_kernel(struct file *file, drm_ioctl_t *func, void *kdata,
if (drm_dev_is_unplugged(dev))
return -ENODEV;
- retcode = drm_ioctl_permit(flags, file_priv);
- if (unlikely(retcode))
- return retcode;
-
- /* Enforce sane locking for modern driver ioctls. */
- if (likely(!drm_core_check_feature(dev, DRIVER_LEGACY)) ||
- (flags & DRM_UNLOCKED))
- retcode = func(dev, kdata, file_priv);
- else {
- mutex_lock(&drm_global_mutex);
- retcode = func(dev, kdata, file_priv);
- mutex_unlock(&drm_global_mutex);
- }
- return retcode;
+ ret = drm_ioctl_permit(flags, file_priv);
+ if (unlikely(ret))
+ return ret;
+
+ return func(dev, kdata, file_priv);
}
EXPORT_SYMBOL(drm_ioctl_kernel);
diff --git a/include/drm/drm_ioctl.h b/include/drm/drm_ioctl.h
index 6ed61c371f6ce..171760b6c4a14 100644
--- a/include/drm/drm_ioctl.h
+++ b/include/drm/drm_ioctl.h
@@ -109,17 +109,6 @@ enum drm_ioctl_flags {
* This is equivalent to callers with the SYSADMIN capability.
*/
DRM_ROOT_ONLY = BIT(2),
- /**
- * @DRM_UNLOCKED:
- *
- * Whether &drm_ioctl_desc.func should be called with the DRM BKL held
- * or not. Enforced as the default for all modern drivers, hence there
- * should never be a need to set this flag.
- *
- * Do not use anywhere else than for the VBLANK_WAIT IOCTL, which is the
- * only legacy IOCTL which needs this.
- */
- DRM_UNLOCKED = BIT(4),
/**
* @DRM_RENDER_ALLOW:
*
--
2.42.1
next prev parent reply other threads:[~2023-11-22 12:25 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 12:09 [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
2023-11-22 12:09 ` [PATCH 01/14] arch/powerpc: Remove legacy DRM drivers from default configs Thomas Zimmermann
2023-11-27 21:03 ` Alex Deucher
2023-11-28 7:19 ` Cai Huoqing
2023-11-22 12:09 ` [PATCH 02/14] drm: Fix TODO list mentioning non-KMS drivers Thomas Zimmermann
2023-11-27 21:02 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 03/14] drm: Include <drm/drm_auth.h> Thomas Zimmermann
2023-11-27 21:03 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 04/14] drm/i915: " Thomas Zimmermann
2023-11-22 18:14 ` Jani Nikula
2023-11-22 12:09 ` [PATCH 05/14] accel: " Thomas Zimmermann
2023-11-27 21:03 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 06/14] drm: Include <drm/drm_device.h> Thomas Zimmermann
2023-11-22 12:09 ` [PATCH 07/14] drm/radeon: Do not include <drm/drm_legacy.h> Thomas Zimmermann
2023-11-27 21:00 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 08/14] drm: Remove entry points for legacy ioctls Thomas Zimmermann
2023-11-27 21:04 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 09/14] drm: Remove the legacy DRM_IOCTL_MODESET_CTL ioctl Thomas Zimmermann
2023-11-27 21:05 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 10/14] drm: Remove support for legacy drivers Thomas Zimmermann
2023-11-27 21:05 ` Alex Deucher
2023-11-22 12:09 ` Thomas Zimmermann [this message]
2023-11-27 21:05 ` [PATCH 11/14] drm: Remove locking for legacy ioctls and DRM_UNLOCKED Alex Deucher
2023-11-22 12:09 ` [PATCH 12/14] drm: Remove source code for non-KMS drivers Thomas Zimmermann
2023-11-27 21:06 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 13/14] char/agp: Remove frontend code Thomas Zimmermann
2023-11-27 21:07 ` Alex Deucher
2023-11-22 12:09 ` [PATCH 14/14] drm: Remove Kconfig option for legacy support (CONFIG_DRM_LEGACY) Thomas Zimmermann
2023-11-27 21:07 ` Alex Deucher
2023-12-01 8:39 ` [PATCH 00/14] drm: Remove infrastructure for user-space mode setting Thomas Zimmermann
2023-12-06 9:20 ` Thomas Zimmermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231122122449.11588-12-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=cai.huoqing@linux.dev \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox