Skip to contentSkip to conversation

drm/radeon/dp: check for errors in dpcd reads

PATCH Applied Alex Deucher 4 participants 4 messages Apr 30, 2014 – May 5, 2014

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

PATCH 1/1 drm/radeon/dp: check for errors in dpcd reads

Check to make sure the transaction succeeded before using the register value. Fixes occasional link training problems.

---
 drivers/gpu/drm/radeon/atombios_dp.c | 44 ++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 19 deletions(-)
drivers/gpu/drm/radeon/atombios_dp.c +25 -19
index bc0119f..54e4f52 100644
@@ -366,11 +366,11 @@ static void radeon_dp_probe_oui(struct radeon_connector *radeon_connector)
 	if (!(dig_connector->dpcd[DP_DOWN_STREAM_PORT_COUNT] & DP_OUI_SUPPORT))
 		return;
 
-	if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_SINK_OUI, buf, 3))
+	if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_SINK_OUI, buf, 3) == 3)
 		DRM_DEBUG_KMS("Sink OUI: %02hx%02hx%02hx\n",
 			      buf[0], buf[1], buf[2]);
 
-	if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_BRANCH_OUI, buf, 3))
+	if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_BRANCH_OUI, buf, 3) == 3)
 		DRM_DEBUG_KMS("Branch OUI: %02hx%02hx%02hx\n",
 			      buf[0], buf[1], buf[2]);
 }
@@ -419,21 +419,23 @@ int radeon_dp_get_panel_mode(struct drm_encoder *encoder,
 
 	if (dp_bridge != ENCODER_OBJECT_ID_NONE) {
 		/* DP bridge chips */
-		drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
-				  DP_EDP_CONFIGURATION_CAP, &tmp);
-		if (tmp & 1)
-			panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
-		else if ((dp_bridge == ENCODER_OBJECT_ID_NUTMEG) ||
-			 (dp_bridge == ENCODER_OBJECT_ID_TRAVIS))
-			panel_mode = DP_PANEL_MODE_INTERNAL_DP1_MODE;
-		else
-			panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE;
+		if (drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
+				      DP_EDP_CONFIGURATION_CAP, &tmp) == 1) {
+			if (tmp & 1)
+				panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
+			else if ((dp_bridge == ENCODER_OBJECT_ID_NUTMEG) ||
+				 (dp_bridge == ENCODER_OBJECT_ID_TRAVIS))
+				panel_mode = DP_PANEL_MODE_INTERNAL_DP1_MODE;
+			else
+				panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE;
+		}
 	} else if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
 		/* eDP */
-		drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
-				  DP_EDP_CONFIGURATION_CAP, &tmp);
-		if (tmp & 1)
-			panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
+		if (drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
+				      DP_EDP_CONFIGURATION_CAP, &tmp) == 1) {
+			if (tmp & 1)
+				panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
+		}
 	}
 
 	return panel_mode;
@@ -809,11 +811,15 @@ void radeon_dp_link_train(struct drm_encoder *encoder,
 	else
 		dp_info.enc_id |= ATOM_DP_CONFIG_LINK_A;
 
-	drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux, DP_MAX_LANE_COUNT, &tmp);
-	if (ASIC_IS_DCE5(rdev) && (tmp & DP_TPS3_SUPPORTED))
-		dp_info.tp3_supported = true;
-	else
+	if (drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux, DP_MAX_LANE_COUNT, &tmp)
+	    == 1) {
+		if (ASIC_IS_DCE5(rdev) && (tmp & DP_TPS3_SUPPORTED))
+			dp_info.tp3_supported = true;
+		else
+			dp_info.tp3_supported = false;
+	} else {
 		dp_info.tp3_supported = false;
+	}
 
 	memcpy(dp_info.dpcd, dig_connector->dpcd, DP_RECEIVER_CAP_SIZE);
 	dp_info.rdev = rdev;
Signature · 1 line
1.8.3.1
#1 lore raw

Am 30.04.2014 15:27, schrieb Alex Deucher:

Quoted 6 lines

