All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Damon Ding" <damon.ding@rock-chips.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v8 19/20] drm/bridge: analogix_dp: Handle HPD notification from downstream bridge
Date: Mon, 30 Nov 2026 12:21:15 +0000	[thread overview]
Message-ID: <sashiko-outbox-241045@kernel.org> (raw)
In-Reply-To: <20261130115152.1797928-20-damon.ding@rock-chips.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] drm/bridge: analogix_dp: stale detect status and redundant AUX
  probes
- [Medium] drm/bridge: analogix_dp: ignored wait_us in
  analogix_dpaux_wait_hpd_asserted()
- [Medium] drm/bridge: analogix_dp: bypassed HPD check in
  analogix_dp_detect_hpd()
--

commit 23ae2fa9f54b40e12639b8192ac7730ca3b660f6
Author: Damon Ding <damon.ding@rock-chips.com>

drm/bridge: analogix_dp: Handle HPD notification from downstream bridge

This commit adds an HPD notify mode for pipelines where hotplug events come
from a downstream bridge, muting native HPD interrupts and probing the sink
over the AUX channel on HPD notifications.

Link: https://lore.kernel.org/all/5609825.iZASKD2KPV@diego/

> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> index e156fe9682582..04e9dc20fe86c 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c

[ ... ]

> @@ -86,10 +86,29 @@ static void analogix_dp_init_dp(struct analogix_dp_device *dp)
>  	analogix_dp_init_aux(dp);
>  }
>  
> +static bool analogix_dp_probe_sink(struct analogix_dp_device *dp)
> +{
> +	u8 dpcd_rev = 0;
> +	int ret;
> +
> +	ret = pm_runtime_resume_and_get(dp->dev);
> +	if (ret)
> +		return false;
> +
> +	ret = drm_dp_dpcd_readb(&dp->aux, DP_DPCD_REV, &dpcd_rev);
> +
> +	pm_runtime_put_autosuspend(dp->dev);
> +
> +	return ret == 1 && dpcd_rev != 0;
> +}
> +
>  static int analogix_dp_detect_hpd(struct analogix_dp_device *dp)
>  {
>  	int timeout_loop = 0;
>  
> +	if (dp->hpd_notify_mode)
> +		return 0;
> +
>  	while (timeout_loop < DP_TIMEOUT_LOOP_COUNT) {
>  		if (analogix_dp_get_plug_in_status(dp) == 0)
>  			return 0;
> @@ -931,6 +950,10 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *conne
>  	struct analogix_dp_device *dp = to_dp(bridge);
>  	enum drm_connector_status status = connector_status_disconnected;
>  
> +	if (dp->hpd_notify_mode)
> +		return dp->connection_notified ? connector_status_connected :
> +						 connector_status_disconnected;
> +
>  	if (dp->force_connected_mode)
>  		return connector_status_connected;

[ ... ]

> @@ -1287,6 +1326,17 @@ static void analogix_dp_bridge_atomic_post_disable(struct drm_bridge *bridge,
>  		DRM_ERROR("Failed to enable psr (%d)\n", ret);
>  }
>  
> +static void analogix_dp_bridge_notify(struct drm_bridge *bridge, struct drm_connector *connector,
> +				      enum drm_connector_status status)
> +{
> +	struct analogix_dp_device *dp = to_dp(bridge);
> +
> +	if (!dp->hpd_notify_mode)
> +		return;
> +
> +	dp->connection_notified = analogix_dp_probe_sink(dp);
> +}

[Severity: High]
Does probing the sink in analogix_dp_bridge_notify() instead of
analogix_dp_bridge_detect() cause drm_bridge_connector_detect_ctx() to
return the stale pre-probe status?

drivers/gpu/drm/display/drm_bridge_connector.c:drm_bridge_connector_detect_ctx() {
	if (detect) {
		status = detect->funcs->detect(detect, connector);
		...
		drm_bridge_connector_hpd_notify(connector, status);
	}
	...
	return status;
}

drm_bridge_connector_detect_ctx() calls .detect() first, notifies the bridge
chain with that result, and returns the pre-notify status. During initial
driver bind or system resume, before a downstream HPD event runs,
analogix_dp_bridge_detect() returns connector_status_disconnected even when
analogix_dp_bridge_notify() immediately probes the connected sink at the end
of the same detect call, leaving the display without modes because
DRM_CONNECTOR_POLL_HPD does not re-poll.

Because drm_bridge_connector_detect_ctx() always invokes
drm_bridge_connector_hpd_notify(), every detection cycle also triggers
analogix_dp_probe_sink() again. On a cable unplug or a detect call with no
sink attached, analogix_dp_bridge_notify() ignores status ==
connector_status_disconnected and analogix_dp_detect_hpd() returns 0, so
drm_dp_dpcd_readb() performs all 32 AUX retries against a disconnected sink,
stalling for ~650 ms and logging 32 dev_err("AUX CH cmd reply timeout!\n")
messages per probe.

In addition, drm_bridge_connector_handle_hpd() drops dev->mode_config.mutex
before calling drm_bridge_connector_hpd_notify(), so a concurrent detect
call can read the old dp->connection_notified value while
analogix_dp_probe_sink() is still in flight. Finally, the commit message
still states that the probe result is refreshed by both the notify and the
detect paths.

[ ... ]

> @@ -1450,7 +1501,12 @@ static int analogix_dpaux_wait_hpd_asserted(struct drm_dp_aux *aux, unsigned lon
>  	if (dp->force_hpd)
>  		return 0;
>  
> -	pm_runtime_get_sync(dp->dev);
> +	if (dp->hpd_notify_mode)
> +		return analogix_dp_probe_sink(dp) ? 0 : -ETIMEDOUT;

[Severity: Medium]
Does analogix_dpaux_wait_hpd_asserted() ignore wait_us in hpd_notify_mode?
drm_dp_aux.wait_hpd_asserted is expected to wait up to wait_us microseconds
for the sink to come up without logging timeout errors, whereas a single
analogix_dp_probe_sink() call fails immediately with -ETIMEDOUT and logs 32
AUX timeout errors if the sink is still powering up.

> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
> index af5e5a8ec88d6..125f4fecbaa28 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c

[ ... ]

> @@ -533,16 +533,15 @@ int analogix_dp_get_plug_in_status(struct analogix_dp_device *dp)
>  {
>  	u32 reg;
>  
> -	if (dp->hpd_gpiod) {
> -		if (gpiod_get_value(dp->hpd_gpiod))
> -			return 0;
> -	} else {
> -		reg = readl(dp->reg_base + ANALOGIX_DP_SYS_CTL_3);
> -		if (reg & HPD_STATUS)
> -			return 0;
> -	}
> +	if (dp->hpd_gpiod)
> +		return gpiod_get_value(dp->hpd_gpiod) ? 0 : -EINVAL;
> +
> +	if (dp->hpd_notify_mode)
> +		return dp->connection_notified ? 0 : -EINVAL;

[Severity: Medium]
Is this dp->hpd_notify_mode check reachable when analogix_dp_detect_hpd()
returns 0 unconditionally at the top of the function? Every caller of
analogix_dp_get_plug_in_status() (analogix_dp_detect_hpd(),
analogix_dpaux_wait_hpd_asserted(), and analogix_dp_irq_thread()) is
bypassed or disabled in hpd_notify_mode, which also causes
analogix_dp_set_bridge() to get 0 from analogix_dp_detect_hpd() and proceed
with link training in analogix_dp_commit() even when dp->connection_notified
is false.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130115152.1797928-1-damon.ding@rock-chips.com?part=19

  reply	other threads:[~2026-11-30 12:21 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 11:51 [PATCH v8 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
2026-11-30 11:51 ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 01/20] drm/bridge: Select VIDEOMODE_HELPERS for DRM_OF_DISPLAY_MODE_BRIDGE Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:59   ` sashiko-bot
2026-12-02  3:01     ` Damon Ding
2026-12-02  3:14       ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 02/20] drm/bridge: analogix_dp: Drop the redundant pm_runtime_mark_last_busy() calls Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 03/20] drm/bridge: analogix_dp: Use bridge->next_bridge instead of plat_data field Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 04/20] drm/bridge: analogix_dp: Restrict forced connected status to panel endpoints Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 05/20] drm/bridge: analogix_dp: Take a runtime PM reference in bridge detect Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 06/20] drm/bridge: analogix_dp: Return bitmask from analogix_dp_get_irq_type() Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 07/20] drm/bridge: analogix_dp: Check all negative return values for &analogix_dp_device.irq Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 08/20] drm/bridge: analogix_dp: Add IRQF_ONESHOT and simplify IRQ handling Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 09/20] drm/bridge: analogix_dp: Extend clear_hotplug_interrupts to accept IRQ bitmask Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 10/20] drm/bridge: analogix_dp: Extend mute/unmute HPD interrupts to accept irq bitmask Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 11/20] drm/bridge: analogix_dp: Simplify analogix_dp_config_interrupt() Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 12/20] drm/bridge: analogix_dp: Use platform-specific HPD detection scheme Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 13/20] drm/bridge: analogix_dp: Skip native HPD interrupt ops for GPIO HPD Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 14/20] drm/rockchip: analogix_dp: Unbind bridge when connector init fails Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 15/20] drm/exynos: exynos_dp: " Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 16/20] drm/bridge: analogix_dp: Move IRQ enable/disable to bind/unbind Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 17/20] drm/bridge: analogix_dp: Manage pm runtime and IRQ for native HPD pin detection Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 18/20] drm/bridge: analogix_dp: Declare DRM_BRIDGE_OP_HPD for hotplug reporting Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 11:51 ` [PATCH v8 19/20] drm/bridge: analogix_dp: Handle HPD notification from downstream bridge Damon Ding
2026-11-30 11:51   ` Damon Ding
2026-11-30 12:21   ` sashiko-bot [this message]
2026-11-30 11:51 ` [PATCH v8 20/20] MAINTAINERS: Add entry for Analogix DP controller bridge Damon Ding
2026-11-30 11:51   ` Damon Ding

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-241045@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=damon.ding@rock-chips.com \
    --cc=dri-devel@lists.freedesktop.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.