drm/i915/chv: Fix error path in GPU freq helpers
authorImre Deak <imre.deak@intel.com>
Fri, 29 Jan 2016 12:52:27 +0000 (14:52 +0200)
committerImre Deak <imre.deak@intel.com>
Tue, 2 Feb 2016 16:28:25 +0000 (18:28 +0200)
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
drivers/gpu/drm/i915/intel_pm.c

index 31bc4ea..a47b8f2 100644 (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);
 
-       div = vlv_gpu_freq_div(czclk_freq) / 2;
+       div = vlv_gpu_freq_div(czclk_freq);
        if (div < 0)
                return div;
+       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);
 
-       mul = vlv_gpu_freq_div(czclk_freq) / 2;
+       mul = vlv_gpu_freq_div(czclk_freq);
        if (mul < 0)
                return mul;
+       mul /= 2;
 
        /* CHV needs even values */
        return DIV_ROUND_CLOSEST(val * 2 * mul, czclk_freq) * 2;