On 11/30/2026 8:21 PM, [email protected] wrote:
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 <[email protected]>
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.
The stale status only exists between the driver bind and the first
downstream HPD event. On the tested RK3576 IOTEST board, the
downstream bridge reports the initial connected state 0.4 ms after
the bind, while the first userspace .detect() call comes 622 ms
later and reads the already updated cached state.
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.
Will fix in v9. .hpd_notify() will trust the downstream bridge for
the removal events and update the cached state directly, so no AUX
probe runs against an absent sink. For the connected events, the
probe is skipped when the cached state already reports the sink as
connected, which also covers the call replayed by the detect path.
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.
The race window is only a few microseconds between the cached-state
read in .detect() and the notification replayed by the detect path,
so it needs a physical hotplug event to land exactly there. I have
never seen it reproduce on the board, and it is basically
impossible to hit in practice.
[ ... ]
@@ -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.
Will fix in v9. The special case is dropped, and
analogix_dpaux_wait_hpd_asserted() polls
analogix_dp_get_plug_in_status() again. The cached state is refreshed
by the notify path, so wait_us is honored without any AUX transfer or
timeout messages.
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.
The skip in analogix_dp_detect_hpd() is intentional:
analogix_dp_probe_sink() transfers over AUX and
analogix_dpaux_transfer() calls analogix_dp_detect_hpd() first, so
checking the cached state there would block the probe itself. The
branch in analogix_dp_get_plug_in_status() becomes reachable again
through analogix_dpaux_wait_hpd_asserted() in v9.
For analogix_dp_set_bridge(), an absent sink fails the link training
anyway, so the error is reported through the training failure.
Best regards,
Damon