drm/i915/chv: Fix error path in GPU freq helpers

Atm we wouldn't catch these errors or on the error path we would end up
with a division-by-zero, fix this up.

Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: David Weinehall <david.weinehall@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1454071949-24677-2-git-send-email-imre.deak@intel.com
This commit is contained in:
Imre Deak 2016-01-29 14:52:27 +02:00
parent d81a67cc1b
commit 9c06f6744d

View file

@ -7185,9 +7185,10 @@ static int chv_gpu_freq(struct drm_i915_private *dev_priv, int val)
{ {
int div, czclk_freq = DIV_ROUND_CLOSEST(dev_priv->czclk_freq, 1000); int div, czclk_freq = DIV_ROUND_CLOSEST(dev_priv->czclk_freq, 1000);
div = vlv_gpu_freq_div(czclk_freq) / 2; div = vlv_gpu_freq_div(czclk_freq);
if (div < 0) if (div < 0)
return div; return div;
div /= 2;
return DIV_ROUND_CLOSEST(czclk_freq * val, 2 * div) / 2; return DIV_ROUND_CLOSEST(czclk_freq * val, 2 * div) / 2;
} }
@ -7196,9 +7197,10 @@ static int chv_freq_opcode(struct drm_i915_private *dev_priv, int val)
{ {
int mul, czclk_freq = DIV_ROUND_CLOSEST(dev_priv->czclk_freq, 1000); int mul, czclk_freq = DIV_ROUND_CLOSEST(dev_priv->czclk_freq, 1000);
mul = vlv_gpu_freq_div(czclk_freq) / 2; mul = vlv_gpu_freq_div(czclk_freq);
if (mul < 0) if (mul < 0)
return mul; return mul;
mul /= 2;
/* CHV needs even values */ /* CHV needs even values */
return DIV_ROUND_CLOSEST(val * 2 * mul, czclk_freq) * 2; return DIV_ROUND_CLOSEST(val * 2 * mul, czclk_freq) * 2;