On Wed, Mar 15, 2017 at 05:43:01PM +0200, Mika Kuoppala wrote:
> Vlv and chv residency counters are 40 bits in width.
> With a control bit, we can choose between upper or lower
> 32 bit window into this counter.
> 
> Lets toggle this bit on and off on and read both parts.
> As a result we can push the wrap from 13 seconds to 54
> minutes.
> 
> v2: commit msg, loop readability, goto elimination (Chris)
> 
> Reported-by: Len Brown <len.br...@intel.com>

References: https://bugs.freedesktop.org/show_bug.cgi?id=94852

> Cc: Chris Wilson <ch...@chris-wilson.co.uk>
> Cc: Ville Syrjälä <ville.syrj...@linux.intel.com>
> Signed-off-by: Mika Kuoppala <mika.kuopp...@intel.com>
> ---
>  u64 intel_rc6_residency_us(struct drm_i915_private *dev_priv,
>                          const i915_reg_t reg)
>  {
> -     u64 raw_time; /* 32b value may overflow during fixed point math */
> -     u64 units = 128000ULL, div = 100000ULL;
> -     u64 ret;
> +     u64 time_hw, units, div, residency_us;
>  
>       if (!intel_enable_rc6())
>               return 0;
> @@ -8367,16 +8406,21 @@ u64 intel_rc6_residency_us(struct drm_i915_private 
> *dev_priv,
>               units = 1000;
>               div = dev_priv->czclk_freq;
>  
> -             if (I915_READ(VLV_COUNTER_CONTROL) & VLV_COUNT_RANGE_HIGH)
> -                     units <<= 8;
> +             time_hw = vlv_residency_raw(dev_priv, reg);
>       } else if (IS_GEN9_LP(dev_priv)) {
>               units = 1000;
>               div = 1200;             /* 833.33ns */
> +
> +             time_hw = I915_READ(reg);
> +     } else {
> +             units = 128000; /* 1.28us */
> +             div = 100000;
> +
> +             time_hw = I915_READ(reg);
>       }
>  
> -     raw_time = I915_READ(reg) * units;
> -     ret = DIV_ROUND_UP_ULL(raw_time, div);
> +     residency_us = DIV_ROUND_UP_ULL(time_hw * units, div);

This calc doesn't need to be inside the rpm, so just
>  
>       intel_runtime_pm_put(dev_priv);
> -     return ret;
> +     return residency_us;

        return DIV_ROUND_UP_ULL(time_hw * units, div);

Either way,
Reviewed-by: Chris Wilson <ch...@chris-wilson.co.uk>
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to