diff mbox

[v2] drm/i915: Correct max delay for HDMI hotplug live status checking

Message ID 1450085921-19646-1-git-send-email-gary.c.wang@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gary C Wang Dec. 14, 2015, 9:38 a.m. UTC
The total delay of HDMI hotplug detecting with 30ms have already
been split into a resolution of 3 retries of 10ms each, for the worst
cases. But it still suffered from only waiting 10ms at most in
intel_hdmi_detect(). This patch corrects it by reading hotplug status
with 4 times at most for 30ms delay.

v2:
- straight up to loop execution for more clear in code readability

Reviewed-by: Cooper Chiou <cooper.chiou@intel.com>
Tested-by: Gary Wang <gary.c.wang@intel.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Gavin Hindman <gavin.hindman@intel.com>
Cc: Sonika Jindal <sonika.jindal@intel.com>
Cc: Shashank Sharma <shashank.sharma@intel.com>
Signed-off-by: Gary Wang <gary.c.wang@intel.com>
---
 drivers/gpu/drm/i915/intel_hdmi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
 mode change 100644 => 100755 drivers/gpu/drm/i915/intel_hdmi.c

Comments

Jani Nikula Dec. 14, 2015, 11:29 a.m. UTC | #1
On Mon, 14 Dec 2015, Gary Wang <gary.c.wang@intel.com> wrote:
> The total delay of HDMI hotplug detecting with 30ms have already
> been split into a resolution of 3 retries of 10ms each, for the worst
> cases. But it still suffered from only waiting 10ms at most in
> intel_hdmi_detect(). This patch corrects it by reading hotplug status
> with 4 times at most for 30ms delay.

It used to try twice, with 10 ms in between, but also with 10 ms after
the last attempt, success or not.

>
> v2:
> - straight up to loop execution for more clear in code readability
>
> Reviewed-by: Cooper Chiou <cooper.chiou@intel.com>
> Tested-by: Gary Wang <gary.c.wang@intel.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Gavin Hindman <gavin.hindman@intel.com>
> Cc: Sonika Jindal <sonika.jindal@intel.com>
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Signed-off-by: Gary Wang <gary.c.wang@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_hdmi.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>  mode change 100644 => 100755 drivers/gpu/drm/i915/intel_hdmi.c
>
> diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
> old mode 100644
> new mode 100755
> index 6825543..97ed16f
> --- a/drivers/gpu/drm/i915/intel_hdmi.c
> +++ b/drivers/gpu/drm/i915/intel_hdmi.c
> @@ -1387,16 +1387,18 @@ intel_hdmi_detect(struct drm_connector *connector, bool force)
>  	struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
>  	struct drm_i915_private *dev_priv = to_i915(connector->dev);
>  	bool live_status = false;
> -	unsigned int retry = 3;
> +	unsigned int retry;
>  
>  	DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
>  		      connector->base.id, connector->name);
>  
>  	intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS);
>  
> -	while (!live_status && --retry) {
> +	for (retry = 0; retry <= 3; retry++) {
>  		live_status = intel_digital_port_connected(dev_priv,
>  				hdmi_to_dig_port(intel_hdmi));
> +		if (live_status || (retry == 3))
> +			break;
>  		mdelay(10);
>  	}

Basically the "retry <= 3" is never the stop condition in your loop, and
is thus misleading.

How about this instead, with the paradigm counting for loop:

	for (try = 0; !live_status && try < 4; try++) {
		if (try)
                	mdelay(10);
		live_status = intel_digital_port_connected(...);
	}

Note that I didn't actually check if this is the right thing to do; this
is just your loop rewritten as I'd write it... ;)

BR,
Jani.
Gary C Wang Dec. 15, 2015, 2:30 a.m. UTC | #2
Yes, your code is clear. It tried to check hot-plug with 4 times based on delay setup (30ms) in following patch,

commit 237ed86c693d8a8e4db476976aeb30df4deac74b
Author: Sonika Jindal <sonika.jindal@xxxxxxxxx>
Date:   Tue Sep 15 09:44:20 2015 +0530

    drm/i915: Check live status before reading edid

I will refine patch for your review again.

Thanks!

Gary

-----Original Message-----
From: Jani Nikula [mailto:jani.nikula@linux.intel.com] 
Sent: Monday, December 14, 2015 7:29 PM
To: Wang, Gary C <gary.c.wang@intel.com>; intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH v2] drm/i915: Correct max delay for HDMI hotplug live status checking

