drm/vc4: debugfs: Protect device resources
authorMaxime Ripard <maxime@cerno.tech>
Mon, 11 Jul 2022 17:39:32 +0000 (19:39 +0200)
committerMaxime Ripard <maxime@cerno.tech>
Wed, 13 Jul 2022 08:46:12 +0000 (10:46 +0200)
commitbe919b89b28e0fa3c4eff39dd96350bc7803f194
tree9ab0c286b9ff9c4fdfa25355b43505db89fd79e0
parent4e06fd9c7c8a2815c63ff132fd392d76e42436e9
drm/vc4: debugfs: Protect device resources

Our current code now mixes some resources whose lifetime are tied to the
device (clocks, IO mappings, etc.) and some that are tied to the DRM device
(encoder, bridge).

The device one will be freed at unbind time, but the DRM one will only be
freed when the last user of the DRM device closes its file handle.

So we end up with a time window during which we can call the encoder hooks,
but we don't have access to the underlying resources and device.

Let's protect all those sections with drm_dev_enter() and drm_dev_exit() so
that we bail out if we are during that window.

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