[Intel-gfx] [PATCH 2/2] drm/i915/vlv: use correct units for rc6 residency

Chris Wilson chris at chris-wilson.co.uk
Fri Sep 27 02:49:37 CEST 2013


On Thu, Sep 26, 2013 at 03:34:33PM -0700, Jesse Barnes wrote:
> On Thu, 26 Sep 2013 23:25:46 +0100
> Chris Wilson <chris at chris-wilson.co.uk> wrote:
> > 
> > >  
> > >  	if (!intel_enable_rc6(dev))
> > >  		return 0;
> > >  
> > > -	raw_time = I915_READ(reg) * 128ULL;
> > > -	return DIV_ROUND_UP_ULL(raw_time, 100000);
> > > +	/* On VLV, residency time is in CZ units rather than 1.28us */
> > > +	if (IS_VALLEYVIEW(dev)) {
> > > +		u32 clkctl2;
> > > +
> > > +		clkctl2 = I915_READ(VLV_CLK_CTL2) >>
> > > +			CLK_CTL2_CZCOUNT_30NS_SHIFT;
> > > +		if (!clkctl2) {
> > > +			WARN(!clkctl2, "bogus CZ count value");
> > > +			return 0;
> > > +		}
> > > +		units = DIV_ROUND_UP_ULL(3000ULL, (u64)clkctl2);
> > 
> > For your divisor, this should 30*1000 not 3*1000.
> 
> 30ns * 100 for fixed point precision, just as above.
> 
> > 
> > > +		if (I915_READ(VLV_COUNTER_CONTROL) & VLV_COUNT_RANGE_HIGH)
> > > +			units <<= 8;
> > > +
> > > +		div = 100 000 000;
> 
> Then here we divide out the ns to ms (1000000) and also the 100 for
> fixed point.
> 
> Or do I still have it wrong?

Just counting fail on my part, even after splitting it up to make it
easier for myself.

How about

#define BIAS 100
units = 30*BIAS / cltctk2;
if (hi) units <<= 8;
div = NSEC_PER_MSEC * BIAS;

All because I have difficultly counting.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre



More information about the Intel-gfx mailing list