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 v6 17/18] drm/bridge: analogix_dp: Handle HPD notification from downstream bridge
Date: Fri, 13 Nov 2026 08:49:26 +0000	[thread overview]
Message-ID: <sashiko-outbox-212465@kernel.org> (raw)
In-Reply-To: <20261113082305.541652-18-damon.ding@rock-chips.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] drm/bridge: analogix_dp: analogix_dp_supports_hpd() ignores
  hpd_notify_mode
- [Medium] drm/bridge: analogix_dp: DRM_BRIDGE_OP_HPD set before
  drm_bridge_attach()
- [Medium] drm/bridge: analogix_dp: detect hpd_notify() echo races with
  HPD notifications
--

commit c237458f9c91bcd96060ebf17f0f83f06f94643c
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 to analogix_dp so that hotplug status is
tracked via .hpd_notify instead of native HPD interrupts or register polling
when a downstream bridge provides HPD without detection.

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 9f50163aecf9f..6db2893443758 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> @@ -52,7 +52,8 @@ static const bool verify_fast_training;
>  static bool analogix_dp_require_pm_for_hpd_irq(struct analogix_dp_device *dp)
>  {
>  	return (dp->plat_data->dev_type == RK3576_EDP || dp->plat_data->dev_type == RK3588_EDP) &&
> -	       !dp->hpd_gpiod && !dp->force_hpd && !dp->force_connected_mode;
> +	       !dp->hpd_gpiod && !dp->force_hpd && !dp->force_connected_mode &&
> +	       !dp->hpd_notify_mode;
>  }

[Severity: Medium]
Should analogix_dp_supports_hpd() also check !dp->hpd_notify_mode?

drivers/gpu/drm/bridge/analogix/analogix_dp_core.c:analogix_dp_supports_hpd() {
	if (dp->force_connected_mode || dp->force_hpd)
		return false;

	if (dp->hpd_gpiod)
		return true;

	return dp->plat_data->dev_type == RK3576_EDP || dp->plat_data->dev_type == RK3588_EDP;
}

In analogix_dp_bind(), analogix_dp_require_pm_for_hpd_irq(dp) now returns
false when dp->hpd_notify_mode is set, skipping pm_runtime_resume_and_get()
and leaving native HPD interrupts unmuted in hardware because
analogix_dp_config_interrupt() has not run.  Right after that,
analogix_dp_supports_hpd(dp) still returns true on RK3576_EDP and RK3588_EDP
and calls enable_irq(dp->irq), so any assertion on the unmuted native IRQ
line wakes analogix_dp_irq_thread() and calls drm_bridge_hpd_notify().

>  
>  /*
> @@ -946,6 +947,10 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *conne
>  	enum drm_connector_status status = connector_status_disconnected;
>  	int ret;
>  
> +	if (dp->hpd_notify_mode)
> +		return dp->connection_notified ? connector_status_connected :
> +						 connector_status_disconnected;
> +
>  	if (dp->force_connected_mode)
>  		return connector_status_connected;

[ ... ]

> @@ -1008,6 +1028,7 @@ static int analogix_dp_bridge_attach(struct drm_bridge *bridge,
>  		 * accurate hotplug state.
>  		 */
>  		dp->force_connected_mode = analogix_dp_bridge_force_connected(dp);
> +		dp->hpd_notify_mode = analogix_dp_has_downstream_hpd(dp);
>  	}
>  
>  	return 0;

[Severity: Medium]
Does analogix_dp_bind() check analogix_dp_supports_hpd() too early when
setting DRM_BRIDGE_OP_HPD?

drivers/gpu/drm/bridge/analogix/analogix_dp_core.c:analogix_dp_bind() {
    ...
	bridge->ops = DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_DETECT;
	if (analogix_dp_supports_hpd(dp))
		bridge->ops |= DRM_BRIDGE_OP_HPD;
	bridge->of_node = dp->dev->of_node;
	bridge->type = DRM_MODE_CONNECTOR_eDP;
	ret = devm_drm_bridge_add(dp->dev, &dp->bridge);
	if (ret)
		goto err_unregister_aux;

	ret = drm_bridge_attach(dp->encoder, bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
    ...
}

dp->force_connected_mode and dp->hpd_notify_mode are only computed inside
analogix_dp_bridge_attach() when drm_bridge_attach() runs.  When
analogix_dp_supports_hpd(dp) is evaluated before drm_bridge_attach(), both
flags are still false, so bridge->ops advertises DRM_BRIDGE_OP_HPD on
RK3576_EDP and RK3588_EDP (or when dp->hpd_gpiod is set) even for fixed
panels where enable_irq(dp->irq) is later skipped.

> @@ -1304,6 +1325,14 @@ 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);
> +
> +	dp->connection_notified = (status == connector_status_connected);
> +}

[Severity: Medium]
Can the .hpd_notify() call at the end of drm_bridge_connector_detect_ctx()
overwrite a concurrent hotplug notification in dp->connection_notified?

drm_bridge_connector_detect_ctx() calls detect->funcs->detect() and then
passes the returned status to drm_bridge_connector_hpd_notify().  Meanwhile,
drm_bridge_connector_handle_hpd() drops dev->mode_config.mutex before calling
drm_bridge_connector_hpd_notify() and
drm_kms_helper_connector_hotplug_event():

