Skip to contentSkip to conversation

drm/dp: follow DP link CTS spec to read link status back

PATCH Superseded Lee Shawn C 3 participants 8 messages Jul 7, 2021 – Aug 19, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/dp: follow DP link CTS spec to read link status back

Refer to DP link CTS 1.2/1.4 spec, the following test case request source read DPCD 200h - 205h to get latest link status from sink.

(4.3.2.4) Handling of IRQ HPD Pulse with No Error Status Bits Set (400.3.2.1) Successful Link Re-training After IRQ HPD Pulse
Due to Loss of Symbol Lock: HBR2 Extension
(400.3.2.2) Successful Link Re-training After IRQ HPD Pulse Due
to Loss of Clock Recovery Lock: HBR2 Extension
(400.3.2.3) Successful Link Re-training After IRQ HPD Pulse Due
to Loss of Inter-lane Alignment Lock: HBR2 Extension

So far, DRM DP driver just read back the link status from 202h to 207h. DPR-120 would judge source can't pass these cases and shows below error messages.

"Test FAILED, Source DUT does not read DPCD registers 200h-205h within 100 ms".

Cc Jani Nikula <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Lyude Paul <[email protected]>
Cc Cooper Chiou <[email protected]>
Cc William Tseng <[email protected]>
---
 drivers/gpu/drm/drm_dp_helper.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_dp_helper.c +6 -4
index 24bbc710c825..2b4d1f498ce3 100644
@@ -410,17 +410,19 @@ int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux,
 				     u8 link_status[DP_LINK_STATUS_SIZE])
 {
 	int ret;
+	u8 full_link_stat[DP_LINK_STATUS_SIZE + 2];
 
 	if (dp_phy == DP_PHY_DPRX) {
 		ret = drm_dp_dpcd_read(aux,
-				       DP_LANE0_1_STATUS,
-				       link_status,
-				       DP_LINK_STATUS_SIZE);
+				       DP_SINK_COUNT,
+				       full_link_stat,
+				       DP_LINK_STATUS_SIZE + 2);
 
 		if (ret < 0)
 			return ret;
 
-		WARN_ON(ret != DP_LINK_STATUS_SIZE);
+		memcpy(link_status, full_link_stat + 2, DP_LINK_STATUS_SIZE);
+		WARN_ON(ret != DP_LINK_STATUS_SIZE + 2);
 
 		return 0;
 	}
Signature · 1 line
2.17.1
#1 lore raw

drivers/gpu/drm/drm_dp_helper.c int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux, · line 419

Quoted 1 line
drivers/gpu/drm/drm_dp_helper.c +1 -0
+				       DP_LINK_STATUS_SIZE + 2);

Suggestion: use sizeof(full_link_stat) here instead to avoid this getting out-of-sync with the real array size?

#2 lore raw
Quoted 4 lines · Simon Ser

drivers/gpu/drm/drm_dp_helper.c int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux, · line 419

Quoted 1 line
drivers/gpu/drm/drm_dp_helper.c +1 -0
+				       DP_LINK_STATUS_SIZE + 2);

Suggestion: use sizeof(full_link_stat) here instead to avoid this getting out-of-sync with the real array size?

I will update v2 patch later. Thanks for comment!

Best regards,
Shawn

#3 lore raw

PATCH v2 1/1 drm/dp: follow DP link CTS spec to read link status back

In reply to Lee Shawn C

Refer to DP link CTS 1.2/1.4 spec, the following test case request source read DPCD 200h - 205h to get latest link status from sink.

(4.3.2.4) Handling of IRQ HPD Pulse with No Error Status Bits Set (400.3.2.1) Successful Link Re-training After IRQ HPD Pulse
Due to Loss of Symbol Lock: HBR2 Extension
(400.3.2.2) Successful Link Re-training After IRQ HPD Pulse Due
to Loss of Clock Recovery Lock: HBR2 Extension
(400.3.2.3) Successful Link Re-training After IRQ HPD Pulse Due
to Loss of Inter-lane Alignment Lock: HBR2 Extension

So far, DRM DP driver just read back the link status from 202h to 207h. DPR-120 would judge source can't pass these cases and shows below error messages.

"Test FAILED, Source DUT does not read DPCD registers 200h-205h within 100 ms".

v2: Use sizeof() to retrieve array size.

Cc Jani Nikula <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Lyude Paul <[email protected]>
Cc Simon Ser <[email protected]>
Cc Cooper Chiou <[email protected]>
Cc William Tseng <[email protected]>
---
 drivers/gpu/drm/drm_dp_helper.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_dp_helper.c +6 -4
