drm/vc4: vec: Protect device resources after removal
authorMaxime Ripard <maxime@cerno.tech>
Mon, 11 Jul 2022 17:39:30 +0000 (19:39 +0200)
committerMaxime Ripard <maxime@cerno.tech>
Wed, 13 Jul 2022 08:46:12 +0000 (10:46 +0200)
commitf0601ef8631ceeab10c7af69b248fc106e0ecf09
tree1d78a07227dc8b7669aaa3e6fa62c6fe3ef318d2
parent881f6d945b34e5604003ba1cc85c9dfbb7e31af2
drm/vc4: vec: Protect device resources after removal

Whenever the device and driver are unbound, the main device and all the
subdevices will be removed by calling their unbind() method.

However, the DRM device itself will only be freed when the last user will
have closed it.

It means that there is a time window where the device and its resources
aren't there anymore, but the userspace can still call into our driver.

Fortunately, the DRM framework provides the drm_dev_enter() and
drm_dev_exit() functions to make sure our underlying device is still there
for the section protected by those calls. Let's add them to the VEC driver.

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20220711173939.1132294-61-maxime@cerno.tech
drivers/gpu/drm/vc4/vc4_vec.c