On Mon, 14 Dec 2015, Gary Wang <gary.c.wang@intel.com> wrote:
> The total delay of HDMI hotplug detecting with 30ms have already been 
> split into a resolution of 3 retries of 10ms each, for the worst 
> cases. But it still suffered from only waiting 10ms at most in 
> intel_hdmi_detect(). This patch corrects it by reading hotplug status 
> with 4 times at most for 30ms delay.

It used to try twice, with 10 ms in between, but also with 10 ms after the last attempt, success or not.

>
> v2:
> - straight up to loop execution for more clear in code readability
>
> Reviewed-by: Cooper Chiou <cooper.chiou@intel.com>
> Tested-by: Gary Wang <gary.c.wang@intel.com>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Gavin Hindman <gavin.hindman@intel.com>
> Cc: Sonika Jindal <sonika.jindal@intel.com>
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Signed-off-by: Gary Wang <gary.c.wang@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_hdmi.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)  mode change 100644 
> => 100755 drivers/gpu/drm/i915/intel_hdmi.c
>
> diff --git a/drivers/gpu/drm/i915/intel_hdmi.c 
> b/drivers/gpu/drm/i915/intel_hdmi.c
> old mode 100644
> new mode 100755
> index 6825543..97ed16f
> --- a/drivers/gpu/drm/i915/intel_hdmi.c
> +++ b/drivers/gpu/drm/i915/intel_hdmi.c
> @@ -1387,16 +1387,18 @@ intel_hdmi_detect(struct drm_connector *connector, bool force)
>  	struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
>  	struct drm_i915_private *dev_priv = to_i915(connector->dev);
>  	bool live_status = false;
> -	unsigned int retry = 3;
> +	unsigned int retry;
>  
>  	DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
>  		      connector->base.id, connector->name);
>  
>  	intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS);
>  
> -	while (!live_status && --retry) {
> +	for (retry = 0; retry <= 3; retry++) {
>  		live_status = intel_digital_port_connected(dev_priv,
>  				hdmi_to_dig_port(intel_hdmi));
> +		if (live_status || (retry == 3))
> +			break;
>  		mdelay(10);
>  	}

Basically the "retry <= 3" is never the stop condition in your loop, and is thus misleading.

How about this instead, with the paradigm counting for loop:

	for (try = 0; !live_status && try < 4; try++) {
		if (try)
                	mdelay(10);
		live_status = intel_digital_port_connected(...);
	}

Note that I didn't actually check if this is the right thing to do; this is just your loop rewritten as I'd write it... ;)

BR,
Jani.


--
Jani Nikula, Intel Open Source Technology Center
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
old mode 100644
new mode 100755
index 6825543..97ed16f
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -1387,16 +1387,18 @@  intel_hdmi_detect(struct drm_connector *connector, bool force)
 	struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
 	struct drm_i915_private *dev_priv = to_i915(connector->dev);
 	bool live_status = false;
-	unsigned int retry = 3;
+	unsigned int retry;
 
 	DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
 		      connector->base.id, connector->name);
 
 	intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS);
 
-	while (!live_status && --retry) {
+	for (retry = 0; retry <= 3; retry++) {
 		live_status = intel_digital_port_connected(dev_priv,
 				hdmi_to_dig_port(intel_hdmi));
+		if (live_status || (retry == 3))
+			break;
 		mdelay(10);
 	}