>From 242fdfdef877fd756a789b1bba8323fb1de0b594 Mon Sep 17 00:00:00 2001
Message-ID: 
<242fdfdef877fd756a789b1bba8323fb1de0b594.1790083445.git.arthur_liber...@hotmail.com>
In-Reply-To: <[email protected]>
References: <[email protected]>
From: Arthur Liberman <[email protected]>
Date: Mon, 21 Sep 2026 01:41:29 +0300
Subject: [PATCH 2/3] drm/amd/display: skip destructive HPD verify on live
 links

Destructive link-cap verify DPMS-offs every live stream from the HPD
worker via dc_commit_updates_for_stream(). DP takes that path unless
the link is embedded, training is skipped, or dpcd_caps.is_mst_capable
is set.

detect_link_and_local_sink() re-reads DPCD before
verify_link_capability(). Switching input or powering off an MST
daisy-chain while the CRTCs are still on can clear is_mst_capable,
so the MST exemption no longer applies and detect takes the
destructive path before MST rediscovery.

Keep the non-destructive verify while the link still has DPMS-on
master pipes. Userspace will disable the CRTCs; a later detect can
train.

Fixes: c282d9512cdd ("drm/amd/display: factor out dp detection link training 
and mst top detection")
Cc: [email protected]
Assisted-by: Cursor:xai-grok-4.6
Signed-off-by: Arthur Liberman <[email protected]>
---
 .../drm/amd/display/dc/link/link_detection.c    | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/link/link_detection.c 
b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
index 12fd4fd24a90..66fb3bc06a1f 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
@@ -960,13 +960,28 @@ static bool 
should_verify_link_capability_destructively(struct dc_link *link,
                                        link);
 
        if (dc_is_dp_signal(link->local_sink->sink_signal)) {
+               struct pipe_ctx *pipes[MAX_PIPES];
+               uint8_t active_count = 0;
+
                max_link_cap = dp_get_max_link_cap(link);
                destrictive = true;
 
+               /*
+                * Destructive verify DPMS-off's every live stream via
+                * dc_commit_updates_for_stream() on the HPD worker. That
+                * races MST teardown (input switch / power-off while the
+                * displays are still on) and can NULL remaining pipe streams.
+                * Keep the non-destructive path until userspace disables the
+                * CRTCs; a later detect can train.
+                */
+               link_get_master_pipes_with_dpms_on(link, 
link->dc->current_state,
+                                                  &active_count, pipes);
+
                if (link->dc->debug.skip_detection_link_training ||
                                
dc_is_embedded_signal(link->local_sink->sink_signal) ||
                                (link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA &&
-                               !link->dc->config.enable_dpia_pre_training)) {
+                               !link->dc->config.enable_dpia_pre_training) ||
+                               active_count) {
                        destrictive = false;
                } else if (link_dp_get_encoding_format(&max_link_cap) ==
                                DP_8b_10b_ENCODING) {
-- 
2.55.0

Reply via email to