An eDP panel may not have been powered up when its mode is checked, and a
disconnected DP sink can leave cached link capabilities behind. The cached
values alone do not distinguish either case from a current read.

Track whether link capability discovery completed successfully. Clear the
flag before reading capabilities and on unplug, and set it only after the
downstream information has been read successfully. Subsequent atomic
checks can then defer checks against unknown capabilities until the sink
is accessible.

Assisted-by: LLM
Signed-off-by: Xilin Wu <[email protected]>
---
 drivers/gpu/drm/msm/dp/dp_display.c | 1 +
 drivers/gpu/drm/msm/dp/dp_panel.c   | 3 +++
 drivers/gpu/drm/msm/dp/dp_panel.h   | 1 +
 3 files changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/msm/dp/dp_display.c 
b/drivers/gpu/drm/msm/dp/dp_display.c
index 1bfa6696d904..9c5b1cd200f8 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -519,6 +519,7 @@ static int msm_dp_hpd_unplug_handle(struct 
msm_dp_display_private *dp)
                        dp->msm_dp_display.connector_type,
                        dp->link->sink_count);
 
+       dp->panel->link_caps_valid = false;
        if (!dp->plugged)
                return 0;
 
diff --git a/drivers/gpu/drm/msm/dp/dp_panel.c 
b/drivers/gpu/drm/msm/dp/dp_panel.c
index fdf1a3f437ba..f7aac0d25c87 100644
--- a/drivers/gpu/drm/msm/dp/dp_panel.c
+++ b/drivers/gpu/drm/msm/dp/dp_panel.c
@@ -247,6 +247,7 @@ int msm_dp_panel_read_link_caps(struct msm_dp_panel 
*msm_dp_panel,
 
        panel = container_of(msm_dp_panel, struct msm_dp_panel_private, 
msm_dp_panel);
 
+       msm_dp_panel->link_caps_valid = false;
        rc = msm_dp_panel_read_dpcd(msm_dp_panel);
        if (rc) {
                DRM_ERROR("read dpcd failed %d\n", rc);
@@ -272,6 +273,8 @@ int msm_dp_panel_read_link_caps(struct msm_dp_panel 
*msm_dp_panel,
 
        rc = drm_dp_read_downstream_info(panel->aux, msm_dp_panel->dpcd,
                                         msm_dp_panel->downstream_ports);
+       if (!rc)
+               msm_dp_panel->link_caps_valid = true;
        return rc;
 }
 
diff --git a/drivers/gpu/drm/msm/dp/dp_panel.h 
b/drivers/gpu/drm/msm/dp/dp_panel.h
index 4519ac374220..4fe6af8b304e 100644
--- a/drivers/gpu/drm/msm/dp/dp_panel.h
+++ b/drivers/gpu/drm/msm/dp/dp_panel.h
@@ -38,6 +38,7 @@ struct msm_dp_panel {
        struct msm_dp_panel_psr psr_cap;
        bool video_test;
        bool vsc_sdp_supported;
+       bool link_caps_valid;
        u32 hw_revision;
 
        u32 max_bw_code;

-- 
2.55.0

Reply via email to