drm: Remove the legacy DRM_IOCTL_MODESET_CTL ioctl
authorThomas Zimmermann <tzimmermann@suse.de>
Wed, 22 Nov 2023 12:09:38 +0000 (13:09 +0100)
committerThomas Zimmermann <tzimmermann@suse.de>
Wed, 6 Dec 2023 09:08:24 +0000 (10:08 +0100)
DRM drivers with user-space mode setting have been removed in Linux
v6.3. [1] Now remove the ioctl entry points for these drivers. Invoking
any of the ioctl ops will unconditionally return -EINVAL to user space.

Invoking DRM_IOCTL_MODESET_CTL is different from the other legacy
ioctl ops as it returns 0 even without CONFIG_DRM_LEGACY set. From the
original commit 29935554b384 ("drm: Disallow DRM_IOCTL_MODESET_CTL for
KMS drivers") it is not apparent how or why the operation differs from
the others. It is likely just an oversight in commit 61ae227032e7
("drm: allow removal of legacy codepaths (v4.1)"), which allowed
disabling leagacy ioctls in the first place. Still keep this removal
separate from the other ioctls to allow an easy revert, if necessary.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/series/111602/
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-10-tzimmermann@suse.de
drivers/gpu/drm/drm_internal.h
drivers/gpu/drm/drm_ioctl.c
drivers/gpu/drm/drm_vblank.c

index b7a311efa2b1829676101140872c23c5ee90a60b..fa08a313127e22f6b4faf37cce2546fa97838677 100644 (file)
@@ -117,8 +117,6 @@ void drm_handle_vblank_works(struct drm_vblank_crtc *vblank);
 /* IOCTLS */
 int drm_wait_vblank_ioctl(struct drm_device *dev, void *data,
                          struct drm_file *filp);
-int drm_legacy_modeset_ctl_ioctl(struct drm_device *dev, void *data,
-                                struct drm_file *file_priv);
 
 /* drm_irq.c */
 
index 93f6bf15c0ae4ad944190b0bb4b3573299da8874..ebba34ba734eac5a9fb988837fa7fb79bfe0411c 100644 (file)
@@ -598,8 +598,6 @@ static const struct drm_ioctl_desc drm_ioctls[] = {
 
        DRM_IOCTL_DEF(DRM_IOCTL_WAIT_VBLANK, drm_wait_vblank_ioctl, DRM_UNLOCKED),
 
-       DRM_IOCTL_DEF(DRM_IOCTL_MODESET_CTL, drm_legacy_modeset_ctl_ioctl, 0),
-
        DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_noop, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 
        DRM_IOCTL_DEF(DRM_IOCTL_GEM_CLOSE, drm_gem_close_ioctl, DRM_RENDER_ALLOW),
index 877e2067534fa215ba16fe16363b04e84e0ad7e1..a11f164b2384f9a5ff2ef3812e2602e5c816c840 100644 (file)
@@ -1574,88 +1574,6 @@ void drm_crtc_vblank_restore(struct drm_crtc *crtc)
 }
 EXPORT_SYMBOL(drm_crtc_vblank_restore);
 
-static void drm_legacy_vblank_pre_modeset(struct drm_device *dev,
-                                         unsigned int pipe)
-{
-       struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
-
-       /* vblank is not initialized (IRQ not installed ?), or has been freed */
-       if (!drm_dev_has_vblank(dev))
-               return;
-
-       if (drm_WARN_ON(dev, pipe >= dev->num_crtcs))
-               return;
-
-       /*
-        * To avoid all the problems that might happen if interrupts
-        * were enabled/disabled around or between these calls, we just
-        * have the kernel take a reference on the CRTC (just once though
-        * to avoid corrupting the count if multiple, mismatch calls occur),
-        * so that interrupts remain enabled in the interim.
-        */
-       if (!vblank->inmodeset) {
-               vblank->inmodeset = 0x1;
-               if (drm_vblank_get(dev, pipe) == 0)
-                       vblank->inmodeset |= 0x2;
-       }
-}
-
-static void drm_legacy_vblank_post_modeset(struct drm_device *dev,
-                                          unsigned int pipe)
-{
-       struct drm_vblank_crtc *vblank = &dev->vblank[pipe];
-
-       /* vblank is not initialized (IRQ not installed ?), or has been freed */
-       if (!drm_dev_has_vblank(dev))
-               return;
-
-       if (drm_WARN_ON(dev, pipe >= dev->num_crtcs))
-               return;
-
-       if (vblank->inmodeset) {
-               spin_lock_irq(&dev->vbl_lock);
-               drm_reset_vblank_timestamp(dev, pipe);
-               spin_unlock_irq(&dev->vbl_lock);
-
-               if (vblank->inmodeset & 0x2)
-                       drm_vblank_put(dev, pipe);
-
-               vblank->inmodeset = 0;
-       }
-}
-
-int drm_legacy_modeset_ctl_ioctl(struct drm_device *dev, void *data,
-                                struct drm_file *file_priv)
-{
-       struct drm_modeset_ctl *modeset = data;
-       unsigned int pipe;
-
-       /* If drm_vblank_init() hasn't been called yet, just no-op */
-       if (!drm_dev_has_vblank(dev))
-               return 0;
-
-       /* KMS drivers handle this internally */
-       if (!drm_core_check_feature(dev, DRIVER_LEGACY))
-               return 0;
-
-       pipe = modeset->crtc;
-       if (pipe >= dev->num_crtcs)
-               return -EINVAL;
-
-       switch (modeset->cmd) {
-       case _DRM_PRE_MODESET:
-               drm_legacy_vblank_pre_modeset(dev, pipe);
-               break;
-       case _DRM_POST_MODESET:
-               drm_legacy_vblank_post_modeset(dev, pipe);
-               break;
-       default:
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
 static int drm_queue_vblank_event(struct drm_device *dev, unsigned int pipe,
                                  u64 req_seq,
                                  union drm_wait_vblank *vblwait,