diff mbox

[1/2] drm: Add retries for dp dual mode read

Message ID 1503418301-21942-2-git-send-email-shashank.sharma@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sharma, Shashank Aug. 22, 2017, 4:11 p.m. UTC
From the CI builds, its been observed that during a driver
reload/insert, dp dual mode read function sometimes fails to
read from dual mode devices (like LSPCON) over i2c-over-aux
channel.

This patch:
- adds some delay and few retries, allowing a scope for these
  devices to settle down and respond.
- changes one error log's level from ERROR->DEBUG as we want
  to call it an error only after all the retries are exhausted.

Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
---
 drivers/gpu/drm/drm_dp_dual_mode_helper.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Jani Nikula Aug. 23, 2017, 11:59 a.m. UTC | #1
On Tue, 22 Aug 2017, Shashank Sharma <shashank.sharma@intel.com> wrote:
> From the CI builds, its been observed that during a driver
> reload/insert, dp dual mode read function sometimes fails to
> read from dual mode devices (like LSPCON) over i2c-over-aux
> channel.
>
> This patch:
> - adds some delay and few retries, allowing a scope for these
>   devices to settle down and respond.
> - changes one error log's level from ERROR->DEBUG as we want
>   to call it an error only after all the retries are exhausted.
>
> Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Imre Deak <imre.deak@intel.com>
> Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
> ---
>  drivers/gpu/drm/drm_dp_dual_mode_helper.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_dp_dual_mode_helper.c b/drivers/gpu/drm/drm_dp_dual_mode_helper.c
> index 80e62f6..13f67a36 100644
> --- a/drivers/gpu/drm/drm_dp_dual_mode_helper.c
> +++ b/drivers/gpu/drm/drm_dp_dual_mode_helper.c
> @@ -75,8 +75,15 @@ ssize_t drm_dp_dual_mode_read(struct i2c_adapter *adapter,
>  		},
>  	};
>  	int ret;
> +	int retry;
> +
> +	for (retry = 5; ; ) {

As I said, I think the paradigm for loop (i = 0; i < N; i++) is always
more obvious and faster for humans to parse.

BR,
Jani.

> +		ret = i2c_transfer(adapter, msgs, ARRAY_SIZE(msgs));
> +		if (ret > 0 || !retry--)
> +			break;
> +		usleep_range(500, 1000);
> +	}
>  
> -	ret = i2c_transfer(adapter, msgs, ARRAY_SIZE(msgs));
>  	if (ret < 0)
>  		return ret;
>  	if (ret != ARRAY_SIZE(msgs))
> @@ -420,7 +427,7 @@ int drm_lspcon_get_mode(struct i2c_adapter *adapter,
>  	ret = drm_dp_dual_mode_read(adapter, DP_DUAL_MODE_LSPCON_CURRENT_MODE,
>  				    &data, sizeof(data));
>  	if (ret < 0) {
> -		DRM_ERROR("LSPCON read(0x80, 0x41) failed\n");
> +		DRM_DEBUG_KMS("LSPCON read(0x80, 0x41) failed\n");
>  		return -EFAULT;
>  	}
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_dp_dual_mode_helper.c b/drivers/gpu/drm/drm_dp_dual_mode_helper.c
index 80e62f6..13f67a36 100644
--- a/drivers/gpu/drm/drm_dp_dual_mode_helper.c
+++ b/drivers/gpu/drm/drm_dp_dual_mode_helper.c
@@ -75,8 +75,15 @@  ssize_t drm_dp_dual_mode_read(struct i2c_adapter *adapter,
 		},
 	};
 	int ret;
+	int retry;
+
+	for (retry = 5; ; ) {
+		ret = i2c_transfer(adapter, msgs, ARRAY_SIZE(msgs));
+		if (ret > 0 || !retry--)
+			break;
+		usleep_range(500, 1000);
+	}
 
-	ret = i2c_transfer(adapter, msgs, ARRAY_SIZE(msgs));
 	if (ret < 0)
 		return ret;
 	if (ret != ARRAY_SIZE(msgs))
@@ -420,7 +427,7 @@  int drm_lspcon_get_mode(struct i2c_adapter *adapter,
 	ret = drm_dp_dual_mode_read(adapter, DP_DUAL_MODE_LSPCON_CURRENT_MODE,
 				    &data, sizeof(data));
 	if (ret < 0) {
-		DRM_ERROR("LSPCON read(0x80, 0x41) failed\n");
+		DRM_DEBUG_KMS("LSPCON read(0x80, 0x41) failed\n");
 		return -EFAULT;
 	}