Message ID | 1454071949-24677-2-git-send-email-imre.deak@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, Jan 29, 2016 at 02:52:27PM +0200, Imre Deak wrote: > Atm we wouldn't catch these errors or on the error path we would end up > with a division-by-zero, fix this up. > > Caught by Coverity. > > Signed-off-by: Imre Deak <imre.deak@intel.com> Reviewed-by: David Weinehall <david.weinehall@intel.com> > --- > drivers/gpu/drm/i915/intel_pm.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c > index 20bf854..740a0e3 100644 > --- a/drivers/gpu/drm/i915/intel_pm.c > +++ b/drivers/gpu/drm/i915/intel_pm.c > @@ -7189,9 +7189,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; > } > @@ -7200,9 +7201,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; > -- > 2.5.0 >
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c index 20bf854..740a0e3 100644 --- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c @@ -7189,9 +7189,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; } @@ -7200,9 +7201,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;
Atm we wouldn't catch these errors or on the error path we would end up with a division-by-zero, fix this up. Caught by Coverity. Signed-off-by: Imre Deak <imre.deak@intel.com> --- drivers/gpu/drm/i915/intel_pm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)