Check to make sure the transaction succeeded before using the register value. Fixes occasional link training problems.

Applied to my 3.15 queue.

Christian.

Quoted 79 lines
---
  drivers/gpu/drm/radeon/atombios_dp.c | 44 ++++++++++++++++++++----------------
  1 file changed, 25 insertions(+), 19 deletions(-)
drivers/gpu/drm/radeon/atombios_dp.c +25 -19
index bc0119f..54e4f52 100644
@@ -366,11 +366,11 @@ static void radeon_dp_probe_oui(struct radeon_connector *radeon_connector)
  	if (!(dig_connector->dpcd[DP_DOWN_STREAM_PORT_COUNT] & DP_OUI_SUPPORT))
  		return;
 
-	if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_SINK_OUI, buf, 3))
+	if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_SINK_OUI, buf, 3) == 3)
  		DRM_DEBUG_KMS("Sink OUI: %02hx%02hx%02hx\n",
  			      buf[0], buf[1], buf[2]);
 
-	if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_BRANCH_OUI, buf, 3))
+	if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_BRANCH_OUI, buf, 3) == 3)
  		DRM_DEBUG_KMS("Branch OUI: %02hx%02hx%02hx\n",
  			      buf[0], buf[1], buf[2]);
  }
@@ -419,21 +419,23 @@ int radeon_dp_get_panel_mode(struct drm_encoder *encoder,
 
  	if (dp_bridge != ENCODER_OBJECT_ID_NONE) {
  		/* DP bridge chips */
-		drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
-				  DP_EDP_CONFIGURATION_CAP, &tmp);
-		if (tmp & 1)
-			panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
-		else if ((dp_bridge == ENCODER_OBJECT_ID_NUTMEG) ||
-			 (dp_bridge == ENCODER_OBJECT_ID_TRAVIS))
-			panel_mode = DP_PANEL_MODE_INTERNAL_DP1_MODE;
-		else
-			panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE;
+		if (drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
+				      DP_EDP_CONFIGURATION_CAP, &tmp) == 1) {
+			if (tmp & 1)
+				panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
+			else if ((dp_bridge == ENCODER_OBJECT_ID_NUTMEG) ||
+				 (dp_bridge == ENCODER_OBJECT_ID_TRAVIS))
+				panel_mode = DP_PANEL_MODE_INTERNAL_DP1_MODE;
+			else
+				panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE;
+		}
  	} else if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
  		/* eDP */
-		drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
-				  DP_EDP_CONFIGURATION_CAP, &tmp);
-		if (tmp & 1)
-			panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
+		if (drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
+				      DP_EDP_CONFIGURATION_CAP, &tmp) == 1) {
+			if (tmp & 1)
+				panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
+		}
  	}
 
  	return panel_mode;
@@ -809,11 +811,15 @@ void radeon_dp_link_train(struct drm_encoder *encoder,
  	else
  		dp_info.enc_id |= ATOM_DP_CONFIG_LINK_A;
 
-	drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux, DP_MAX_LANE_COUNT, &tmp);
-	if (ASIC_IS_DCE5(rdev) && (tmp & DP_TPS3_SUPPORTED))
-		dp_info.tp3_supported = true;
-	else
+	if (drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux, DP_MAX_LANE_COUNT, &tmp)
+	    == 1) {
+		if (ASIC_IS_DCE5(rdev) && (tmp & DP_TPS3_SUPPORTED))
+			dp_info.tp3_supported = true;
+		else
+			dp_info.tp3_supported = false;
+	} else {
  		dp_info.tp3_supported = false;
+	}
 
  	memcpy(dp_info.dpcd, dig_connector->dpcd, DP_RECEIVER_CAP_SIZE);
  	dp_info.rdev = rdev;
#2 lore raw
Quoted 9 lines

Am 30.04.2014 um 15:58 schrieb Christian König <[email protected]>:

Am 30.04.2014 15:27, schrieb Alex Deucher:

Quoted 4 lines

Check to make sure the transaction succeeded before using the register value. Fixes occasional link training problems.

