diff mbox

drm/i915: Prevent divide-by-zero in debugfs/i915_rps_boost_info

Message ID 20170218112708.24504-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson Feb. 18, 2017, 11:27 a.m. UTC
Either by chance, or by misread, the current evaluation interval may be
zero. If that is the case, don't divide by it!

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Szwichtenberg, Radoslaw Feb. 20, 2017, 11:02 a.m. UTC | #1
On Sat, 2017-02-18 at 11:27 +0000, Chris Wilson wrote:
> Either by chance, or by misread, the current evaluation interval may be

> zero. If that is the case, don't divide by it!

> 

> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Reviewed-by: Radoslaw Szwichtenberg <radoslaw.szwichtenberg@intel.com>
Chris Wilson Feb. 20, 2017, 11:06 a.m. UTC | #2
On Mon, Feb 20, 2017 at 11:02:10AM +0000, Szwichtenberg, Radoslaw wrote:
> On Sat, 2017-02-18 at 11:27 +0000, Chris Wilson wrote:
> > Either by chance, or by misread, the current evaluation interval may be
> > zero. If that is the case, don't divide by it!
> > 
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Reviewed-by: Radoslaw Szwichtenberg <radoslaw.szwichtenberg@intel.com>

Thanks, pushed.
-Chris
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 124213a36b4f..c0bc922fe497 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -2367,10 +2367,10 @@  static int i915_rps_boost_info(struct seq_file *m, void *data)
 		seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n",
 			   rps_power_to_str(dev_priv->rps.power));
 		seq_printf(m, "  Avg. up: %d%% [above threshold? %d%%]\n",
-			   100 * rpup / rpupei,
+			   rpup && rpupei ? 100 * rpup / rpupei : 0,
 			   dev_priv->rps.up_threshold);
 		seq_printf(m, "  Avg. down: %d%% [below threshold? %d%%]\n",
-			   100 * rpdown / rpdownei,
+			   rpdown && rpdownei ? 100 * rpdown / rpdownei : 0,
 			   dev_priv->rps.down_threshold);
 	} else {
 		seq_puts(m, "\nRPS Autotuning inactive\n");