Commit 75426367 authored by Daniel Vetter's avatar Daniel Vetter

drm/ioctl: Ditch DRM_UNLOCKED except for the legacy vblank ioctl

This completes Emil's series of removing DRM_UNLOCKED from modern
drivers. It's entirely cargo-culted since we ignore it on
non-DRIVER_LEGACY drivers since:

commit ea487835
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date:   Mon Sep 28 21:42:40 2015 +0200

    drm: Enforce unlocked ioctl operation for kms driver ioctls

Now justifying why we can do this for legacy drives too (and hence
close the source of all the bogus copypasting) is a bit more involved.
DRM_UNLOCKED was introduced in:

commit ed8b6704
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Wed Dec 16 22:17:09 2009 +0000

    drm: convert drm_ioctl to unlocked_ioctl

As a immediate hack to keep i810 happy, which would have deadlocked
without this trickery. The old BKL is automatically dropped in
schedule(), and hence the i810 vs. mmap_sem deadlock didn't actually
cause a real deadlock. But with a mutex it would. The solution was to
annotate these as DRM_UNLOCKED and mark i810 unsafe on SMP machines.

This conversion caused a regression, because unlike the BKL a mutex
isn't dropped over schedule (that thing again), which caused a vblank
wait in one thread to block the entire desktop and all its apps. Back
then we did vblank scheduling by blocking in the client, awesome isn't
it. This was fixed quickly in (ok not so quickly, took 2 years):

commit 8f4ff2b0
Author: Ilija Hadzic <ihadzic@research.bell-labs.com>
Date:   Mon Oct 31 17:46:18 2011 -0400

    drm: do not sleep on vblank while holding a mutex

All the other DRM_UNLOCKED annotations for all the core ioctls was
work to reach finer-grained locking for modern drivers. This took
years, and culminated in:

commit fdd5b877
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date:   Sat Dec 10 22:52:54 2016 +0100

    drm: Enforce BKL-less ioctls for modern drivers

DRM_UNLOCKED was never required by any legacy drivers, except for the
vblank_wait IOCTL. Therefore we will not regress these old drivers by
going back to where we've been in 2011. For all modern drivers nothing
will change.

To make this perfectly clear, also add a comment to DRM_UNLOCKED.

v2: Don't forget about drm_ioc32.c (Michel).

Cc: Michel Dänzer <michel@daenzer.net>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: default avatarEmil Velikov <emil.velikov@collabora.com>
Acked-by: default avatarMichel Dänzer <michel@daenzer.net>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190605120835.2798-1-daniel.vetter@ffwll.ch
parent e4fa8457
......@@ -108,7 +108,7 @@ static int compat_drm_version(struct file *file, unsigned int cmd,
.desc = compat_ptr(v32.desc),
};
err = drm_ioctl_kernel(file, drm_version, &v,
DRM_UNLOCKED|DRM_RENDER_ALLOW);
DRM_RENDER_ALLOW);
if (err)
return err;
......@@ -142,7 +142,7 @@ static int compat_drm_getunique(struct file *file, unsigned int cmd,
.unique = compat_ptr(uq32.unique),
};
err = drm_ioctl_kernel(file, drm_getunique, &uq, DRM_UNLOCKED);
err = drm_ioctl_kernel(file, drm_getunique, &uq, 0);
if (err)
return err;
......@@ -181,7 +181,7 @@ static int compat_drm_getmap(struct file *file, unsigned int cmd,
return -EFAULT;
map.offset = m32.offset;
err = drm_ioctl_kernel(file, drm_legacy_getmap_ioctl, &map, DRM_UNLOCKED);
err = drm_ioctl_kernel(file, drm_legacy_getmap_ioctl, &map, 0);
if (err)
return err;
......@@ -267,7 +267,7 @@ static int compat_drm_getclient(struct file *file, unsigned int cmd,
client.idx = c32.idx;
err = drm_ioctl_kernel(file, drm_getclient, &client, DRM_UNLOCKED);
err = drm_ioctl_kernel(file, drm_getclient, &client, 0);
if (err)
return err;
......@@ -297,7 +297,7 @@ static int compat_drm_getstats(struct file *file, unsigned int cmd,
drm_stats32_t __user *argp = (void __user *)arg;
int err;
err = drm_ioctl_kernel(file, drm_noop, NULL, DRM_UNLOCKED);
err = drm_ioctl_kernel(file, drm_noop, NULL, 0);
if (err)
return err;
......@@ -892,8 +892,7 @@ static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd,
sizeof(req64.modifier)))
return -EFAULT;
err = drm_ioctl_kernel(file, drm_mode_addfb2, &req64,
DRM_UNLOCKED);
err = drm_ioctl_kernel(file, drm_mode_addfb2, &req64, 0);
if (err)
return err;
......
This diff is collapsed.
......@@ -114,6 +114,9 @@ enum drm_ioctl_flags {
* 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),
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment