Re: [PATCH 2/5] drm/i915: Refactor power well refcount inc/dec operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2013/9/12  <ville.syrjala@xxxxxxxxxxxxxxx>:
> From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
>
> We increase/decrease the power well refcount in several places now, and
> all of those places need to do the same thing, so pull that code into
> a few small helper functions.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>

<bikeshed> I don't think we need those "__" in the beginning. </bikeshed>

Reviewed-by: Paulo Zanoni <paulo.r.zanoni@xxxxxxxxx>

> ---
>  drivers/gpu/drm/i915/intel_pm.c | 39 +++++++++++++++++++++------------------
>  1 file changed, 21 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index 4962303..1aa604c 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -5333,6 +5333,19 @@ static void __intel_set_power_well(struct drm_device *dev, bool enable)
>         }
>  }
>
> +static void __intel_inc_power_well_refcount(struct i915_power_well *power_well)
> +{
> +       if (!power_well->count++)
> +               __intel_set_power_well(power_well->device, true);
> +}
> +
> +static void __intel_dec_power_well_refcount(struct i915_power_well *power_well)
> +{
> +       WARN_ON(!power_well->count);
> +       if (!--power_well->count)
> +               __intel_set_power_well(power_well->device, false);
> +}
> +
>  void intel_display_power_get(struct drm_device *dev,
>                              enum intel_display_power_domain domain)
>  {
> @@ -5355,8 +5368,7 @@ void intel_display_power_get(struct drm_device *dev,
>         case POWER_DOMAIN_TRANSCODER_B:
>         case POWER_DOMAIN_TRANSCODER_C:
>                 spin_lock_irq(&power_well->lock);
> -               if (!power_well->count++)
> -                       __intel_set_power_well(power_well->device, true);
> +               __intel_inc_power_well_refcount(power_well);
>                 spin_unlock_irq(&power_well->lock);
>                 return;
>         default:
> @@ -5386,9 +5398,7 @@ void intel_display_power_put(struct drm_device *dev,
>         case POWER_DOMAIN_TRANSCODER_B:
>         case POWER_DOMAIN_TRANSCODER_C:
>                 spin_lock_irq(&power_well->lock);
> -               WARN_ON(!power_well->count);
> -               if (!--power_well->count)
> -                       __intel_set_power_well(power_well->device, false);
> +               __intel_dec_power_well_refcount(power_well);
>                 spin_unlock_irq(&power_well->lock);
>                 return;
>         default:
> @@ -5405,8 +5415,7 @@ void i915_request_power_well(void)
>                 return;
>
>         spin_lock_irq(&hsw_pwr->lock);
> -       if (!hsw_pwr->count++)
> -               __intel_set_power_well(hsw_pwr->device, true);
> +       __intel_inc_power_well_refcount(hsw_pwr);
>         spin_unlock_irq(&hsw_pwr->lock);
>  }
>  EXPORT_SYMBOL_GPL(i915_request_power_well);
> @@ -5418,9 +5427,7 @@ void i915_release_power_well(void)
>                 return;
>
>         spin_lock_irq(&hsw_pwr->lock);
> -       WARN_ON(!hsw_pwr->count);
> -       if (!--hsw_pwr->count)
> -               __intel_set_power_well(hsw_pwr->device, false);
> +       __intel_dec_power_well_refcount(hsw_pwr);
>         spin_unlock_irq(&hsw_pwr->lock);
>  }
>  EXPORT_SYMBOL_GPL(i915_release_power_well);
> @@ -5467,14 +5474,10 @@ void intel_set_power_well(struct drm_device *dev, bool enable)
>
>         power_well->i915_request = enable;
>
> -       if (enable) {
> -               if (!power_well->count++)
> -                       __intel_set_power_well(dev, true);
> -       } else {
> -               WARN_ON(!power_well->count);
> -               if (!--power_well->count)
> -                       __intel_set_power_well(dev, false);
> -       }
> +       if (enable)
> +               __intel_inc_power_well_refcount(power_well);
> +       else
> +               __intel_dec_power_well_refcount(power_well);
>
>   out:
>         spin_unlock_irq(&power_well->lock);
> --
> 1.8.1.5
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx



-- 
Paulo Zanoni
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux