* [PATCH 0/4] drm/msm/dp, phy: qcom: improve DP Type-C reconnect handling
@ 2026-08-24 11:28 Saurabh Anand
2026-08-24 11:28 ` [PATCH 1/4] phy: qcom: qmp-combo: delay Type-C mux switch while DP PHY is initializing Saurabh Anand
` (3 more replies)
0 siblings, 4 replies; 14+ messages in thread
From: Saurabh Anand @ 2026-08-24 11:28 UTC (permalink / raw)
To: Vinod Koul, Neil Armstrong, Manivannan Sadhasivam, Rob Clark,
Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
Marijn Suijten, David Airlie, Simona Vetter
Cc: linux-arm-msm, linux-phy, linux-kernel, dri-devel, freedreno,
Ritesh Kumar, Vishnuvardhan Prodduturi, Mani Chandana Kuntumalla,
Mahadevan P, Saurabh Anand
This series improves the Qualcomm DP Type-C bring-up and reconnect paths
by handling PHY initialization races and link-training corner cases more
consistently.
The fixes cover races and link-training corner cases in the Qualcomm DP
Type-C path. They prevent Type-C mux switching while the DP PHY is still
initializing, avoid unnecessary retraining after a successful link train,
skip LTTPR setup when no LTTPRs are present, and keep the downgrade retry
path running across transient AUX disconnects when the cable is still
plugged.
Together these changes make DP reconnect and orientation-switch
handling more robust, especially when AUX link status briefly disagrees
with Type-C cable presence during reconnect.
Signed-off-by: Saurabh Anand <saurabh.anand@oss.qualcomm.com>
---
Saurabh Anand (4):
phy: qcom: qmp-combo: delay Type-C mux switch while DP PHY is initializing
drm/msm/dp: clear force_link_train flag when link training succeeds
drm/msm/dp: skip LTTPR init when no LTTPRs are present
drm/msm/dp: continue link training downgrade when cable is still plugged
drivers/gpu/drm/msm/dp/dp_ctrl.c | 4 ++--
drivers/gpu/drm/msm/dp/dp_ctrl.h | 1 +
drivers/gpu/drm/msm/dp/dp_display.c | 7 +++++++
drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 3 ++-
4 files changed, 12 insertions(+), 3 deletions(-)
---
base-commit: e6664f2b33db9b6811eb4cec109f06cb2b4f458d
change-id: 20260824-qcom-dp-typec-reconnect-fixes-030767868837
Best regards,
--
Saurabh Anand <saurabh.anand@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/4] phy: qcom: qmp-combo: delay Type-C mux switch while DP PHY is initializing
2026-08-24 11:28 [PATCH 0/4] drm/msm/dp, phy: qcom: improve DP Type-C reconnect handling Saurabh Anand
@ 2026-08-24 11:28 ` Saurabh Anand
2026-09-02 7:48 ` Manivannan Sadhasivam
2026-09-13 21:36 ` Dmitry Baryshkov
2026-08-24 11:28 ` [PATCH 2/4] drm/msm/dp: clear force_link_train flag when link training succeeds Saurabh Anand
` (2 subsequent siblings)
3 siblings, 2 replies; 14+ messages in thread
From: Saurabh Anand @ 2026-08-24 11:28 UTC (permalink / raw)
To: Vinod Koul, Neil Armstrong, Manivannan Sadhasivam, Rob Clark,
Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
Marijn Suijten, David Airlie, Simona Vetter
Cc: linux-arm-msm, linux-phy, linux-kernel, dri-devel, freedreno,
Ritesh Kumar, Vishnuvardhan Prodduturi, Mani Chandana Kuntumalla,
Mahadevan P, Saurabh Anand
The Type-C mux switch guard only checked dp_powered_on, which is set in
qmp_combo_dp_power_on(). However there is a race window between
qmp_combo_dp_init() and qmp_combo_dp_power_on() during which dp_init_count
is non-zero but dp_powered_on is still false. A Type-C orientation change
arriving in this window would proceed with the mux switch while the DP PHY
is mid-initialization, corrupting the PHY state.
Extend the guard to also block the mux switch when dp_init_count is
non-zero, covering the full period from dp_init through dp_power_on.
Signed-off-by: Saurabh Anand <saurabh.anand@oss.qualcomm.com>
---
drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
index c39ced168d03..f23aff79ca08 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c
@@ -4842,7 +4842,8 @@ static int qmp_combo_typec_mux_set(struct typec_mux_dev *mux, struct typec_mux_s
return 0;
}
- if (qmp->qmpphy_mode != QMPPHY_MODE_USB3_ONLY && qmp->dp_powered_on) {
+ if (qmp->qmpphy_mode != QMPPHY_MODE_USB3_ONLY &&
+ (qmp->dp_powered_on || qmp->dp_init_count)) {
dev_dbg(qmp->dev, "typec_mux_set: DP PHY is still in use, delaying switch\n");
return 0;
}
--
2.34.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 2/4] drm/msm/dp: clear force_link_train flag when link training succeeds
2026-08-24 11:28 [PATCH 0/4] drm/msm/dp, phy: qcom: improve DP Type-C reconnect handling Saurabh Anand
2026-08-24 11:28 ` [PATCH 1/4] phy: qcom: qmp-combo: delay Type-C mux switch while DP PHY is initializing Saurabh Anand
@ 2026-08-24 11:28 ` Saurabh Anand
2026-08-24 13:17 ` Konrad Dybcio
2026-08-24 11:28 ` [PATCH 3/4] drm/msm/dp: skip LTTPR init when no LTTPRs are present Saurabh Anand
2026-08-24 11:28 ` [PATCH 4/4] drm/msm/dp: continue link training downgrade when cable is still plugged Saurabh Anand
3 siblings, 1 reply; 14+ messages in thread
From: Saurabh Anand @ 2026-08-24 11:28 UTC (permalink / raw)
To: Vinod Koul, Neil Armstrong, Manivannan Sadhasivam, Rob Clark,
Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
Marijn Suijten, David Airlie, Simona Vetter
Cc: linux-arm-msm, linux-phy, linux-kernel, dri-devel, freedreno,
Ritesh Kumar, Vishnuvardhan Prodduturi, Mani Chandana Kuntumalla,
Mahadevan P, Saurabh Anand
msm_dp_display_prepare_link() sets force_link_train = true before calling
msm_dp_ctrl_on_link(). On success the flag was never cleared, so
msm_dp_ctrl_prepare_stream_on() would unconditionally trigger a second
link retrain even though the link was already trained.
Clear force_link_train on the success path so that
msm_dp_ctrl_prepare_stream_on() only retrains when the channel EQ check
fails, as intended.
Signed-off-by: Saurabh Anand <saurabh.anand@oss.qualcomm.com>
---
drivers/gpu/drm/msm/dp/dp_display.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index bc646d172abe..40e19d506a45 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -649,6 +649,8 @@ static int msm_dp_display_prepare_link(struct msm_dp_display_private *dp)
return rc;
}
+ force_link_train = false;
+
return msm_dp_ctrl_prepare_stream_on(dp->ctrl, dp->panel, force_link_train);
}
--
2.34.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 3/4] drm/msm/dp: skip LTTPR init when no LTTPRs are present
2026-08-24 11:28 [PATCH 0/4] drm/msm/dp, phy: qcom: improve DP Type-C reconnect handling Saurabh Anand
2026-08-24 11:28 ` [PATCH 1/4] phy: qcom: qmp-combo: delay Type-C mux switch while DP PHY is initializing Saurabh Anand
2026-08-24 11:28 ` [PATCH 2/4] drm/msm/dp: clear force_link_train flag when link training succeeds Saurabh Anand
@ 2026-08-24 11:28 ` Saurabh Anand
2026-08-24 13:15 ` Konrad Dybcio
2026-08-24 11:28 ` [PATCH 4/4] drm/msm/dp: continue link training downgrade when cable is still plugged Saurabh Anand
3 siblings, 1 reply; 14+ messages in thread
From: Saurabh Anand @ 2026-08-24 11:28 UTC (permalink / raw)
To: Vinod Koul, Neil Armstrong, Manivannan Sadhasivam, Rob Clark,
Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
Marijn Suijten, David Airlie, Simona Vetter
Cc: linux-arm-msm, linux-phy, linux-kernel, dri-devel, freedreno,
Ritesh Kumar, Vishnuvardhan Prodduturi, Mani Chandana Kuntumalla,
Mahadevan P, Saurabh Anand
drm_dp_lttpr_count() returns 0 when no LTTPRs are detected and a
negative value on error. The previous code passed the result directly
to drm_dp_lttpr_init() without checking, which would call into the
LTTPR transparency-mode setup with a zero or negative repeater count.
Add an early return for lttpr_count <= 0 to skip the init entirely
when there are no repeaters in the link, matching the expected usage
of drm_dp_lttpr_init().
Signed-off-by: Saurabh Anand <saurabh.anand@oss.qualcomm.com>
---
drivers/gpu/drm/msm/dp/dp_display.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index 40e19d506a45..1f60c78a463d 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -253,6 +253,10 @@ static int msm_dp_display_lttpr_init(struct msm_dp_display_private *dp, u8 *dpcd
return 0;
lttpr_count = drm_dp_lttpr_count(dp->link->lttpr_common_caps);
+
+ if (lttpr_count <= 0)
+ return 0;
+
rc = drm_dp_lttpr_init(dp->aux, lttpr_count);
if (rc) {
DRM_ERROR("failed to set LTTPRs transparency mode, rc=%d\n", rc);
--
2.34.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 4/4] drm/msm/dp: continue link training downgrade when cable is still plugged
2026-08-24 11:28 [PATCH 0/4] drm/msm/dp, phy: qcom: improve DP Type-C reconnect handling Saurabh Anand
` (2 preceding siblings ...)
2026-08-24 11:28 ` [PATCH 3/4] drm/msm/dp: skip LTTPR init when no LTTPRs are present Saurabh Anand
@ 2026-08-24 11:28 ` Saurabh Anand
2026-09-13 21:42 ` Dmitry Baryshkov
3 siblings, 1 reply; 14+ messages in thread
From: Saurabh Anand @ 2026-08-24 11:28 UTC (permalink / raw)
To: Vinod Koul, Neil Armstrong, Manivannan Sadhasivam, Rob Clark,
Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
Marijn Suijten, David Airlie, Simona Vetter
Cc: linux-arm-msm, linux-phy, linux-kernel, dri-devel, freedreno,
Ritesh Kumar, Vishnuvardhan Prodduturi, Mani Chandana Kuntumalla,
Mahadevan P, Saurabh Anand
During a Type-C reconnect the AUX channel may report link-disconnected
transiently while the physical cable is still present. The link training
retry loop in msm_dp_ctrl_on_link() was aborting immediately on any
msm_dp_aux_is_link_connected() failure, preventing the rate/lane downgrade
path from running.
When the display is known to be plugged (msm_dp_ctrl->plugged), an AUX
link-disconnected status is likely a transient glitch rather than a true
unplug. Allow the downgrade loop to continue in that case by requiring both
conditions before breaking out of the retry loop: AUX reports disconnected
and the display is not plugged.
The plugged state is snapshotted from dp_display into msm_dp_ctrl just
before msm_dp_ctrl_on_link() is called, so the retry loop has an accurate
view of cable presence at the time link training started.
Signed-off-by: Saurabh Anand <saurabh.anand@oss.qualcomm.com>
---
drivers/gpu/drm/msm/dp/dp_ctrl.c | 4 ++--
drivers/gpu/drm/msm/dp/dp_ctrl.h | 1 +
drivers/gpu/drm/msm/dp/dp_display.c | 1 +
3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c
index 59070f399e2d..e8fd8f4c75fe 100644
--- a/drivers/gpu/drm/msm/dp/dp_ctrl.c
+++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c
@@ -2379,7 +2379,7 @@ int msm_dp_ctrl_on_link(struct msm_dp_ctrl *msm_dp_ctrl,
break;
} else if (training_step == DP_TRAINING_1) {
/* link train_1 failed */
- if (!msm_dp_aux_is_link_connected(ctrl->aux))
+ if (!msm_dp_aux_is_link_connected(ctrl->aux) && !msm_dp_ctrl->plugged)
break;
drm_dp_dpcd_read_link_status(ctrl->aux, link_status);
@@ -2404,7 +2404,7 @@ int msm_dp_ctrl_on_link(struct msm_dp_ctrl *msm_dp_ctrl,
}
} else if (training_step == DP_TRAINING_2) {
/* link train_2 failed */
- if (!msm_dp_aux_is_link_connected(ctrl->aux))
+ if (!msm_dp_aux_is_link_connected(ctrl->aux) && !msm_dp_ctrl->plugged)
break;
drm_dp_dpcd_read_link_status(ctrl->aux, link_status);
diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.h b/drivers/gpu/drm/msm/dp/dp_ctrl.h
index 5902cf7e746a..95533b0b6297 100644
--- a/drivers/gpu/drm/msm/dp/dp_ctrl.h
+++ b/drivers/gpu/drm/msm/dp/dp_ctrl.h
@@ -12,6 +12,7 @@
struct msm_dp_ctrl {
bool wide_bus_en;
+ bool plugged;
};
struct phy;
diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
index 1f60c78a463d..93a37a44273f 100644
--- a/drivers/gpu/drm/msm/dp/dp_display.c
+++ b/drivers/gpu/drm/msm/dp/dp_display.c
@@ -644,6 +644,7 @@ static int msm_dp_display_prepare_link(struct msm_dp_display_private *dp)
if (!msm_dp_display->power_on) {
msm_dp_display_host_phy_init(dp);
force_link_train = true;
+ dp->ctrl->plugged = dp->plugged;
}
rc = msm_dp_ctrl_on_link(dp->ctrl, dp->panel);
--
2.34.1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/4] drm/msm/dp: skip LTTPR init when no LTTPRs are present
2026-08-24 11:28 ` [PATCH 3/4] drm/msm/dp: skip LTTPR init when no LTTPRs are present Saurabh Anand
@ 2026-08-24 13:15 ` Konrad Dybcio
2026-09-07 9:44 ` Saurabh Anand
0 siblings, 1 reply; 14+ messages in thread
From: Konrad Dybcio @ 2026-08-24 13:15 UTC (permalink / raw)
To: Saurabh Anand, Vinod Koul, Neil Armstrong, Manivannan Sadhasivam,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, David Airlie, Simona Vetter
Cc: linux-arm-msm, linux-phy, linux-kernel, dri-devel, freedreno,
Ritesh Kumar, Vishnuvardhan Prodduturi, Mani Chandana Kuntumalla,
Mahadevan P
On 8/24/26 1:28 PM, Saurabh Anand wrote:
> drm_dp_lttpr_count() returns 0 when no LTTPRs are detected and a
> negative value on error. The previous code passed the result directly
> to drm_dp_lttpr_init() without checking, which would call into the
> LTTPR transparency-mode setup with a zero or negative repeater count.
>
> Add an early return for lttpr_count <= 0 to skip the init entirely
> when there are no repeaters in the link, matching the expected usage
> of drm_dp_lttpr_init().
Reading the body of that function, I'm not sure your statement is true
Konrad
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/4] drm/msm/dp: clear force_link_train flag when link training succeeds
2026-08-24 11:28 ` [PATCH 2/4] drm/msm/dp: clear force_link_train flag when link training succeeds Saurabh Anand
@ 2026-08-24 13:17 ` Konrad Dybcio
2026-09-07 9:35 ` Saurabh Anand
0 siblings, 1 reply; 14+ messages in thread
From: Konrad Dybcio @ 2026-08-24 13:17 UTC (permalink / raw)
To: Saurabh Anand, Vinod Koul, Neil Armstrong, Manivannan Sadhasivam,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, David Airlie, Simona Vetter
Cc: linux-arm-msm, linux-phy, linux-kernel, dri-devel, freedreno,
Ritesh Kumar, Vishnuvardhan Prodduturi, Mani Chandana Kuntumalla,
Mahadevan P
On 8/24/26 1:28 PM, Saurabh Anand wrote:
> msm_dp_display_prepare_link() sets force_link_train = true before calling
> msm_dp_ctrl_on_link(). On success the flag was never cleared, so
> msm_dp_ctrl_prepare_stream_on() would unconditionally trigger a second
> link retrain even though the link was already trained.
>
> Clear force_link_train on the success path so that
> msm_dp_ctrl_prepare_stream_on() only retrains when the channel EQ check
> fails, as intended.
>
> Signed-off-by: Saurabh Anand <saurabh.anand@oss.qualcomm.com>
> ---
> drivers/gpu/drm/msm/dp/dp_display.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
> index bc646d172abe..40e19d506a45 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -649,6 +649,8 @@ static int msm_dp_display_prepare_link(struct msm_dp_display_private *dp)
> return rc;
> }
>
> + force_link_train = false;
> +
> return msm_dp_ctrl_prepare_stream_on(dp->ctrl, dp->panel, force_link_train);
This makes the argument of this function useless
Konrad
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/4] phy: qcom: qmp-combo: delay Type-C mux switch while DP PHY is initializing
2026-08-24 11:28 ` [PATCH 1/4] phy: qcom: qmp-combo: delay Type-C mux switch while DP PHY is initializing Saurabh Anand
@ 2026-09-02 7:48 ` Manivannan Sadhasivam
2026-09-07 9:47 ` Saurabh Anand
2026-09-13 21:36 ` Dmitry Baryshkov
1 sibling, 1 reply; 14+ messages in thread
From: Manivannan Sadhasivam @ 2026-09-02 7:48 UTC (permalink / raw)
To: Saurabh Anand
Cc: Vinod Koul, Neil Armstrong, Rob Clark, Dmitry Baryshkov,
Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten,
David Airlie, Simona Vetter, linux-arm-msm, linux-phy,
linux-kernel, dri-devel, freedreno, Ritesh Kumar,
Vishnuvardhan Prodduturi, Mani Chandana Kuntumalla, Mahadevan P
On Mon, Aug 24, 2026 at 04:58:04PM +0530, Saurabh Anand wrote:
> The Type-C mux switch guard only checked dp_powered_on, which is set in
> qmp_combo_dp_power_on(). However there is a race window between
> qmp_combo_dp_init() and qmp_combo_dp_power_on() during which dp_init_count
> is non-zero but dp_powered_on is still false. A Type-C orientation change
> arriving in this window would proceed with the mux switch while the DP PHY
> is mid-initialization, corrupting the PHY state.
>
> Extend the guard to also block the mux switch when dp_init_count is
> non-zero, covering the full period from dp_init through dp_power_on.
>
> Signed-off-by: Saurabh Anand <saurabh.anand@oss.qualcomm.com>
If this patch fixes a race condition, it should have a Fixes tag.
- Mani
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 2/4] drm/msm/dp: clear force_link_train flag when link training succeeds
2026-08-24 13:17 ` Konrad Dybcio
@ 2026-09-07 9:35 ` Saurabh Anand
0 siblings, 0 replies; 14+ messages in thread
From: Saurabh Anand @ 2026-09-07 9:35 UTC (permalink / raw)
To: Konrad Dybcio, Vinod Koul, Neil Armstrong, Manivannan Sadhasivam,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, David Airlie, Simona Vetter
Cc: linux-arm-msm, linux-phy, linux-kernel, dri-devel, freedreno,
Ritesh Kumar, Vishnuvardhan Prodduturi, Mani Chandana Kuntumalla,
Mahadevan P
On 24-08-2026 18:47, Konrad Dybcio wrote:
> On 8/24/26 1:28 PM, Saurabh Anand wrote:
>> msm_dp_display_prepare_link() sets force_link_train = true before calling
>> msm_dp_ctrl_on_link(). On success the flag was never cleared, so
>> msm_dp_ctrl_prepare_stream_on() would unconditionally trigger a second
>> link retrain even though the link was already trained.
>>
>> Clear force_link_train on the success path so that
>> msm_dp_ctrl_prepare_stream_on() only retrains when the channel EQ check
>> fails, as intended.
>>
>> Signed-off-by: Saurabh Anand <saurabh.anand@oss.qualcomm.com>
>> ---
>> drivers/gpu/drm/msm/dp/dp_display.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
>> index bc646d172abe..40e19d506a45 100644
>> --- a/drivers/gpu/drm/msm/dp/dp_display.c
>> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
>> @@ -649,6 +649,8 @@ static int msm_dp_display_prepare_link(struct msm_dp_display_private *dp)
>> return rc;
>> }
>>
>> + force_link_train = false;
>> +
>> return msm_dp_ctrl_prepare_stream_on(dp->ctrl, dp->panel, force_link_train);
> This makes the argument of this function useless
Yes, agreed. I will update it in the next version.
>
> Konrad
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/4] drm/msm/dp: skip LTTPR init when no LTTPRs are present
2026-08-24 13:15 ` Konrad Dybcio
@ 2026-09-07 9:44 ` Saurabh Anand
2026-09-13 21:39 ` Dmitry Baryshkov
0 siblings, 1 reply; 14+ messages in thread
From: Saurabh Anand @ 2026-09-07 9:44 UTC (permalink / raw)
To: Konrad Dybcio, Vinod Koul, Neil Armstrong, Manivannan Sadhasivam,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, David Airlie, Simona Vetter
Cc: linux-arm-msm, linux-phy, linux-kernel, dri-devel, freedreno,
Ritesh Kumar, Vishnuvardhan Prodduturi, Mani Chandana Kuntumalla,
Mahadevan P
On 24-08-2026 18:45, Konrad Dybcio wrote:
> On 8/24/26 1:28 PM, Saurabh Anand wrote:
>> drm_dp_lttpr_count() returns 0 when no LTTPRs are detected and a
>> negative value on error. The previous code passed the result directly
>> to drm_dp_lttpr_init() without checking, which would call into the
>> LTTPR transparency-mode setup with a zero or negative repeater count.
>>
>> Add an early return for lttpr_count <= 0 to skip the init entirely
>> when there are no repeaters in the link, matching the expected usage
>> of drm_dp_lttpr_init().
> Reading the body of that function, I'm not sure your statement is true
drm_dp_lttpr_count() returns 0 when no LTTPRs are detected and a
negative error code when the LTTPR common capabilities report an invalid
or unsupported repeater count.
drm_dp_lttpr_init() already handles the zero-count case by returning
early. However, when passed a negative count, it still writes transparent
mode before returning -ENODEV.
I will update the commit message giving more details.
>
> Konrad
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/4] phy: qcom: qmp-combo: delay Type-C mux switch while DP PHY is initializing
2026-09-02 7:48 ` Manivannan Sadhasivam
@ 2026-09-07 9:47 ` Saurabh Anand
0 siblings, 0 replies; 14+ messages in thread
From: Saurabh Anand @ 2026-09-07 9:47 UTC (permalink / raw)
To: Manivannan Sadhasivam
Cc: Vinod Koul, Neil Armstrong, Rob Clark, Dmitry Baryshkov,
Abhinav Kumar, Jessica Zhang, Sean Paul, Marijn Suijten,
David Airlie, Simona Vetter, linux-arm-msm, linux-phy,
linux-kernel, dri-devel, freedreno, Ritesh Kumar,
Vishnuvardhan Prodduturi, Mani Chandana Kuntumalla, Mahadevan P
On 02-09-2026 13:18, Manivannan Sadhasivam wrote:
> On Mon, Aug 24, 2026 at 04:58:04PM +0530, Saurabh Anand wrote:
>> The Type-C mux switch guard only checked dp_powered_on, which is set in
>> qmp_combo_dp_power_on(). However there is a race window between
>> qmp_combo_dp_init() and qmp_combo_dp_power_on() during which dp_init_count
>> is non-zero but dp_powered_on is still false. A Type-C orientation change
>> arriving in this window would proceed with the mux switch while the DP PHY
>> is mid-initialization, corrupting the PHY state.
>>
>> Extend the guard to also block the mux switch when dp_init_count is
>> non-zero, covering the full period from dp_init through dp_power_on.
>>
>> Signed-off-by: Saurabh Anand <saurabh.anand@oss.qualcomm.com>
> If this patch fixes a race condition, it should have a Fixes tag.
Sure, will add in next version.
Fixes: 896277138c13 ("phy: qcom: qmp-combo: register a typec mux to
change the QMPPHY_MODE")
>
> - Mani
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/4] phy: qcom: qmp-combo: delay Type-C mux switch while DP PHY is initializing
2026-08-24 11:28 ` [PATCH 1/4] phy: qcom: qmp-combo: delay Type-C mux switch while DP PHY is initializing Saurabh Anand
2026-09-02 7:48 ` Manivannan Sadhasivam
@ 2026-09-13 21:36 ` Dmitry Baryshkov
1 sibling, 0 replies; 14+ messages in thread
From: Dmitry Baryshkov @ 2026-09-13 21:36 UTC (permalink / raw)
To: Saurabh Anand
Cc: Vinod Koul, Neil Armstrong, Manivannan Sadhasivam, Rob Clark,
Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
Marijn Suijten, David Airlie, Simona Vetter, linux-arm-msm,
linux-phy, linux-kernel, dri-devel, freedreno, Ritesh Kumar,
Vishnuvardhan Prodduturi, Mani Chandana Kuntumalla, Mahadevan P
On Mon, Aug 24, 2026 at 04:58:04PM +0530, Saurabh Anand wrote:
> The Type-C mux switch guard only checked dp_powered_on, which is set in
> qmp_combo_dp_power_on(). However there is a race window between
> qmp_combo_dp_init() and qmp_combo_dp_power_on() during which dp_init_count
> is non-zero but dp_powered_on is still false. A Type-C orientation change
> arriving in this window would proceed with the mux switch while the DP PHY
> is mid-initialization, corrupting the PHY state.
>
> Extend the guard to also block the mux switch when dp_init_count is
> non-zero, covering the full period from dp_init through dp_power_on.
>
> Signed-off-by: Saurabh Anand <saurabh.anand@oss.qualcomm.com>
> ---
> drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
If it's a race, it usually means you need a lock. Otherwise you can
still read the incorrect value of the variable.
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/4] drm/msm/dp: skip LTTPR init when no LTTPRs are present
2026-09-07 9:44 ` Saurabh Anand
@ 2026-09-13 21:39 ` Dmitry Baryshkov
0 siblings, 0 replies; 14+ messages in thread
From: Dmitry Baryshkov @ 2026-09-13 21:39 UTC (permalink / raw)
To: Saurabh Anand
Cc: Konrad Dybcio, Vinod Koul, Neil Armstrong, Manivannan Sadhasivam,
Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, David Airlie, Simona Vetter,
linux-arm-msm, linux-phy, linux-kernel, dri-devel, freedreno,
Ritesh Kumar, Vishnuvardhan Prodduturi, Mani Chandana Kuntumalla,
Mahadevan P
On Mon, Sep 07, 2026 at 03:14:33PM +0530, Saurabh Anand wrote:
>
> On 24-08-2026 18:45, Konrad Dybcio wrote:
> > On 8/24/26 1:28 PM, Saurabh Anand wrote:
> > > drm_dp_lttpr_count() returns 0 when no LTTPRs are detected and a
> > > negative value on error. The previous code passed the result directly
> > > to drm_dp_lttpr_init() without checking, which would call into the
> > > LTTPR transparency-mode setup with a zero or negative repeater count.
> > >
> > > Add an early return for lttpr_count <= 0 to skip the init entirely
> > > when there are no repeaters in the link, matching the expected usage
> > > of drm_dp_lttpr_init().
> > Reading the body of that function, I'm not sure your statement is true
>
> drm_dp_lttpr_count() returns 0 when no LTTPRs are detected and a
> negative error code when the LTTPR common capabilities report an invalid
> or unsupported repeater count.
>
> drm_dp_lttpr_init() already handles the zero-count case by returning
> early. However, when passed a negative count, it still writes transparent
> mode before returning -ENODEV.
And this is correct. If there are more than 8 LTTPRs, they must be
switched to the transparent mode as it's impossible to control them
individually.
>
> I will update the commit message giving more details.
>
> >
> > Konrad
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 4/4] drm/msm/dp: continue link training downgrade when cable is still plugged
2026-08-24 11:28 ` [PATCH 4/4] drm/msm/dp: continue link training downgrade when cable is still plugged Saurabh Anand
@ 2026-09-13 21:42 ` Dmitry Baryshkov
0 siblings, 0 replies; 14+ messages in thread
From: Dmitry Baryshkov @ 2026-09-13 21:42 UTC (permalink / raw)
To: Saurabh Anand
Cc: Vinod Koul, Neil Armstrong, Manivannan Sadhasivam, Rob Clark,
Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
Marijn Suijten, David Airlie, Simona Vetter, linux-arm-msm,
linux-phy, linux-kernel, dri-devel, freedreno, Ritesh Kumar,
Vishnuvardhan Prodduturi, Mani Chandana Kuntumalla, Mahadevan P
On Mon, Aug 24, 2026 at 04:58:07PM +0530, Saurabh Anand wrote:
> During a Type-C reconnect the AUX channel may report link-disconnected
> transiently while the physical cable is still present. The link training
> retry loop in msm_dp_ctrl_on_link() was aborting immediately on any
> msm_dp_aux_is_link_connected() failure, preventing the rate/lane downgrade
> path from running.
>
> When the display is known to be plugged (msm_dp_ctrl->plugged), an AUX
> link-disconnected status is likely a transient glitch rather than a true
> unplug. Allow the downgrade loop to continue in that case by requiring both
> conditions before breaking out of the retry loop: AUX reports disconnected
> and the display is not plugged.
A cable reconnect should follow the full procedure. DPRX may use long
HPD pulses to signal that DPTX should reconfigure the link according to
the changed status registers.
>
> The plugged state is snapshotted from dp_display into msm_dp_ctrl just
> before msm_dp_ctrl_on_link() is called, so the retry loop has an accurate
> view of cable presence at the time link training started.
>
> Signed-off-by: Saurabh Anand <saurabh.anand@oss.qualcomm.com>
> ---
> drivers/gpu/drm/msm/dp/dp_ctrl.c | 4 ++--
> drivers/gpu/drm/msm/dp/dp_ctrl.h | 1 +
> drivers/gpu/drm/msm/dp/dp_display.c | 1 +
> 3 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.c b/drivers/gpu/drm/msm/dp/dp_ctrl.c
> index 59070f399e2d..e8fd8f4c75fe 100644
> --- a/drivers/gpu/drm/msm/dp/dp_ctrl.c
> +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.c
> @@ -2379,7 +2379,7 @@ int msm_dp_ctrl_on_link(struct msm_dp_ctrl *msm_dp_ctrl,
> break;
> } else if (training_step == DP_TRAINING_1) {
> /* link train_1 failed */
> - if (!msm_dp_aux_is_link_connected(ctrl->aux))
> + if (!msm_dp_aux_is_link_connected(ctrl->aux) && !msm_dp_ctrl->plugged)
Locking?
> break;
>
> drm_dp_dpcd_read_link_status(ctrl->aux, link_status);
> @@ -2404,7 +2404,7 @@ int msm_dp_ctrl_on_link(struct msm_dp_ctrl *msm_dp_ctrl,
> }
> } else if (training_step == DP_TRAINING_2) {
> /* link train_2 failed */
> - if (!msm_dp_aux_is_link_connected(ctrl->aux))
> + if (!msm_dp_aux_is_link_connected(ctrl->aux) && !msm_dp_ctrl->plugged)
> break;
>
> drm_dp_dpcd_read_link_status(ctrl->aux, link_status);
> diff --git a/drivers/gpu/drm/msm/dp/dp_ctrl.h b/drivers/gpu/drm/msm/dp/dp_ctrl.h
> index 5902cf7e746a..95533b0b6297 100644
> --- a/drivers/gpu/drm/msm/dp/dp_ctrl.h
> +++ b/drivers/gpu/drm/msm/dp/dp_ctrl.h
> @@ -12,6 +12,7 @@
>
> struct msm_dp_ctrl {
> bool wide_bus_en;
> + bool plugged;
> };
>
> struct phy;
> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c
> index 1f60c78a463d..93a37a44273f 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -644,6 +644,7 @@ static int msm_dp_display_prepare_link(struct msm_dp_display_private *dp)
> if (!msm_dp_display->power_on) {
> msm_dp_display_host_phy_init(dp);
> force_link_train = true;
> + dp->ctrl->plugged = dp->plugged;
No, don't create copies of the fiels. They easily get out of sync.
> }
>
> rc = msm_dp_ctrl_on_link(dp->ctrl, dp->panel);
>
> --
> 2.34.1
>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-09-13 21:42 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-24 11:28 [PATCH 0/4] drm/msm/dp, phy: qcom: improve DP Type-C reconnect handling Saurabh Anand
2026-08-24 11:28 ` [PATCH 1/4] phy: qcom: qmp-combo: delay Type-C mux switch while DP PHY is initializing Saurabh Anand
2026-09-02 7:48 ` Manivannan Sadhasivam
2026-09-07 9:47 ` Saurabh Anand
2026-09-13 21:36 ` Dmitry Baryshkov
2026-08-24 11:28 ` [PATCH 2/4] drm/msm/dp: clear force_link_train flag when link training succeeds Saurabh Anand
2026-08-24 13:17 ` Konrad Dybcio
2026-09-07 9:35 ` Saurabh Anand
2026-08-24 11:28 ` [PATCH 3/4] drm/msm/dp: skip LTTPR init when no LTTPRs are present Saurabh Anand
2026-08-24 13:15 ` Konrad Dybcio
2026-09-07 9:44 ` Saurabh Anand
2026-09-13 21:39 ` Dmitry Baryshkov
2026-08-24 11:28 ` [PATCH 4/4] drm/msm/dp: continue link training downgrade when cable is still plugged Saurabh Anand
2026-09-13 21:42 ` Dmitry Baryshkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®