index 24bbc710c825..4f03df317d62 100644
@@ -410,17 +410,19 @@ int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux,
 				     u8 link_status[DP_LINK_STATUS_SIZE])
 {
 	int ret;
+	u8 full_link_stat[DP_LINK_STATUS_SIZE + 2];
 
 	if (dp_phy == DP_PHY_DPRX) {
 		ret = drm_dp_dpcd_read(aux,
-				       DP_LANE0_1_STATUS,
-				       link_status,
-				       DP_LINK_STATUS_SIZE);
+				       DP_SINK_COUNT,
+				       full_link_stat,
+				       sizeof(full_link_stat));
 
 		if (ret < 0)
 			return ret;
 
-		WARN_ON(ret != DP_LINK_STATUS_SIZE);
+		memcpy(link_status, full_link_stat + 2, DP_LINK_STATUS_SIZE);
+		WARN_ON(ret != DP_LINK_STATUS_SIZE + 2);
 
 		return 0;
 	}
Signature · 1 line
2.17.1
Acked-by on v2 1/1
#4 lore raw
Quoted 11 lines · Lee Shawn C

Refer to DP link CTS 1.2/1.4 spec, the following test case request source read DPCD 200h - 205h to get latest link status from sink.

(4.3.2.4) Handling of IRQ HPD Pulse with No Error Status Bits Set (400.3.2.1) Successful Link Re-training After IRQ HPD Pulse
Due to Loss of Symbol Lock: HBR2 Extension
(400.3.2.2) Successful Link Re-training After IRQ HPD Pulse Due
to Loss of Clock Recovery Lock: HBR2 Extension
(400.3.2.3) Successful Link Re-training After IRQ HPD Pulse Due
to Loss of Inter-lane Alignment Lock: HBR2 Extension

Quoted 6 lines

So far, DRM DP driver just read back the link status from 202h to 207h. DPR-120 would judge source can't pass these cases and shows below error messages.

"Test FAILED, Source DUT does not read DPCD registers 200h-205h within 100 ms".

for making the test pass iff everything else seems to work.

The underlying question is, though, should we look at 0x200-0x201 for some status we don't look at?

Quoted 42 lines

v2: Use sizeof() to retrieve array size.

Cc Jani Nikula <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Lyude Paul <[email protected]>
Cc Simon Ser <[email protected]>
Cc Cooper Chiou <[email protected]>
Cc William Tseng <[email protected]>
---
 drivers/gpu/drm/drm_dp_helper.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_dp_helper.c +6 -4
index 24bbc710c825..4f03df317d62 100644
@@ -410,17 +410,19 @@ int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux,
 				     u8 link_status[DP_LINK_STATUS_SIZE])
 {
 	int ret;
+	u8 full_link_stat[DP_LINK_STATUS_SIZE + 2];
 
 	if (dp_phy == DP_PHY_DPRX) {
 		ret = drm_dp_dpcd_read(aux,
-				       DP_LANE0_1_STATUS,
-				       link_status,
-				       DP_LINK_STATUS_SIZE);
+				       DP_SINK_COUNT,
+				       full_link_stat,
+				       sizeof(full_link_stat));
 
 		if (ret < 0)
 			return ret;
 
-		WARN_ON(ret != DP_LINK_STATUS_SIZE);
+		memcpy(link_status, full_link_stat + 2, DP_LINK_STATUS_SIZE);
+		WARN_ON(ret != DP_LINK_STATUS_SIZE + 2);
 
 		return 0;
 	}
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
#5 lore raw
Quoted 16 lines · Jani Nikula
Quoted 15 lines · Lee Shawn C

Refer to DP link CTS 1.2/1.4 spec, the following test case request source read DPCD 200h - 205h to get latest link status from sink.

(4.3.2.4) Handling of IRQ HPD Pulse with No Error Status Bits Set (400.3.2.1) Successful Link Re-training After IRQ HPD Pulse
Due to Loss of Symbol Lock: HBR2 Extension
(400.3.2.2) Successful Link Re-training After IRQ HPD Pulse Due
to Loss of Clock Recovery Lock: HBR2 Extension
(400.3.2.3) Successful Link Re-training After IRQ HPD Pulse Due
to Loss of Inter-lane Alignment Lock: HBR2 Extension

