drm/vc4: hdmi: Prevent access to crtc->state outside of KMS
authorMaxime Ripard <maxime@cerno.tech>
Tue, 19 Oct 2021 12:19:29 +0000 (14:19 +0200)
committerDom Cobley <popcornmix@gmail.com>
Mon, 21 Mar 2022 16:03:44 +0000 (16:03 +0000)
commit9ee2bfb98cf094ced950d7f9b31c40f4d403c0b7
tree0f9a53668a6094dde11f9b0ea1d2b213a656cf6f
parent6ffe99e3c68bd913e94f5e3f7f1c8b1a79320fd0
drm/vc4: hdmi: Prevent access to crtc->state outside of KMS

Accessing the crtc->state pointer from outside the modesetting context
is not allowed. We thus need to copy whatever we need from the KMS state
to our structure in order to access it.

However, in the vc4 HDMI driver we do use that pointer in the ALSA code
path, and potentially in the hotplug interrupt handler path.

These paths both need access to the CRTC adjusted mode in order for the
proper dividers to be set for ALSA, and the scrambler state to be
reinstated properly for hotplug.

Let's copy this mode into our private encoder structure and reference it
from there when needed. Since that part is shared between KMS and other
paths, we need to protect it using our mutex.

Link: https://lore.kernel.org/all/YWgteNaNeaS9uWDe@phenom.ffwll.local/
Fixes: bb7d78568814 ("drm/vc4: Add HDMI audio support")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
drivers/gpu/drm/vc4/vc4_hdmi.c
drivers/gpu/drm/vc4/vc4_hdmi.h