summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/vc4/vc4_hdmi.h
diff options
context:
space:
mode:
authorMaxime Ripard <maxime@cerno.tech>2021-10-25 17:11:09 +0300
committerMaxime Ripard <maxime@cerno.tech>2021-11-05 14:53:25 +0300
commit82cb88af12d29eaa5350d9ba83f9c376f65b7fec (patch)
tree371373f45c7714c5d8a2a5c9fd817538d017a7b9 /drivers/gpu/drm/vc4/vc4_hdmi.h
parent81fb55e500a82a070da20f02b2e252d6a09a34c3 (diff)
downloadlinux-82cb88af12d29eaa5350d9ba83f9c376f65b7fec.tar.xz
drm/vc4: hdmi: Use a mutex to prevent concurrent framework access
The vc4 HDMI controller registers into the KMS, CEC and ALSA frameworks. However, no particular care is done to prevent the concurrent execution of different framework hooks from happening at the same time. In order to protect against that scenario, let's introduce a mutex that relevant ALSA and KMS hooks will need to take to prevent concurrent execution. CEC is left out at the moment though, since the .get_modes and .detect KMS hooks, when running cec_s_phys_addr_from_edid, can end up calling CEC's .adap_enable hook. This introduces some reentrancy that isn't easy to deal with properly. The CEC hooks also don't share much state with the rest of the driver: the registers are entirely separate, we don't share any variable, the only thing that can conflict is the CEC clock divider setup that can be affected by a mode set. However, after discussing it, it looks like CEC should be able to recover from this if it was to happen. Link: https://lore.kernel.org/r/20211025141113.702757-6-maxime@cerno.tech Fixes: bb7d78568814 ("drm/vc4: Add HDMI audio support") Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Diffstat (limited to 'drivers/gpu/drm/vc4/vc4_hdmi.h')
-rw-r--r--drivers/gpu/drm/vc4/vc4_hdmi.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h
index 006142fe8d4e..cf9bb21a8ef7 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.h
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.h
@@ -183,6 +183,20 @@ struct vc4_hdmi {
* @hw_lock: Spinlock protecting device register access.
*/
spinlock_t hw_lock;
+
+ /**
+ * @mutex: Mutex protecting the driver access across multiple
+ * frameworks (KMS, ALSA).
+ *
+ * NOTE: While supported, CEC has been left out since
+ * cec_s_phys_addr_from_edid() might call .adap_enable and lead to a
+ * reentrancy issue between .get_modes (or .detect) and .adap_enable.
+ * Since we don't share any state between the CEC hooks and KMS', it's
+ * not a big deal. The only trouble might come from updating the CEC
+ * clock divider which might be affected by a modeset, but CEC should
+ * be resilient to that.
+ */
+ struct mutex mutex;
};
static inline struct vc4_hdmi *