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

Jesse Barnes jbarnes at virtuousgeek.org
Fri Sep 27 02:51:16 CEST 2013


On Fri, 27 Sep 2013 01:49:37 +0100
Chris Wilson <chris at chris-wilson.co.uk> wrote:

> 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.

Sure, will re-post.

Thanks,
-- 
Jesse Barnes, Intel Open Source Technology Center



More information about the Intel-gfx mailing list