drm/i915: Fix GT frequency rounding
authorMika Kuoppala <mika.kuoppala@linux.intel.com>
Fri, 13 Nov 2015 17:29:41 +0000 (19:29 +0200)
committerJani Nikula <jani.nikula@intel.com>
Mon, 16 Nov 2015 13:25:34 +0000 (15:25 +0200)
commit500a3d2eb3883b71350036e15aad286cc6e5df21
treee8b6187be07b5175ef4980caab7c506fe84606b2
parent1b9448b071caa7d10bb2569fabe3020a2c25ae59
drm/i915: Fix GT frequency rounding

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>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Bob Paauwe <bob.j.paauwe@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1447435781-23416-1-git-send-email-mika.kuoppala@intel.com
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/intel_pm.c