]> git.baikalelectronics.ru Git - kernel.git/commit
drm/ioctl: Ditch DRM_UNLOCKED except for the legacy vblank ioctl
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 5 Jun 2019 12:08:35 +0000 (14:08 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 21 Jun 2019 17:13:10 +0000 (19:13 +0200)
commitf3a8b2951342c0ea19df7c25a266cf74f3d46bb6
tree3a0b8df22c8cb89487ec75a69eba57fb7f55e9d1
parent73891183149bd565f3a9b0339c1ab8c11ed9ff61
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 06332beb83acaa9b97e76177005e7972f3ebe953
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 862bef678f3b43e466f8305de88450da09b66d7a
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 d7cc1f3a032bafbb29321f60fc8e7514187f2f21
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 7d445f27506cc735de8fd9efae464fa9e55674de
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: Emil Velikov <emil.velikov@collabora.com>
Acked-by: Michel Dänzer <michel@daenzer.net>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190605120835.2798-1-daniel.vetter@ffwll.ch
drivers/gpu/drm/drm_ioc32.c
drivers/gpu/drm/drm_ioctl.c
include/drm/drm_ioctl.h