Quoted 6 lines
Quoted 2 lines

Applied to my 3.15 queue.

Christian.

Why is not this patch still in Linus' tree? I looked forward to seeing it in 3.15-rc4 but it is not there.

Quoted 66 lines
Quoted 66 lines
---
 drivers/gpu/drm/radeon/atombios_dp.c | 44 ++++++++++++++++++++----------------
 1 file changed, 25 insertions(+), 19 deletions(-)
drivers/gpu/drm/radeon/atombios_dp.c +20 -16
index bc0119f..54e4f52 100644
@@ -366,11 +366,11 @@ static void radeon_dp_probe_oui(struct radeon_connector *radeon_connector)
     if (!(dig_connector->dpcd[DP_DOWN_STREAM_PORT_COUNT] & DP_OUI_SUPPORT))
         return;
 -    if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_SINK_OUI, buf, 3))
+    if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_SINK_OUI, buf, 3) == 3)
         DRM_DEBUG_KMS("Sink OUI: %02hx%02hx%02hx\n",
                   buf[0], buf[1], buf[2]);
 -    if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_BRANCH_OUI, buf, 3))
+    if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_BRANCH_OUI, buf, 3) == 3)
         DRM_DEBUG_KMS("Branch OUI: %02hx%02hx%02hx\n",
                   buf[0], buf[1], buf[2]);
 }
@@ -419,21 +419,23 @@ int radeon_dp_get_panel_mode(struct drm_encoder *encoder,
       if (dp_bridge != ENCODER_OBJECT_ID_NONE) {
         /* DP bridge chips */
-        drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
-                  DP_EDP_CONFIGURATION_CAP, &tmp);
-        if (tmp & 1)
-            panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
-        else if ((dp_bridge == ENCODER_OBJECT_ID_NUTMEG) ||
-             (dp_bridge == ENCODER_OBJECT_ID_TRAVIS))
-            panel_mode = DP_PANEL_MODE_INTERNAL_DP1_MODE;
-        else
-            panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE;
+        if (drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
+                      DP_EDP_CONFIGURATION_CAP, &tmp) == 1) {
+            if (tmp & 1)
+                panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
+            else if ((dp_bridge == ENCODER_OBJECT_ID_NUTMEG) ||
+                 (dp_bridge == ENCODER_OBJECT_ID_TRAVIS))
+                panel_mode = DP_PANEL_MODE_INTERNAL_DP1_MODE;
+            else
+                panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE;
+        }
     } else if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
         /* eDP */
-        drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
-                  DP_EDP_CONFIGURATION_CAP, &tmp);
-        if (tmp & 1)
-            panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
+        if (drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
+                      DP_EDP_CONFIGURATION_CAP, &tmp) == 1) {
+            if (tmp & 1)
+                panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
+        }
     }
       return panel_mode;
@@ -809,11 +811,15 @@ void radeon_dp_link_train(struct drm_encoder *encoder,
     else
         dp_info.enc_id |= ATOM_DP_CONFIG_LINK_A;
 -    drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux, DP_MAX_LANE_COUNT, &tmp);
