mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Cc: Andrzej Hajda <andrzej.hajda@intel.com>,
	 Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>,
	 Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	 Jernej Skrabec <jernej.skrabec@gmail.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	 Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	 David Airlie <airlied@gmail.com>,
	Simona Vetter <simona@ffwll.ch>,
	 Tomi Valkeinen <tomi.valkeinen@ti.com>,
	Boris Brezillon <boris.brezillon@collabora.com>,
	 Sam Ravnborg <sam@ravnborg.org>,
	Yongxing Mou <yongxing.mou@oss.qualcomm.com>,
	 dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/3] drm/bridge: split hpd_mutex into two mutexes
Date: Mon, 1 Jun 2026 18:01:12 +0200	[thread overview]
Message-ID: <ah2smWb3vurXHg1X@venus> (raw)
In-Reply-To: <20260528-dp-connector-hpd-v3-1-d656eb1079b7@oss.qualcomm.com>

[-- Attachment #1: Type: text/plain, Size: 3946 bytes --]

Hi,

On Thu, May 28, 2026 at 10:10:48AM +0300, Dmitry Baryshkov wrote:
> 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
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  drivers/gpu/drm/drm_bridge.c | 16 +++++++++++++---
>  include/drm/drm_bridge.h     |  4 ++++
>  2 files changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index 687b36eea0c7..9a185032a3bd 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -417,6 +417,7 @@ void drm_bridge_add(struct drm_bridge *bridge)
>  	if (!list_empty(&bridge->list))
>  		list_del_init(&bridge->list);
>  
> +	mutex_init(&bridge->hpd_state_mutex);
>  	mutex_init(&bridge->hpd_mutex);
>  
>  	if (bridge->ops & DRM_BRIDGE_OP_HDMI)
> @@ -469,6 +470,7 @@ void drm_bridge_remove(struct drm_bridge *bridge)
>  	mutex_unlock(&bridge_lock);
>  
>  	mutex_destroy(&bridge->hpd_mutex);
> +	mutex_destroy(&bridge->hpd_state_mutex);
>  
>  	drm_bridge_put(bridge);
>  }
> @@ -1451,19 +1453,25 @@ void drm_bridge_hpd_enable(struct drm_bridge *bridge,
>  	if (!(bridge->ops & DRM_BRIDGE_OP_HPD))
>  		return;
>  
> +	mutex_lock(&bridge->hpd_state_mutex);
> +
>  	mutex_lock(&bridge->hpd_mutex);
>  
> -	if (WARN(bridge->hpd_cb, "Hot plug detection already enabled\n"))
> +	if (WARN(bridge->hpd_cb, "Hot plug detection already enabled\n")) {
> +		mutex_unlock(&bridge->hpd_mutex);
>  		goto unlock;
> +	}
>  
>  	bridge->hpd_cb = cb;
>  	bridge->hpd_data = data;
>  
> +	mutex_unlock(&bridge->hpd_mutex);
> +
>  	if (bridge->funcs->hpd_enable)
>  		bridge->funcs->hpd_enable(bridge);
>  
>  unlock:
> -	mutex_unlock(&bridge->hpd_mutex);
> +	mutex_unlock(&bridge->hpd_state_mutex);
>  }
>  EXPORT_SYMBOL_GPL(drm_bridge_hpd_enable);
>  
> @@ -1484,13 +1492,15 @@ void drm_bridge_hpd_disable(struct drm_bridge *bridge)
>  	if (!(bridge->ops & DRM_BRIDGE_OP_HPD))
>  		return;
>  
> -	mutex_lock(&bridge->hpd_mutex);
> +	mutex_lock(&bridge->hpd_state_mutex);
>  	if (bridge->funcs->hpd_disable)
>  		bridge->funcs->hpd_disable(bridge);
>  
> +	mutex_lock(&bridge->hpd_mutex);
>  	bridge->hpd_cb = NULL;
>  	bridge->hpd_data = NULL;
>  	mutex_unlock(&bridge->hpd_mutex);
> +	mutex_unlock(&bridge->hpd_state_mutex);
>  }
>  EXPORT_SYMBOL_GPL(drm_bridge_hpd_disable);
>  
> 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().
> 
> -- 
> 2.47.3
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2026-06-01 16:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-28  7:10 [PATCH v3 0/3] drm/bridge: display-connector: detect DP state if cable is plugged on boot Dmitry Baryshkov
2026-05-28  7:10 ` [PATCH v3 1/3] drm/bridge: split hpd_mutex into two mutexes Dmitry Baryshkov
2026-06-01 16:01   ` Sebastian Reichel [this message]
2026-05-28  7:10 ` [PATCH v3 2/3] drm/bridge: display-connector: don't autoenable HPD IRQ Dmitry Baryshkov
2026-05-28 11:07   ` Neil Armstrong
2026-06-01 16:01   ` Sebastian Reichel
2026-05-28  7:10 ` [PATCH v3 3/3] drm/bridge: display-connector: trigger initial HPD event for DP Dmitry Baryshkov
2026-06-01 16:02   ` Sebastian Reichel
2026-06-08  6:49 ` [PATCH v3 0/3] drm/bridge: display-connector: detect DP state if cable is plugged on boot Dmitry Baryshkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ah2smWb3vurXHg1X@venus \
    --to=sebastian.reichel@collabora.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=boris.brezillon@collabora.com \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.org \
    --cc=sam@ravnborg.org \
    --cc=simona@ffwll.ch \
    --cc=tomi.valkeinen@ti.com \
    --cc=tzimmermann@suse.de \
    --cc=yongxing.mou@oss.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®