dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Gianfranco Mariotti" <gianfranco.mariotti94@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 07/10] drm/msm/dp: fix HPD plugged, AUX gate, and runtime PM tracking
Date: Fri, 27 Nov 2026 10:59:17 +0000	[thread overview]
Message-ID: <sashiko-outbox-237194@kernel.org> (raw)
In-Reply-To: <20261127101417.24303-8-gianfranco.mariotti94@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] drm/msm/dp: early return in msm_dp_hpd_plug_handle() skips
  branch sink init
- [Medium] drm/msm/dp: stale sink_count in
  msm_dp_display_is_dongle_plugged() on unplug
--

commit f7be63be5e39d6eb47128f66765be92b0a077052
Author: Gianfranco Mariotti <gianfranco.mariotti94@gmail.com>

drm/msm/dp: fix HPD plugged, AUX gate, and runtime PM tracking

This commit updates hotplug, connector detection, and link preparation in the
MSM DP driver to balance dp->plugged state, AUX transfer enablement, and
runtime PM reference counting.

> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
> index 7831dd13b0674..a48f42a173657 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -408,8 +408,9 @@ static int msm_dp_display_handle_irq_hpd(struct msm_dp_display_private *dp)
>  
>  static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp)
>  {
> -	int ret;
>  	struct platform_device *pdev = dp->msm_dp_display.pdev;
> +	bool phy_deinit;
> +	int ret;
>  
>  	drm_dbg_dp(dp->drm_dev, "Before, type=%d sink_count=%d\n",
>  			dp->msm_dp_display.connector_type,
> @@ -417,6 +418,9 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp)
>  
>  	guard(mutex)(&dp->plugged_lock);
>  
> +	if (dp->plugged)
> +		return 0;
> +
>  	ret = pm_runtime_resume_and_get(&pdev->dev);
>  	if (ret) {
>  		DRM_ERROR("failed to pm_runtime_resume\n");
> @@ -425,9 +429,16 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp)
>  
>  	msm_dp_aux_enable_xfers(dp->aux, true);
>  
> -	msm_dp_display_host_phy_init(dp);
> +	phy_deinit = msm_dp_display_host_phy_init(dp);
>  
>  	ret = msm_dp_display_process_hpd_high(dp);
> +	if (ret && ret != -ENOTCONN) {
> +		msm_dp_aux_enable_xfers(dp->aux, false);
> +		if (phy_deinit)
> +			msm_dp_display_host_phy_exit(dp);
> +		pm_runtime_put(&pdev->dev);
> +		return ret;
> +	}
>  
>  	drm_dbg_dp(dp->drm_dev, "After, type=%d sink_count=%d\n",
>  			dp->msm_dp_display.connector_type,
> @@ -435,8 +446,8 @@ static int msm_dp_hpd_plug_handle(struct msm_dp_display_private *dp)
>  
>  	dp->plugged = true;
>  
> -	return ret;
> -};
> +	return 0;
> +}

[Severity: High]
Does the early return when dp->plugged is true skip downstream sink
initialization when a monitor is later plugged into an already-attached empty
branch device?

When an empty branch dongle is connected first, msm_dp_panel_read_link_caps()
sets dp->link->sink_count = 0 and returns -ENOTCONN before reading EDID, and
msm_dp_hpd_plug_handle() sets dp->plugged = true.  When a downstream monitor
is connected afterward and msm_dp_bridge_hpd_notify() calls
msm_dp_hpd_plug_handle() (for example on external Type-C HPD where
hpd_link_status is ISR_DISCONNECTED, or via drm_bridge_connector_detect()),
msm_dp_hpd_plug_handle() returns early without running
msm_dp_display_process_hpd_high().  Because msm_dp_bridge_detect() only reads
DP_SINK_COUNT into a local variable, dp->link->sink_count stays 0, EDID is
never read, and msm_dp_display_prepare_link() fails with -ENOTCONN.

[ ... ]