-    if (ASIC_IS_DCE5(rdev) && (tmp & DP_TPS3_SUPPORTED))
-        dp_info.tp3_supported = true;
-    else
+    if (drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux, DP_MAX_LANE_COUNT, &tmp)
+        == 1) {
+        if (ASIC_IS_DCE5(rdev) && (tmp & DP_TPS3_SUPPORTED))
Quoted 9 lines

drivers/gpu/drm/radeon/atombios_dp.c void radeon_dp_link_train(struct drm_encoder *encoder, · line 825

Quoted 8 lines
drivers/gpu/drm/radeon/atombios_dp.c +5 -0
+            dp_info.tp3_supported = true;
+        else
+            dp_info.tp3_supported = false;
+    } else {
         dp_info.tp3_supported = false;
+    }
       memcpy(dp_info.dpcd, dig_connector->dpcd, DP_RECEIVER_CAP_SIZE);
     dp_info.rdev = rdev;

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
Quoted 20 lines

-----Original Message-----
From: Sergei Antonov [mailto:[email protected]]
Sent: Monday, May 05, 2014 4:55 PM
To: Christian König
Cc: Alex Deucher; [email protected]; Deucher, Alexander
Subject: Re: [PATCH] drm/radeon/dp: check for errors in dpcd reads

Quoted 1 line

Am 30.04.2014 um 15:58 schrieb Christian König

<[email protected]>:

Quoted 9 lines

Am 30.04.2014 15:27, schrieb Alex Deucher:

Quoted 6 lines

Check to make sure the transaction succeeded before using the register value. Fixes occasional link training problems.

Quoted 6 lines
Quoted 3 lines

Applied to my 3.15 queue.

Christian.

Why is not this patch still in Linus' tree? I looked forward to seeing it in 3.15- rc4 but it is not there.

It hasn't been pulled into Dave's tree yet. It should show up in his next pull request to Linus this week.

Alex

Quoted 87 lines
Quoted 4 lines
Quoted 4 lines

---
 drivers/gpu/drm/radeon/atombios_dp.c | 44 ++++++++++++++++++++-

---------------

Quoted 3 lines

Review

Quoted 3 lines
 1 file changed, 25 insertions(+), 19 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/radeon/atombios_dp.c

Quoted 4 lines

drivers/gpu/drm/radeon/atombios_dp.c static void radeon_dp_probe_oui(struct

Quoted 4 lines

index bc0119f..54e4f52 100644

drivers/gpu/drm/radeon/atombios_dp.c +0 -0
@@ -366,11 +366,11 @@ static void radeon_dp_probe_oui(struct

radeon_connector *radeon_connector)

Quoted 1 line

drivers/gpu/drm/radeon/atombios_dp.c static void radeon_dp_probe_oui(struct · line 366

Quoted 1 line
drivers/gpu/drm/radeon/atombios_dp.c +0 -0
     if (!(dig_connector->dpcd[DP_DOWN_STREAM_PORT_COUNT] &

DP_OUI_SUPPORT))

Quoted 2 lines

drivers/gpu/drm/radeon/atombios_dp.c static void radeon_dp_probe_oui(struct · line 368

Quoted 2 lines
drivers/gpu/drm/radeon/atombios_dp.c +0 -0
         return;
 -    if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux,

DP_SINK_OUI, buf, 3))

Quoted 1 line

drivers/gpu/drm/radeon/atombios_dp.c static void radeon_dp_probe_oui(struct · line 369

Quoted 1 line
drivers/gpu/drm/radeon/atombios_dp.c +1 -0
+    if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux,

DP_SINK_OUI, buf, 3) == 3)

Quoted 3 lines

drivers/gpu/drm/radeon/atombios_dp.c static void radeon_dp_probe_oui(struct radeon_connector *radeon_connector)

Quoted 3 lines
drivers/gpu/drm/radeon/atombios_dp.c +0 -0
         DRM_DEBUG_KMS("Sink OUI: %02hx%02hx%02hx\n",
                   buf[0], buf[1], buf[2]);
 -    if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux,

DP_BRANCH_OUI, buf, 3))

Quoted 1 line

drivers/gpu/drm/radeon/atombios_dp.c static void radeon_dp_probe_oui(struct · line 373

Quoted 1 line
drivers/gpu/drm/radeon/atombios_dp.c +1 -0
+    if (drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux,

DP_BRANCH_OUI, buf, 3) == 3)

Quoted 4 lines

drivers/gpu/drm/radeon/atombios_dp.c int radeon_dp_get_panel_mode(struct

Quoted 4 lines
drivers/gpu/drm/radeon/atombios_dp.c +0 -0
         DRM_DEBUG_KMS("Branch OUI: %02hx%02hx%02hx\n",
                   buf[0], buf[1], buf[2]);
 }
