[1/1] drm/i915/skl: fix RC6 residency time calculation

Submitted by Sagar Arun Kamble on Feb. 3, 2016, 5:59 a.m.

Details

Message ID 1454479186-32113-1-git-send-email-sagar.a.kamble@intel.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Intel GFX

Not browsing as part of any series.

Commit Message

Sagar Arun Kamble Feb. 3, 2016, 5:59 a.m.
The RC6 residency time unit is 1.33us on SKL according to the
specification, so update the calculation accordingly.

Cc: Imre Deak <imre.deak@intel.com>
Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@intel.com>
---
 drivers/gpu/drm/i915/i915_sysfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c
index c6188dd..9aa49a9 100644
--- a/drivers/gpu/drm/i915/i915_sysfs.c
+++ b/drivers/gpu/drm/i915/i915_sysfs.c
@@ -58,7 +58,8 @@  static u32 calc_residency(struct drm_device *dev,
 	} else if (IS_BROXTON(dev)) {
 		units = 1;
 		div = 1200;		/* 833.33ns */
-	}
+	} else if (IS_SKYLAKE(dev))
+		units = 133ULL;
 
 	raw_time = I915_READ(reg) * units;
 	ret = DIV_ROUND_UP_ULL(raw_time, div);

Comments

On ke, 2016-02-03 at 11:29 +0530, Sagar Arun Kamble wrote:
> The RC6 residency time unit is 1.33us on SKL according to the
> specification, so update the calculation accordingly.
> 
> Cc: Imre Deak <imre.deak@intel.com>
> Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_sysfs.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_sysfs.c
> b/drivers/gpu/drm/i915/i915_sysfs.c
> index c6188dd..9aa49a9 100644
> --- a/drivers/gpu/drm/i915/i915_sysfs.c
> +++ b/drivers/gpu/drm/i915/i915_sysfs.c
> @@ -58,7 +58,8 @@ static u32 calc_residency(struct drm_device *dev,
>  	} else if (IS_BROXTON(dev)) {
>  		units = 1;
>  		div = 1200;		/* 833.33ns */
> -	}
> +	} else if (IS_SKYLAKE(dev))
> +		units = 133ULL;

Hrm. The SKL/GT_GFX_RC6 description in ConfigDB doesn't say anything
about the units, the BSpec "Timestamp Bases" provides two values for
two different modes:

1.33us and 1.28us

Not sure what are these different modes.

BSpec GT_GFX_RC6 description specifies 1.28us.

Running igt/pm_rc6_residency calculating with the current 1.28us results in:
Residency in rc6 or deeper state: 2983 ms (sleep duration 3003 ms) (ratio to expected duration: 0,99)
Subtest rc6-accuracy: SUCCESS (0,000s)

and after applying your patch (calculating with 1.33us):
Residency in rc6 or deeper state: 3101 ms (sleep duration 3001 ms) (ratio to expected duration: 1,03)
(pm_rc6_residency:6281) CRITICAL: Test assertion failure function residency_accuracy, file pm_rc6_residency.c:110:
(pm_rc6_residency:6281) CRITICAL: Failed assertion: ratio > 0.9 && ratio <= 1
(pm_rc6_residency:6281) CRITICAL: Sysfs RC6 residency counter is inaccurate.

While the measurement can be inaccurate, normally we should only err by
measuring less duration in RC6 than the duration of the actual sleep.
So I'm not convinced that 1.33us is the correct value..

--Imre

>  
>  	raw_time = I915_READ(reg) * units;
>  	ret = DIV_ROUND_UP_ULL(raw_time, div);
Ok. I related my change to below definition:

#define GT_INTERVAL_FROM_US(dev_priv, us) (IS_GEN9(dev_priv) ? \
                                 (IS_BROXTON(dev_priv) ? \
                                 INTERVAL_0_833_US(us) : \
                                 INTERVAL_1_33_US(us)) : \
                                 INTERVAL_1_28_US(us))

This is using 1.33us unit for SKL.
May be we need to define these based on mode (normal/PSMI).
Not sure how to determine modes.

Thanks
Sagar


