[PATCH 7/7] drm/msm/dp: retrain link when loss of symbol lock detected
From: Kuogee Hsieh
Date: Tue Jul 06 2021 - 13:21:15 EST
Main link symbol locked is achieved at end of link training 2. Some
dongle main link symbol may become unlocked again if host did not end
link training soon enough after completion of link training 2. Host
have to re train main link if loss of symbol lock detected before
end link training so that the coming video stream can be transmitted
to sink properly.
Signed-off-by: Kuogee Hsieh <khsieh@xxxxxxxxxxxxxx>
---
drivers/gpu/drm/msm/dp/dp_ctrl.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c
index 0cb01a9..e616ab2 100644
--- a/drivers/gpu/drm/msm/dp/dp_ctrl.c
+++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c
@@ -1661,6 +1661,25 @@ static bool dp_ctrl_any_lane_cr_lose(struct dp_ctrl_private *ctrl,
return false;
}
+static bool dp_ctrl_loss_symbol_lock(struct dp_ctrl_private *ctrl)
+{
+ u8 link_status[6];
+ u8 status;
+ int i;
+ int lane = ctrl->link->link_params.num_lanes;
+
+ dp_ctrl_read_link_status(ctrl, link_status);
+
+ for (i = 0; i < lane; i++) {
+ status = link_status[i / 2];
+ status >>= ((i % 2) * 4);
+ if (!(status & DP_LANE_SYMBOL_LOCKED))
+ return true;
+ }
+
+ return false;
+}
+
int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl)
{
int rc = 0;
@@ -1777,6 +1796,17 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl)
return rc;
}
+static int dp_ctrl_link_retrain(struct dp_ctrl_private *ctrl)
+{
+ int ret = 0;
+ u8 cr_status[2];
+ int training_step = DP_TRAINING_NONE;
+
+ ret = dp_ctrl_setup_main_link(ctrl, cr_status, &training_step);
+
+ return ret;
+}
+
int dp_ctrl_on_stream(struct dp_ctrl *dp_ctrl)
{
int ret = 0;
@@ -1802,6 +1832,10 @@ int dp_ctrl_on_stream(struct dp_ctrl *dp_ctrl)
}
}
+ /* if loss symbol lock happen, then retaining the link */
+ if (dp_ctrl_loss_symbol_lock(ctrl))
+ dp_ctrl_link_retrain(ctrl);
+
/* stop txing train pattern to end link training */
dp_ctrl_clear_training_pattern(ctrl);
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project