CPU0                                  CPU1
drm_bridge_connector_detect_ctx()
  analogix_dp_bridge_detect()
    reads connection_notified (false)
                                      drm_bridge_connector_handle_hpd()
                                        drm_bridge_connector_hpd_notify(
                                          ..., status_connected)
                                          analogix_dp_bridge_notify()
                                            connection_notified = true
  drm_bridge_connector_hpd_notify(
    ..., status_disconnected)
    analogix_dp_bridge_notify()
      connection_notified = false  <-- overwrites connected state
                                        drm_kms_helper_connector_hotplug_event()
                                          ...
                                          analogix_dp_bridge_detect()
                                            returns status_disconnected

When the hotplug event on CPU1 re-probes the connector,
analogix_dp_bridge_detect() sees dp->connection_notified == false and reports
the newly connected sink as disconnected, and subsequent AUX transfers fail in
analogix_dp_detect_hpd().

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

  reply	other threads:[~2026-11-13  8:49 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13  8:22 [PATCH v6 00/18] Add HPD support for Rockchip Analogix DP Damon Ding
2026-11-13  8:22 ` Damon Ding
2026-11-13  8:22 ` [PATCH v6 01/18] drm/bridge: Select VIDEOMODE_HELPERS for DRM_OF_DISPLAY_MODE_BRIDGE Damon Ding
2026-11-13  8:22   ` Damon Ding
2026-11-13  8:22 ` [PATCH v6 02/18] drm/bridge: analogix_dp: Use bridge->next_bridge instead of plat_data field Damon Ding
2026-11-13  8:22   ` Damon Ding
2026-11-13  8:22 ` [PATCH v6 03/18] drm/bridge: analogix_dp: Restrict forced connected status to panel endpoints Damon Ding
2026-11-13  8:22   ` Damon Ding
2026-11-13  8:22 ` [PATCH v6 04/18] drm/bridge: analogix_dp: Return bitmask from analogix_dp_get_irq_type() Damon Ding
2026-11-13  8:22   ` Damon Ding
2026-11-13  8:22 ` [PATCH v6 05/18] drm/bridge: analogix_dp: Check all negative return values for &analogix_dp_device.irq Damon Ding
2026-11-13  8:22   ` Damon Ding
2026-11-13  8:22 ` [PATCH v6 06/18] drm/bridge: analogix_dp: Add IRQF_ONESHOT and simplify IRQ handling Damon Ding
2026-11-13  8:22   ` Damon Ding
2026-11-13  8:40   ` sashiko-bot
2026-11-13  8:22 ` [PATCH v6 07/18] drm/bridge: analogix_dp: Extend clear_hotplug_interrupts to accept IRQ bitmask Damon Ding
2026-11-13  8:22   ` Damon Ding
2026-11-13  8:22 ` [PATCH v6 08/18] drm/bridge: analogix_dp: Extend mute/unmute HPD interrupts to accept irq bitmask Damon Ding
2026-11-13  8:22   ` Damon Ding
2026-11-13  8:22 ` [PATCH v6 09/18] drm/bridge: analogix_dp: Simplify analogix_dp_config_interrupt() Damon Ding
2026-11-13  8:22   ` Damon Ding
2026-11-13  8:22 ` [PATCH v6 10/18] drm/bridge: analogix_dp: Use platform-specific HPD detection scheme Damon Ding
2026-11-13  8:22 ` [PATCH v6 11/18] drm/bridge: analogix_dp: Skip native HPD interrupt ops for GPIO HPD Damon Ding
2026-11-13  8:22   ` Damon Ding
2026-11-13  8:22 ` [PATCH v6 12/18] drm/rockchip: analogix_dp: Unbind bridge when connector init fails Damon Ding
2026-11-13  8:22   ` Damon Ding
2026-11-13  8:36   ` sashiko-bot
2026-11-13  8:23 ` [PATCH v6 13/18] drm/exynos: exynos_dp: " Damon Ding
2026-11-13  8:23   ` Damon Ding
2026-11-13  8:48   ` sashiko-bot
2026-11-13  8:23 ` [PATCH v6 14/18] drm/bridge: analogix_dp: Move IRQ enable/disable to bind/unbind Damon Ding
2026-11-13  8:23   ` Damon Ding
2026-11-13  8:50   ` sashiko-bot
2026-11-13  8:23 ` [PATCH v6 15/18] drm/bridge: analogix_dp: Manage pm runtime and IRQ for native HPD pin detection Damon Ding
2026-11-13  8:23   ` Damon Ding
2026-11-13  8:23 ` [PATCH v6 16/18] drm/bridge: analogix_dp: Declare DRM_BRIDGE_OP_HPD for hotplug reporting Damon Ding
2026-11-13  8:23   ` Damon Ding
2026-11-13  8:44   ` sashiko-bot
2026-11-13  8:23 ` [PATCH v6 17/18] drm/bridge: analogix_dp: Handle HPD notification from downstream bridge Damon Ding
2026-11-13  8:23   ` Damon Ding
2026-11-13  8:49   ` sashiko-bot [this message]
2026-11-13  8:23 ` [PATCH v6 18/18] MAINTAINERS: Add entry for Analogix DP controller bridge Damon Ding
2026-11-13  8:23   ` 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-212465@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.