From cd0d23939b8775482c30ca7ab207f185aecd6555 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Thu, 28 May 2026 10:10:48 +0300 Subject: drm/bridge: split hpd_mutex into two mutexes Currently almost all bridge drivers which implement hpd_enable / hpd_disable callbacks simply toggle the hardware registers generating the interrupt. However, as pointed out by Jonas Karlman and Sashiko bot, using those callbacks for enable_irq() / disable_irq() calls or scheduling and cancelling the work can cause a AB-BA deadlock (between hpd_mutex lock and the corresponding lock). Split the hpd_mutex into two locks: one simply making sure that hpd_cb / hpd_data are consistent and another one, hpd_state_mutex, making sure that concurrent drm_bridge_hpd_enable() / drm_bridge_hpd_disable() calls can't end up with inconsistency between hpd_cb/_data and bridge's internal state. Link: https://lore.kernel.org/dri-devel/9aa4bd35-bff6-4009-a959-ce31010c7b35@kwiboo.se Link: https://sashiko.dev/#/patchset/20260513-dp-connector-hpd-v2-0-42f757bfcbf9%40oss.qualcomm.com Reviewed-by: Sebastian Reichel Link: https://patch.msgid.link/20260528-dp-connector-hpd-v3-1-d656eb1079b7@oss.qualcomm.com Signed-off-by: Dmitry Baryshkov --- include/drm/drm_bridge.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 4ba3a5deef9a..00a95f927e34 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -1256,6 +1256,10 @@ struct drm_bridge { * @hpd_mutex: Protects the @hpd_cb and @hpd_data fields. */ struct mutex hpd_mutex; + /** + * @hpd_state_mutex: Protects the HPD en/disablement state for the bridge. + */ + struct mutex hpd_state_mutex; /** * @hpd_cb: Hot plug detection callback, registered with * drm_bridge_hpd_enable(). -- cgit v1.2.3