* [PATCH] drm/i915: Fix GT frequency rounding
@ 2015-11-13 17:29 Mika Kuoppala
2015-11-13 17:47 ` Ville Syrjälä
2015-11-13 19:38 ` Bob Paauwe
0 siblings, 2 replies; 4+ messages in thread
From: Mika Kuoppala @ 2015-11-13 17:29 UTC (permalink / raw)
To: intel-gfx
When we set and later readback a frequency value through
sysfs interface, igt/pm_rpm assumes that we get same value back
if it matches hw granularity.
On bxt we have found out that this is not always the case.
Currently frequency - hw ratio - frequency conversions round down,
with few exceptions on platforms that have more specific conversions.
On bxt the supported range can be for example from 100Mhz to 650Mhz.
Midpoint is then calculated by test to be 375 which pm_rps uses to find a
closest hw supported frequency. That is 366 (ratio 22),
which it then writes back. But as the rounding down kicks in,
driver actually sets 350 instead of 366, as 366 is 2/3 below 22 * 50/3.
Fix this by rounding to closest instead of rounding down in
freq-ratio-freq conversions.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92768
Testcase: igt/pm_rps/basic-api
Tested-by: Bob Paauwe <bob.j.paauwe@intel.com>
Cc: Bob Paauwe <bob.j.paauwe@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
---
drivers/gpu/drm/i915/intel_pm.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 647c0ff..740623f 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -7139,7 +7139,8 @@ static int chv_freq_opcode(struct drm_i915_private *dev_priv, int val)
int intel_gpu_freq(struct drm_i915_private *dev_priv, int val)
{
if (IS_GEN9(dev_priv->dev))
- return (val * GT_FREQUENCY_MULTIPLIER) / GEN9_FREQ_SCALER;
+ return DIV_ROUND_CLOSEST(val * GT_FREQUENCY_MULTIPLIER,
+ GEN9_FREQ_SCALER);
else if (IS_CHERRYVIEW(dev_priv->dev))
return chv_gpu_freq(dev_priv, val);
else if (IS_VALLEYVIEW(dev_priv->dev))
@@ -7151,13 +7152,14 @@ int intel_gpu_freq(struct drm_i915_private *dev_priv, int val)
int intel_freq_opcode(struct drm_i915_private *dev_priv, int val)
{
if (IS_GEN9(dev_priv->dev))
- return (val * GEN9_FREQ_SCALER) / GT_FREQUENCY_MULTIPLIER;
+ return DIV_ROUND_CLOSEST(val * GEN9_FREQ_SCALER,
+ GT_FREQUENCY_MULTIPLIER);
else if (IS_CHERRYVIEW(dev_priv->dev))
return chv_freq_opcode(dev_priv, val);
else if (IS_VALLEYVIEW(dev_priv->dev))
return byt_freq_opcode(dev_priv, val);
else
- return val / GT_FREQUENCY_MULTIPLIER;
+ return DIV_ROUND_CLOSEST(val, GT_FREQUENCY_MULTIPLIER);
}
struct request_boost {
--
2.5.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] drm/i915: Fix GT frequency rounding
2015-11-13 17:29 [PATCH] drm/i915: Fix GT frequency rounding Mika Kuoppala
@ 2015-11-13 17:47 ` Ville Syrjälä
2015-11-13 19:38 ` Bob Paauwe
1 sibling, 0 replies; 4+ messages in thread
From: Ville Syrjälä @ 2015-11-13 17:47 UTC (permalink / raw)
To: Mika Kuoppala; +Cc: intel-gfx
On Fri, Nov 13, 2015 at 07:29:41PM +0200, Mika Kuoppala wrote:
> When we set and later readback a frequency value through
> sysfs interface, igt/pm_rpm assumes that we get same value back
> if it matches hw granularity.
>
> On bxt we have found out that this is not always the case.
> Currently frequency - hw ratio - frequency conversions round down,
> with few exceptions on platforms that have more specific conversions.
> On bxt the supported range can be for example from 100Mhz to 650Mhz.
> Midpoint is then calculated by test to be 375 which pm_rps uses to find a
> closest hw supported frequency. That is 366 (ratio 22),
> which it then writes back. But as the rounding down kicks in,
> driver actually sets 350 instead of 366, as 366 is 2/3 below 22 * 50/3.
>
> Fix this by rounding to closest instead of rounding down in
> freq-ratio-freq conversions.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92768
> Testcase: igt/pm_rps/basic-api
> Tested-by: Bob Paauwe <bob.j.paauwe@intel.com>
> Cc: Bob Paauwe <bob.j.paauwe@intel.com>
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
> ---
> drivers/gpu/drm/i915/intel_pm.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index 647c0ff..740623f 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -7139,7 +7139,8 @@ static int chv_freq_opcode(struct drm_i915_private *dev_priv, int val)
> int intel_gpu_freq(struct drm_i915_private *dev_priv, int val)
> {
> if (IS_GEN9(dev_priv->dev))
> - return (val * GT_FREQUENCY_MULTIPLIER) / GEN9_FREQ_SCALER;
> + return DIV_ROUND_CLOSEST(val * GT_FREQUENCY_MULTIPLIER,
> + GEN9_FREQ_SCALER);
> else if (IS_CHERRYVIEW(dev_priv->dev))
> return chv_gpu_freq(dev_priv, val);
> else if (IS_VALLEYVIEW(dev_priv->dev))
> @@ -7151,13 +7152,14 @@ int intel_gpu_freq(struct drm_i915_private *dev_priv, int val)
> int intel_freq_opcode(struct drm_i915_private *dev_priv, int val)
> {
> if (IS_GEN9(dev_priv->dev))
> - return (val * GEN9_FREQ_SCALER) / GT_FREQUENCY_MULTIPLIER;
> + return DIV_ROUND_CLOSEST(val * GEN9_FREQ_SCALER,
> + GT_FREQUENCY_MULTIPLIER);
> else if (IS_CHERRYVIEW(dev_priv->dev))
> return chv_freq_opcode(dev_priv, val);
> else if (IS_VALLEYVIEW(dev_priv->dev))
> return byt_freq_opcode(dev_priv, val);
> else
> - return val / GT_FREQUENCY_MULTIPLIER;
> + return DIV_ROUND_CLOSEST(val, GT_FREQUENCY_MULTIPLIER);
lgtm
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> }
>
> struct request_boost {
> --
> 2.5.0
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] drm/i915: Fix GT frequency rounding
2015-11-13 17:29 [PATCH] drm/i915: Fix GT frequency rounding Mika Kuoppala
2015-11-13 17:47 ` Ville Syrjälä
@ 2015-11-13 19:38 ` Bob Paauwe
2015-11-16 13:28 ` Jani Nikula
1 sibling, 1 reply; 4+ messages in thread
From: Bob Paauwe @ 2015-11-13 19:38 UTC (permalink / raw)
To: Mika Kuoppala; +Cc: intel-gfx
On Fri, 13 Nov 2015 19:29:41 +0200
Mika Kuoppala <mika.kuoppala@linux.intel.com> wrote:
> When we set and later readback a frequency value through
> sysfs interface, igt/pm_rpm assumes that we get same value back
> if it matches hw granularity.
>
> On bxt we have found out that this is not always the case.
> Currently frequency - hw ratio - frequency conversions round down,
> with few exceptions on platforms that have more specific conversions.
> On bxt the supported range can be for example from 100Mhz to 650Mhz.
> Midpoint is then calculated by test to be 375 which pm_rps uses to find a
> closest hw supported frequency. That is 366 (ratio 22),
> which it then writes back. But as the rounding down kicks in,
> driver actually sets 350 instead of 366, as 366 is 2/3 below 22 * 50/3.
>
> Fix this by rounding to closest instead of rounding down in
> freq-ratio-freq conversions.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92768
> Testcase: igt/pm_rps/basic-api
> Tested-by: Bob Paauwe <bob.j.paauwe@intel.com>
> Cc: Bob Paauwe <bob.j.paauwe@intel.com>
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
> ---
> drivers/gpu/drm/i915/intel_pm.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index 647c0ff..740623f 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -7139,7 +7139,8 @@ static int chv_freq_opcode(struct drm_i915_private *dev_priv, int val)
> int intel_gpu_freq(struct drm_i915_private *dev_priv, int val)
> {
> if (IS_GEN9(dev_priv->dev))
> - return (val * GT_FREQUENCY_MULTIPLIER) / GEN9_FREQ_SCALER;
> + return DIV_ROUND_CLOSEST(val * GT_FREQUENCY_MULTIPLIER,
> + GEN9_FREQ_SCALER);
> else if (IS_CHERRYVIEW(dev_priv->dev))
> return chv_gpu_freq(dev_priv, val);
> else if (IS_VALLEYVIEW(dev_priv->dev))
> @@ -7151,13 +7152,14 @@ int intel_gpu_freq(struct drm_i915_private *dev_priv, int val)
> int intel_freq_opcode(struct drm_i915_private *dev_priv, int val)
> {
> if (IS_GEN9(dev_priv->dev))
> - return (val * GEN9_FREQ_SCALER) / GT_FREQUENCY_MULTIPLIER;
> + return DIV_ROUND_CLOSEST(val * GEN9_FREQ_SCALER,
> + GT_FREQUENCY_MULTIPLIER);
> else if (IS_CHERRYVIEW(dev_priv->dev))
> return chv_freq_opcode(dev_priv, val);
> else if (IS_VALLEYVIEW(dev_priv->dev))
> return byt_freq_opcode(dev_priv, val);
> else
> - return val / GT_FREQUENCY_MULTIPLIER;
> + return DIV_ROUND_CLOSEST(val, GT_FREQUENCY_MULTIPLIER);
> }
>
> struct request_boost {
Reviewed-by: Bob Paauwe <bob.j.paauwe@intel.com>
--
--
Bob Paauwe
Bob.J.Paauwe@intel.com
IOTG / PED Software Organization
Intel Corp. Folsom, CA
(916) 356-6193
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] drm/i915: Fix GT frequency rounding
2015-11-13 19:38 ` Bob Paauwe
@ 2015-11-16 13:28 ` Jani Nikula
0 siblings, 0 replies; 4+ messages in thread
From: Jani Nikula @ 2015-11-16 13:28 UTC (permalink / raw)
To: Bob Paauwe, Mika Kuoppala; +Cc: intel-gfx
On Fri, 13 Nov 2015, Bob Paauwe <bob.j.paauwe@intel.com> wrote:
> On Fri, 13 Nov 2015 19:29:41 +0200
> Mika Kuoppala <mika.kuoppala@linux.intel.com> wrote:
>
>> When we set and later readback a frequency value through
>> sysfs interface, igt/pm_rpm assumes that we get same value back
>> if it matches hw granularity.
>>
>> On bxt we have found out that this is not always the case.
>> Currently frequency - hw ratio - frequency conversions round down,
>> with few exceptions on platforms that have more specific conversions.
>> On bxt the supported range can be for example from 100Mhz to 650Mhz.
>> Midpoint is then calculated by test to be 375 which pm_rps uses to find a
>> closest hw supported frequency. That is 366 (ratio 22),
>> which it then writes back. But as the rounding down kicks in,
>> driver actually sets 350 instead of 366, as 366 is 2/3 below 22 * 50/3.
>>
>> Fix this by rounding to closest instead of rounding down in
>> freq-ratio-freq conversions.
>>
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92768
>> Testcase: igt/pm_rps/basic-api
>> Tested-by: Bob Paauwe <bob.j.paauwe@intel.com>
>> Cc: Bob Paauwe <bob.j.paauwe@intel.com>
>> Signed-off-by: Imre Deak <imre.deak@intel.com>
>> Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
>> ---
>> drivers/gpu/drm/i915/intel_pm.c | 8 +++++---
>> 1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
>> index 647c0ff..740623f 100644
>> --- a/drivers/gpu/drm/i915/intel_pm.c
>> +++ b/drivers/gpu/drm/i915/intel_pm.c
>> @@ -7139,7 +7139,8 @@ static int chv_freq_opcode(struct drm_i915_private *dev_priv, int val)
>> int intel_gpu_freq(struct drm_i915_private *dev_priv, int val)
>> {
>> if (IS_GEN9(dev_priv->dev))
>> - return (val * GT_FREQUENCY_MULTIPLIER) / GEN9_FREQ_SCALER;
>> + return DIV_ROUND_CLOSEST(val * GT_FREQUENCY_MULTIPLIER,
>> + GEN9_FREQ_SCALER);
>> else if (IS_CHERRYVIEW(dev_priv->dev))
>> return chv_gpu_freq(dev_priv, val);
>> else if (IS_VALLEYVIEW(dev_priv->dev))
>> @@ -7151,13 +7152,14 @@ int intel_gpu_freq(struct drm_i915_private *dev_priv, int val)
>> int intel_freq_opcode(struct drm_i915_private *dev_priv, int val)
>> {
>> if (IS_GEN9(dev_priv->dev))
>> - return (val * GEN9_FREQ_SCALER) / GT_FREQUENCY_MULTIPLIER;
>> + return DIV_ROUND_CLOSEST(val * GEN9_FREQ_SCALER,
>> + GT_FREQUENCY_MULTIPLIER);
>> else if (IS_CHERRYVIEW(dev_priv->dev))
>> return chv_freq_opcode(dev_priv, val);
>> else if (IS_VALLEYVIEW(dev_priv->dev))
>> return byt_freq_opcode(dev_priv, val);
>> else
>> - return val / GT_FREQUENCY_MULTIPLIER;
>> + return DIV_ROUND_CLOSEST(val, GT_FREQUENCY_MULTIPLIER);
>> }
>>
>> struct request_boost {
>
> Reviewed-by: Bob Paauwe <bob.j.paauwe@intel.com>
Pushed to drm-intel-fixes, thanks for the patch and review.
BR,
Jani.
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-11-16 13:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-13 17:29 [PATCH] drm/i915: Fix GT frequency rounding Mika Kuoppala
2015-11-13 17:47 ` Ville Syrjälä
2015-11-13 19:38 ` Bob Paauwe
2015-11-16 13:28 ` Jani Nikula
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox