[Intel-gfx] [PATCH 1/2] drm/i915: fix possible refcount leak when resetting forcewake

Chris Wilson chris at chris-wilson.co.uk
Fri Jun 6 12:03:20 CEST 2014


On Fri, Jun 06, 2014 at 12:59:38PM +0300, Imre Deak wrote:
> If the timer putting the last forcewake refcount was pending and we
> canceled it, we'll leak the corresponding forcewake and RPM references.
> 
> Signed-off-by: Imre Deak <imre.deak at intel.com>
> ---
>  drivers/gpu/drm/i915/intel_uncore.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
> index c90222d..389e235 100644
> --- a/drivers/gpu/drm/i915/intel_uncore.c
> +++ b/drivers/gpu/drm/i915/intel_uncore.c
> @@ -299,9 +299,8 @@ static void vlv_force_wake_put(struct drm_i915_private *dev_priv, int fw_engine)
>  	spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
>  }
>  
> -static void gen6_force_wake_timer(unsigned long arg)
> +static void __gen6_force_wake_timer(struct drm_i915_private *dev_priv)
>  {
> -	struct drm_i915_private *dev_priv = (void *)arg;
>  	unsigned long irqflags;
>  
>  	assert_device_not_suspended(dev_priv);
> @@ -316,12 +315,20 @@ static void gen6_force_wake_timer(unsigned long arg)
>  	intel_runtime_pm_put(dev_priv);
>  }
>  
> +static void gen6_force_wake_timer(unsigned long arg)
> +{
> +	struct drm_i915_private *dev_priv = (void *)arg;
> +
> +	__gen6_force_wake_timer(dev_priv);
> +}
> +
>  static void intel_uncore_forcewake_reset(struct drm_device *dev, bool restore)
>  {
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	unsigned long irqflags;
>  
> -	del_timer_sync(&dev_priv->uncore.force_wake_timer);
> +	if (del_timer_sync(&dev_priv->uncore.force_wake_timer))
> +		__gen6_force_wake_timer(dev_priv);

Just do the cast for the exception case.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre



More information about the Intel-gfx mailing list