So far, DRM DP driver just read back the link status from 202h to 207h. DPR-120 would judge source can't pass these cases and shows below error messages.

Quoted 9 lines
Quoted 2 lines

"Test FAILED, Source DUT does not read DPCD registers 200h-205h within 100 ms".

for making the test pass iff everything else seems to work.

The underlying question is, though, should we look at 0x200-0x201 for some status we don't look at?

Look into 200h. While doing link train with DPRX. In my opinion, sink_count and cp_ready status should be constant. And sink would trigger HPD to source to notify 201h value was changed. Seems source driver don't need this value at link training stage as well. What do you think?

Best regards,
Shawn

Quoted 46 lines
Quoted 33 lines

v2: Use sizeof() to retrieve array size.

Cc Jani Nikula <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Lyude Paul <[email protected]>
Cc Simon Ser <[email protected]>
Cc Cooper Chiou <[email protected]>
Cc William Tseng <[email protected]>
---
 drivers/gpu/drm/drm_dp_helper.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_dp_helper.c index 24bbc710c825..4f03df317d62 100644

drivers/gpu/drm/drm_dp_helper.c +4 -3
@@ -410,17 +410,19 @@ int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux,
 				     u8 link_status[DP_LINK_STATUS_SIZE])  {
 	int ret;
+	u8 full_link_stat[DP_LINK_STATUS_SIZE + 2];
 
 	if (dp_phy == DP_PHY_DPRX) {
 		ret = drm_dp_dpcd_read(aux,
-				       DP_LANE0_1_STATUS,
-				       link_status,
-				       DP_LINK_STATUS_SIZE);
+				       DP_SINK_COUNT,
+				       full_link_stat,
+				       sizeof(full_link_stat));

drivers/gpu/drm/drm_dp_helper.c int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux, · line 427

Quoted 10 lines
drivers/gpu/drm/drm_dp_helper.c +2 -1
 
 		if (ret < 0)
 			return ret;
 
-		WARN_ON(ret != DP_LINK_STATUS_SIZE);
+		memcpy(link_status, full_link_stat + 2, DP_LINK_STATUS_SIZE);
+		WARN_ON(ret != DP_LINK_STATUS_SIZE + 2);
 
 		return 0;
 	}

--
Jani Nikula, Intel Open Source Graphics Center

#6 lore raw
Quoted 25 lines · Lee Shawn C
Quoted 24 lines · Jani Nikula
Quoted 11 lines · Lee Shawn C

Refer to DP link CTS 1.2/1.4 spec, the following test case request source read DPCD 200h - 205h to get latest link status from sink.

(4.3.2.4) Handling of IRQ HPD Pulse with No Error Status Bits Set (400.3.2.1) Successful Link Re-training After IRQ HPD Pulse
Due to Loss of Symbol Lock: HBR2 Extension
(400.3.2.2) Successful Link Re-training After IRQ HPD Pulse Due
to Loss of Clock Recovery Lock: HBR2 Extension
(400.3.2.3) Successful Link Re-training After IRQ HPD Pulse Due
to Loss of Inter-lane Alignment Lock: HBR2 Extension

Quoted 7 lines

So far, DRM DP driver just read back the link status from 202h to 207h. DPR-120 would judge source can't pass these cases and shows below error messages.

"Test FAILED, Source DUT does not read DPCD registers 200h-205h within
100 ms".

for making the test pass iff everything else seems to work.

Quoted 9 lines
Quoted 2 lines

The underlying question is, though, should we look at 0x200-0x201 for some status we don't look at?

Look into 200h. While doing link train with DPRX. In my opinion, sink_count and cp_ready status should be constant.
And sink would trigger HPD to source to notify 201h value was changed. Seems source driver don't need this value at link training stage as well. What do you think?

Best regards,
Shawn

Hi Simon and all,

Please share your recommendations for this patch to pass DP link layer compliance test. Thanks!

Best regards,
Shawn

Quoted 47 lines
Quoted 46 lines
Quoted 33 lines

v2: Use sizeof() to retrieve array size.

Cc Jani Nikula <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Lyude Paul <[email protected]>
Cc Simon Ser <[email protected]>
Cc Cooper Chiou <[email protected]>
Cc William Tseng <[email protected]>
---
 drivers/gpu/drm/drm_dp_helper.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_dp_helper.c index 24bbc710c825..4f03df317d62 100644

