Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: Remove locking for legacy ioctls and DRM_UNLOCKED

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>
Reviewed-by: David Airlie <airlied@gmail.com>
Reviewed-by: Daniel Vetter <daniel@ffwll.ch>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231122122449.11588-12-tzimmermann@suse.de

+7 -27
+1 -1
drivers/gpu/drm/drm_ioc32.c
··· 273 273 req.request.type = req32.request.type; 274 274 req.request.sequence = req32.request.sequence; 275 275 req.request.signal = req32.request.signal; 276 - err = drm_ioctl_kernel(file, drm_wait_vblank_ioctl, &req, DRM_UNLOCKED); 276 + err = drm_ioctl_kernel(file, drm_wait_vblank_ioctl, &req, 0); 277 277 278 278 req32.reply.type = req.reply.type; 279 279 req32.reply.sequence = req.reply.sequence;
+6 -15
drivers/gpu/drm/drm_ioctl.c
··· 596 596 597 597 DRM_IOCTL_DEF(DRM_IOCTL_FINISH, drm_noop, DRM_AUTH), 598 598 599 - DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank_ioctl, DRM_UNLOCKED), 599 + DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank_ioctl, 0), 600 600 601 601 DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY), 602 602 ··· 729 729 { 730 730 struct drm_file *file_priv = file->private_data; 731 731 struct drm_device *dev = file_priv->minor->dev; 732 - int retcode; 732 + int ret; 733 733 734 734 /* Update drm_file owner if fd was passed along. */ 735 735 drm_file_update_pid(file_priv); ··· 737 737 if (drm_dev_is_unplugged(dev)) 738 738 return -ENODEV; 739 739 740 - retcode = drm_ioctl_permit(flags, file_priv); 741 - if (unlikely(retcode)) 742 - return retcode; 740 + ret = drm_ioctl_permit(flags, file_priv); 741 + if (unlikely(ret)) 742 + return ret; 743 743 744 - /* Enforce sane locking for modern driver ioctls. */ 745 - if (likely(!drm_core_check_feature(dev, DRIVER_LEGACY)) || 746 - (flags & DRM_UNLOCKED)) 747 - retcode = func(dev, kdata, file_priv); 748 - else { 749 - mutex_lock(&drm_global_mutex); 750 - retcode = func(dev, kdata, file_priv); 751 - mutex_unlock(&drm_global_mutex); 752 - } 753 - return retcode; 744 + return func(dev, kdata, file_priv); 754 745 } 755 746 EXPORT_SYMBOL(drm_ioctl_kernel); 756 747
-11
include/drm/drm_ioctl.h
··· 110 110 */ 111 111 DRM_ROOT_ONLY = BIT(2), 112 112 /** 113 - * @DRM_UNLOCKED: 114 - * 115 - * Whether &drm_ioctl_desc.func should be called with the DRM BKL held 116 - * or not. Enforced as the default for all modern drivers, hence there 117 - * should never be a need to set this flag. 118 - * 119 - * Do not use anywhere else than for the VBLANK_WAIT IOCTL, which is the 120 - * only legacy IOCTL which needs this. 121 - */ 122 - DRM_UNLOCKED = BIT(4), 123 - /** 124 113 * @DRM_RENDER_ALLOW: 125 114 * 126 115 * This is used for all ioctl needed for rendering only, for drivers