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)
committerPhil Elwell <8911409+pelwell@users.noreply.github.com>
Fri, 5 Nov 2021 15:51:13 +0000 (15:51 +0000)
commit1454c2730e9ce2850e6e95a4d0f532f12e547a0a
treed2c662137fff6971a569ff84e102f46f2e5566df
parent5d37f8808da4ec1eba54836c71d1c4958b3638b0
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