On 2/3/2016 10:40 PM, Imre Deak wrote:
> On ke, 2016-02-03 at 11:29 +0530, Sagar Arun Kamble wrote:
>> The RC6 residency time unit is 1.33us on SKL according to the
>> specification, so update the calculation accordingly.
>>
>> Cc: Imre Deak <imre.deak@intel.com>
>> Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@intel.com>
>> ---
>>   drivers/gpu/drm/i915/i915_sysfs.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_sysfs.c
>> b/drivers/gpu/drm/i915/i915_sysfs.c
>> index c6188dd..9aa49a9 100644
>> --- a/drivers/gpu/drm/i915/i915_sysfs.c
>> +++ b/drivers/gpu/drm/i915/i915_sysfs.c
>> @@ -58,7 +58,8 @@ static u32 calc_residency(struct drm_device *dev,
>>   	} else if (IS_BROXTON(dev)) {
>>   		units = 1;
>>   		div = 1200;		/* 833.33ns */
>> -	}
>> +	} else if (IS_SKYLAKE(dev))
>> +		units = 133ULL;
> Hrm. The SKL/GT_GFX_RC6 description in ConfigDB doesn't say anything
> about the units, the BSpec "Timestamp Bases" provides two values for
> two different modes:
>
> 1.33us and 1.28us
>
> Not sure what are these different modes.
>
> BSpec GT_GFX_RC6 description specifies 1.28us.
>
> Running igt/pm_rc6_residency calculating with the current 1.28us results in:
> Residency in rc6 or deeper state: 2983 ms (sleep duration 3003 ms) (ratio to expected duration: 0,99)
> Subtest rc6-accuracy: SUCCESS (0,000s)
>
> and after applying your patch (calculating with 1.33us):
> Residency in rc6 or deeper state: 3101 ms (sleep duration 3001 ms) (ratio to expected duration: 1,03)
> (pm_rc6_residency:6281) CRITICAL: Test assertion failure function residency_accuracy, file pm_rc6_residency.c:110:
> (pm_rc6_residency:6281) CRITICAL: Failed assertion: ratio > 0.9 && ratio <= 1
> (pm_rc6_residency:6281) CRITICAL: Sysfs RC6 residency counter is inaccurate.
>
> While the measurement can be inaccurate, normally we should only err by
> measuring less duration in RC6 than the duration of the actual sleep.
> So I'm not convinced that 1.33us is the correct value..
>
> --Imre
>
>>   
>>   	raw_time = I915_READ(reg) * units;
>>   	ret = DIV_ROUND_UP_ULL(raw_time, div);
On to, 2016-02-04 at 15:39 +0530, Kamble, Sagar A wrote:
> Ok. I related my change to below definition:
> 
> #define GT_INTERVAL_FROM_US(dev_priv, us) (IS_GEN9(dev_priv) ? \
>                                  (IS_BROXTON(dev_priv) ? \
>                                  INTERVAL_0_833_US(us) : \
>                                  INTERVAL_1_33_US(us)) : \
>                                  INTERVAL_1_28_US(us))
> 
> This is using 1.33us unit for SKL.
> May be we need to define these based on mode (normal/PSMI).
> Not sure how to determine modes.

Hm, good point. Looking at this now, the above macro is used for
registers that have the same contradicting description in BSpec: all
specify 1.28us units, but the "Timestamp Bases" section kind of
suggests that you need to use the units defined there for these
registers too, which could be 1.28us or 1.33us depending on the mode.
It's also possible that GT_GFX_RC6 really uses different units than
these registers. We'd really need a clarification on these in BSpec
before making changes.

--Imre

> Thanks
> Sagar
> 
> 
> On 2/3/2016 10:40 PM, Imre Deak wrote:
> > On ke, 2016-02-03 at 11:29 +0530, Sagar Arun Kamble wrote:
> > > The RC6 residency time unit is 1.33us on SKL according to the
> > > specification, so update the calculation accordingly.
> > > 
> > > Cc: Imre Deak <imre.deak@intel.com>
> > > Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@intel.com>
> > > ---
> > >   drivers/gpu/drm/i915/i915_sysfs.c | 3 ++-
> > >   1 file changed, 2 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpu/drm/i915/i915_sysfs.c
> > > b/drivers/gpu/drm/i915/i915_sysfs.c
> > > index c6188dd..9aa49a9 100644
> > > --- a/drivers/gpu/drm/i915/i915_sysfs.c
> > > +++ b/drivers/gpu/drm/i915/i915_sysfs.c
> > > @@ -58,7 +58,8 @@ static u32 calc_residency(struct drm_device
> > > *dev,
> > >   	} else if (IS_BROXTON(dev)) {
> > >   		units = 1;
> > >   		div = 1200;		/* 833.33ns */
> > > -	}
> > > +	} else if (IS_SKYLAKE(dev))
> > > +		units = 133ULL;
> > Hrm. The SKL/GT_GFX_RC6 description in ConfigDB doesn't say
> > anything
> > about the units, the BSpec "Timestamp Bases" provides two values
> > for
> > two different modes:
> > 
> > 1.33us and 1.28us
> > 
> > Not sure what are these different modes.
> > 
> > BSpec GT_GFX_RC6 description specifies 1.28us.
> > 
> > Running igt/pm_rc6_residency calculating with the current 1.28us
> > results in:
> > Residency in rc6 or deeper state: 2983 ms (sleep duration 3003 ms)
> > (ratio to expected duration: 0,99)
> > Subtest rc6-accuracy: SUCCESS (0,000s)
> > 
> > and after applying your patch (calculating with 1.33us):
> > Residency in rc6 or deeper state: 3101 ms (sleep duration 3001 ms)
> > (ratio to expected duration: 1,03)
> > (pm_rc6_residency:6281) CRITICAL: Test assertion failure function
> > residency_accuracy, file pm_rc6_residency.c:110:
> > (pm_rc6_residency:6281) CRITICAL: Failed assertion: ratio > 0.9 &&
> > ratio <= 1
> > (pm_rc6_residency:6281) CRITICAL: Sysfs RC6 residency counter is
> > inaccurate.
> > 
> > While the measurement can be inaccurate, normally we should only
> > err by
> > measuring less duration in RC6 than the duration of the actual
> > sleep.
> > So I'm not convinced that 1.33us is the correct value..
> > 
> > --Imre
> > 
> > >   
> > >   	raw_time = I915_READ(reg) * units;
> > >   	ret = DIV_ROUND_UP_ULL(raw_time, div);
>