> @@ -1598,6 +1603,22 @@ void msm_dp_bridge_hpd_disable(struct drm_bridge *bridge)
>  	pm_runtime_put_sync(&msm_dp_display->pdev->dev);
>  }
>  
> +static bool msm_dp_display_is_dongle_plugged(struct msm_dp_display_private *dp,
> +					     u32 hpd_link_status)
> +{
> +	u8 rev;
> +
> +	guard(mutex)(&dp->plugged_lock);
> +
> +	if (!dp->plugged || !dp->link->has_sink_count || dp->link->sink_count)
> +		return false;
> +
> +	if (hpd_link_status != ISR_DISCONNECTED)
> +		return true;
> +
> +	return !drm_dp_dpcd_read_byte(dp->aux, DP_DPCD_REV, &rev);
> +}
> +
>  void msm_dp_bridge_hpd_notify(struct drm_bridge *bridge,
>  			      struct drm_connector *connector,
>  			      enum drm_connector_status status)
> @@ -1626,7 +1647,7 @@ void msm_dp_bridge_hpd_notify(struct drm_bridge *bridge,
>  		} else {
>  			msm_dp_hpd_plug_handle(dp);
>  		}
> -	} else {
> +	} else if (!msm_dp_display_is_dongle_plugged(dp, hpd_link_status)) {
>  		msm_dp_hpd_unplug_handle(dp);
>  	}

[Severity: Medium]
Can msm_dp_display_is_dongle_plugged() see a stale non-zero
dp->link->sink_count when a downstream monitor is unplugged from an attached
branch dongle?

When a downstream monitor is disconnected and detection runs through
drm_bridge_connector_detect() -> msm_dp_bridge_detect() without a prior
native IRQ_HPD pulse updating dp->link->sink_count, msm_dp_bridge_detect()
reads DP_SINK_COUNT == 0 into a local variable and returns
connector_status_disconnected while dp->link->sink_count remains >= 1.
msm_dp_display_is_dongle_plugged() then returns false and
msm_dp_bridge_hpd_notify() calls msm_dp_hpd_unplug_handle(), tearing down
dp->plugged, AUX transfers, and runtime PM for the still-attached dongle.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261127101417.24303-1-gianfranco.mariotti94@gmail.com?part=7

  reply	other threads:[~2026-11-27 10:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 10:14 [PATCH v2 00/10] drm/msm/dp: fix DisplayPort hotplug, link training, and multi-lane PHY setup Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 01/10] drm/msm/dp: configure voltage swing and pre-emphasis for all active lanes Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 02/10] drm/msm/dp: reset cached link_info before reading DPCD capabilities Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 03/10] drm/msm/dp: keep training pattern active until stream video is ready Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 04/10] drm/msm/dp: reinit video_comp and guard stream state on link maintenance Gianfranco Mariotti
2026-11-27 10:31   ` sashiko-bot
2026-11-27 10:14 ` [PATCH v2 05/10] drm/msm/dp: avoid synchronous runtime PM put from HPD IRQ thread Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 06/10] drm/msm/dp: track DP_SINK_COUNT capability and sync prev_sink_count Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 07/10] drm/msm/dp: fix HPD plugged, AUX gate, and runtime PM tracking Gianfranco Mariotti
2026-11-27 10:59   ` sashiko-bot [this message]
2026-11-27 10:14 ` [PATCH v2 08/10] drm/msm/dp: keep PHY initialized while plugged across link unprepare Gianfranco Mariotti
2026-11-27 11:01   ` sashiko-bot
2026-11-27 10:14 ` [PATCH v2 09/10] drm/msm/dp: re-read EDID on demand in get_modes when blob is missing Gianfranco Mariotti
2026-11-27 10:14 ` [PATCH v2 10/10] drm/msm/dp: dispatch native IRQ_HPD directly to msm_dp_irq_hpd_handle() Gianfranco Mariotti

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=sashiko-outbox-237194@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gianfranco.mariotti94@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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