drivers/gpu/drm/drm_dp_helper.c +4 -3
@@ -410,17 +410,19 @@ int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux,
 				     u8 link_status[DP_LINK_STATUS_SIZE])  {
 	int ret;
+	u8 full_link_stat[DP_LINK_STATUS_SIZE + 2];
 
 	if (dp_phy == DP_PHY_DPRX) {
 		ret = drm_dp_dpcd_read(aux,
-				       DP_LANE0_1_STATUS,
-				       link_status,
-				       DP_LINK_STATUS_SIZE);
+				       DP_SINK_COUNT,
+				       full_link_stat,
+				       sizeof(full_link_stat));

drivers/gpu/drm/drm_dp_helper.c int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux, · line 427

Quoted 10 lines
drivers/gpu/drm/drm_dp_helper.c +2 -1
 
 		if (ret < 0)
 			return ret;
 
-		WARN_ON(ret != DP_LINK_STATUS_SIZE);
+		memcpy(link_status, full_link_stat + 2, DP_LINK_STATUS_SIZE);
+		WARN_ON(ret != DP_LINK_STATUS_SIZE + 2);
 
 		return 0;
 	}

--
Jani Nikula, Intel Open Source Graphics Center

#7 lore raw
Quoted 25 lines · Lee Shawn C
Quoted 24 lines · Jani Nikula
Quoted 11 lines · Lee Shawn C

Refer to DP link CTS 1.2/1.4 spec, the following test case request source read DPCD 200h - 205h to get latest link status from sink.

(4.3.2.4) Handling of IRQ HPD Pulse with No Error Status Bits Set (400.3.2.1) Successful Link Re-training After IRQ HPD Pulse
Due to Loss of Symbol Lock: HBR2 Extension
(400.3.2.2) Successful Link Re-training After IRQ HPD Pulse Due
to Loss of Clock Recovery Lock: HBR2 Extension
(400.3.2.3) Successful Link Re-training After IRQ HPD Pulse Due
to Loss of Inter-lane Alignment Lock: HBR2 Extension

Quoted 7 lines

So far, DRM DP driver just read back the link status from 202h to 207h. DPR-120 would judge source can't pass these cases and shows below error messages.

"Test FAILED, Source DUT does not read DPCD registers 200h-205h within
100 ms".

for making the test pass iff everything else seems to work.

Quoted 9 lines
Quoted 2 lines

The underlying question is, though, should we look at 0x200-0x201 for some status we don't look at?

Look into 200h. While doing link train with DPRX. In my opinion, sink_count and cp_ready status should be constant.
And sink would trigger HPD to source to notify 201h value was changed. Seems source driver don't need this value at link training stage as well. What do you think?

Best regards,
Shawn

Hi Simon and all,

Please share your recommendations for this patch to pass DP link layer compliance test. Thanks!

Best regards,
Shawn

Quoted 47 lines
Quoted 46 lines
Quoted 33 lines

v2: Use sizeof() to retrieve array size.

Cc Jani Nikula <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Lyude Paul <[email protected]>
Cc Simon Ser <[email protected]>
Cc Cooper Chiou <[email protected]>
Cc William Tseng <[email protected]>
---
 drivers/gpu/drm/drm_dp_helper.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_dp_helper.c index 24bbc710c825..4f03df317d62 100644

drivers/gpu/drm/drm_dp_helper.c +4 -3
@@ -410,17 +410,19 @@ int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux,
 				     u8 link_status[DP_LINK_STATUS_SIZE])  {
 	int ret;
+	u8 full_link_stat[DP_LINK_STATUS_SIZE + 2];
 
 	if (dp_phy == DP_PHY_DPRX) {
 		ret = drm_dp_dpcd_read(aux,
-				       DP_LANE0_1_STATUS,
-				       link_status,
-				       DP_LINK_STATUS_SIZE);
+				       DP_SINK_COUNT,
+				       full_link_stat,
+				       sizeof(full_link_stat));

drivers/gpu/drm/drm_dp_helper.c int drm_dp_dpcd_read_phy_link_status(struct drm_dp_aux *aux, · line 427

Quoted 10 lines
drivers/gpu/drm/drm_dp_helper.c +2 -1
 
 		if (ret < 0)
 			return ret;
 
-		WARN_ON(ret != DP_LINK_STATUS_SIZE);
+		memcpy(link_status, full_link_stat + 2, DP_LINK_STATUS_SIZE);
+		WARN_ON(ret != DP_LINK_STATUS_SIZE + 2);
 
 		return 0;
 	}

--
Jani Nikula, Intel Open Source Graphics Center