diff mbox

[3/6] drm/i915: Optimize the VLV Punit wait a bit

Message ID 1372177266-2665-4-git-send-email-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ville Syrjälä June 25, 2013, 4:21 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Don't do needless udelay() calls if the Punit already completed
the frequency change.

Also double check things after the timeout to make sure the timeout
wasn't just caused by some scheduling delays.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_pm.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

Jesse Barnes June 25, 2013, 7:03 p.m. UTC | #1
On Tue, 25 Jun 2013 19:21:03 +0300
ville.syrjala@linux.intel.com wrote:

> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Don't do needless udelay() calls if the Punit already completed
> the frequency change.
> 
> Also double check things after the timeout to make sure the timeout
> wasn't just caused by some scheduling delays.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_pm.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index 6dbcad7..6b98d45 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -3078,14 +3078,20 @@ static void vlv_update_rps_cur_delay(struct drm_i915_private *dev_priv)
>  
>  	WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));
>  
> -	do {
> -		pval = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
> +	pval = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
> +
> +	while (pval & 1) {
>  		if (time_after(jiffies, timeout)) {
> -			DRM_DEBUG_DRIVER("timed out waiting for Punit\n");
> +			pval = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
>  			break;
>  		}
> +
>  		udelay(10);
> -	} while (pval & 1);
> +		pval = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
> +	}
> +
> +	if (pval & 1)
> +		DRM_DEBUG_DRIVER("timed out waiting for Punit\n");
>  
>  	pval >>= 8;
>  

Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Daniel Vetter June 26, 2013, 10:17 a.m. UTC | #2
On Tue, Jun 25, 2013 at 07:21:03PM +0300, ville.syrjala@linux.intel.com wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Don't do needless udelay() calls if the Punit already completed
> the frequency change.
> 
> Also double check things after the timeout to make sure the timeout
> wasn't just caused by some scheduling delays.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_pm.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index 6dbcad7..6b98d45 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -3078,14 +3078,20 @@ static void vlv_update_rps_cur_delay(struct drm_i915_private *dev_priv)
>  
>  	WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));
>  
> -	do {
> -		pval = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
> +	pval = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
> +
> +	while (pval & 1) {
>  		if (time_after(jiffies, timeout)) {
> -			DRM_DEBUG_DRIVER("timed out waiting for Punit\n");
> +			pval = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
>  			break;
>  		}
> +
>  		udelay(10);
> -	} while (pval & 1);
> +		pval = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
> +	}
> +
> +	if (pval & 1)
> +		DRM_DEBUG_DRIVER("timed out waiting for Punit\n");

Since we notoriously get these suckers wrong and this check isn't really
in the critical path any more (the punit should have complete the last
change already) and furthermore in a work item: Can we just use one of our
bog-standard wait_for macros here now?
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 6dbcad7..6b98d45 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -3078,14 +3078,20 @@  static void vlv_update_rps_cur_delay(struct drm_i915_private *dev_priv)
 
 	WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));
 
-	do {
-		pval = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
+	pval = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
+
+	while (pval & 1) {
 		if (time_after(jiffies, timeout)) {
-			DRM_DEBUG_DRIVER("timed out waiting for Punit\n");
+			pval = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
 			break;
 		}
+
 		udelay(10);
-	} while (pval & 1);
+		pval = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS);
+	}
+
+	if (pval & 1)
+		DRM_DEBUG_DRIVER("timed out waiting for Punit\n");
 
 	pval >>= 8;