@@ -419,21 +419,23 @@ int radeon_dp_get_panel_mode(struct

drm_encoder *encoder,

Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/radeon/atombios_dp.c +3 -9
       if (dp_bridge != ENCODER_OBJECT_ID_NONE) {
         /* DP bridge chips */
-        drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
-                  DP_EDP_CONFIGURATION_CAP, &tmp);
-        if (tmp & 1)
-            panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
-        else if ((dp_bridge == ENCODER_OBJECT_ID_NUTMEG) ||
-             (dp_bridge == ENCODER_OBJECT_ID_TRAVIS))
-            panel_mode = DP_PANEL_MODE_INTERNAL_DP1_MODE;
-        else
-            panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE;
+        if (drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
+                      DP_EDP_CONFIGURATION_CAP, &tmp) == 1) {
+            if (tmp & 1)
Quoted 8 lines

drivers/gpu/drm/radeon/atombios_dp.c int radeon_dp_get_panel_mode(struct drm_encoder *encoder,

Quoted 8 lines
drivers/gpu/drm/radeon/atombios_dp.c +7 -0
+                panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
+            else if ((dp_bridge == ENCODER_OBJECT_ID_NUTMEG) ||
+                 (dp_bridge == ENCODER_OBJECT_ID_TRAVIS))
+                panel_mode = DP_PANEL_MODE_INTERNAL_DP1_MODE;
+            else
+                panel_mode = DP_PANEL_MODE_EXTERNAL_DP_MODE;
+        }
     } else if (connector->connector_type ==

DRM_MODE_CONNECTOR_eDP) {

Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/radeon/atombios_dp.c +0 -4
         /* eDP */
-        drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
-                  DP_EDP_CONFIGURATION_CAP, &tmp);
-        if (tmp & 1)
-            panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
Quoted 8 lines

drivers/gpu/drm/radeon/atombios_dp.c void radeon_dp_link_train(struct drm_encoder

Quoted 8 lines
drivers/gpu/drm/radeon/atombios_dp.c +5 -0
+        if (drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,
+                      DP_EDP_CONFIGURATION_CAP, &tmp) == 1) {
+            if (tmp & 1)
+                panel_mode = DP_PANEL_MODE_INTERNAL_DP2_MODE;
+        }
     }
       return panel_mode;
@@ -809,11 +811,15 @@ void radeon_dp_link_train(struct drm_encoder

*encoder,

Quoted 3 lines

drivers/gpu/drm/radeon/atombios_dp.c void radeon_dp_link_train(struct drm_encoder *encoder,

Quoted 3 lines
drivers/gpu/drm/radeon/atombios_dp.c +0 -0
     else
         dp_info.enc_id |= ATOM_DP_CONFIG_LINK_A;
 -    drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,

DP_MAX_LANE_COUNT, &tmp);

Quoted 4 lines

drivers/gpu/drm/radeon/atombios_dp.c void radeon_dp_link_train(struct drm_encoder *encoder,

Quoted 4 lines
drivers/gpu/drm/radeon/atombios_dp.c +1 -3
-    if (ASIC_IS_DCE5(rdev) && (tmp & DP_TPS3_SUPPORTED))
-        dp_info.tp3_supported = true;
-    else
+    if (drm_dp_dpcd_readb(&radeon_connector->ddc_bus->aux,

DP_MAX_LANE_COUNT, &tmp)

Quoted 9 lines

drivers/gpu/drm/radeon/atombios_dp.c void radeon_dp_link_train(struct drm_encoder *encoder,

Quoted 9 lines
drivers/gpu/drm/radeon/atombios_dp.c +7 -0
+        == 1) {
+        if (ASIC_IS_DCE5(rdev) && (tmp & DP_TPS3_SUPPORTED))
+            dp_info.tp3_supported = true;
+        else
+            dp_info.tp3_supported = false;
+    } else {
         dp_info.tp3_supported = false;
+    }
       memcpy(dp_info.dpcd, dig_connector->dpcd,
Quoted 3 lines

DP_RECEIVER_CAP_SIZE);

Quoted 2 lines
Quoted 1 line
drivers/gpu/drm/radeon/atombios_dp.c +0 -0
     dp_info.rdev = rdev;

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel