[PATCH] drm/display/drm_dp_dual_mode_helper: added retry on lspcon write on mode change

Dnyaneshwar dnyaneshwar.bhadane at intel.com
Mon Feb 6 12:29:41 UTC 2023


On LSPCON issue with PARADE chip, Added retry on LSPCON mode change and 
read it to verify. Added drm debug logs to check the read and write 
values on failure case.

Signed-off-by: Dnyaneshwar Bhadane <dnyaneshwar.bhadane at intel.com>

---
 .../gpu/drm/display/drm_dp_dual_mode_helper.c | 48 ++++++++++++++++++-
 1 file changed, 46 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/display/drm_dp_dual_mode_helper.c b/drivers/gpu/drm/display/drm_dp_dual_mode_helper.c
index bd61e20770a5..4864b82d53d2 100644
--- a/drivers/gpu/drm/display/drm_dp_dual_mode_helper.c
+++ b/drivers/gpu/drm/display/drm_dp_dual_mode_helper.c
@@ -497,10 +497,54 @@ int drm_lspcon_set_mode(const struct drm_device *dev, struct i2c_adapter *adapte
 	int ret;
 	int time_out = 200;
 	enum drm_lspcon_mode current_mode;
-
+	int retry = 0; 
 	if (mode == DRM_LSPCON_MODE_PCON)
 		data = DP_DUAL_MODE_LSPCON_MODE_PCON;
-
+	// Checking for machanism to make sure we have updated the mode.
+	while(time_out) {
+		enum drm_lspcon_mode tmp_mode = DRM_LSPCON_MODE_INVALID;
+		u8 tmp; 
+		ret = drm_dp_dual_mode_write(adapter, 
+						DP_DUAL_MODE_LSPCON_MODE_CHANGE,
+					    &data, sizeof(data));
+		if (ret) {
+			drm_dbg_kms(dev, "LSPCON, Failed to write %d buffers (%d attempts)\n", 
+					data, retry + 1);
+			return ret;
+		}
+		ret = drm_lspcon_get_mode(dev, adapter, &tmp_mode);
+		if (ret) {
+			drm_err(dev, "LSPCON, can't get mode confirm LSPCON mode change\n");
+			return ret;
+		}
+		ret = drm_dp_dual_mode_read(adapter,DP_DUAL_MODE_LSPCON_CURRENT_MODE,
+					    &tmp, sizeof(tmp));
+		if (ret) {
+			drm_dbg_kms(dev,
+				    "LSPCON, I2C read failed during  %d (%d attempts)\n",
+				    data, retry + 1);
+			return ret;
+		}
+		
+		if (tmp_mode == mode){
+			drm_dbg_kms(dev, "LSPCON, From retrial  Mode changed to %s (%d attempts)\n",
+				mode == DRM_LSPCON_MODE_LS ? "LS" : "PCON", retry + 1);
+			return ret;
+		}
+		drm_dbg_kms(dev, "LSPCON, Written : %d, and Read: %d (%d attempts)\n", 
+					data, tmp, retry + 1 );	
+		drm_dbg_kms(dev, "LSPCON, Still not matched  %d != %d (%d attempts) \n",
+					tmp_mode, mode, retry + 1 );	
+		drm_dbg_kms(dev, "LSPCON, Trying to change mode from  %s to %s (%d attempts) \n",
+					mode == DRM_LSPCON_MODE_LS ? "LS" : "PCON" ,
+					tmp_mode == DRM_LSPCON_MODE_LS ? "LS" : "PCON",
+					retry + 1 );	
+		msleep(10);
+		time_out -= 10;
+		retry++;
+	}
+	/*If failed, One more try with existing legacy flow*/
+	time_out = 200;
 	/* Change mode */
 	ret = drm_dp_dual_mode_write(adapter, DP_DUAL_MODE_LSPCON_MODE_CHANGE,
 				     &data, sizeof(data));
-- 
2.35.1



More information about the Intel-gfx-trybot mailing list