浏览代码

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

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>
Link: http://patchwork.freedesktop.org/patch/msgid/20170218112708.24504-1-chris@chris-wilson.co.uk
Reviewed-by: Radoslaw Szwichtenberg <radoslaw.szwichtenberg@intel.com>
Chris Wilson 8 年之前
父节点
当前提交
23f4a287fc
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      drivers/gpu/drm/i915/i915_debugfs.c

+ 2 - 2
drivers/gpu/drm/i915/i915_debugfs.c

@@ -2356,10 +2356,10 @@ static int i915_rps_boost_info(struct seq_file *m, void *data)
 		seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n",
 		seq_printf(m, "\nRPS Autotuning (current \"%s\" window):\n",
 			   rps_power_to_str(dev_priv->rps.power));
 			   rps_power_to_str(dev_priv->rps.power));
 		seq_printf(m, "  Avg. up: %d%% [above threshold? %d%%]\n",
 		seq_printf(m, "  Avg. up: %d%% [above threshold? %d%%]\n",
-			   100 * rpup / rpupei,
+			   rpup && rpupei ? 100 * rpup / rpupei : 0,
 			   dev_priv->rps.up_threshold);
 			   dev_priv->rps.up_threshold);
 		seq_printf(m, "  Avg. down: %d%% [below threshold? %d%%]\n",
 		seq_printf(m, "  Avg. down: %d%% [below threshold? %d%%]\n",
-			   100 * rpdown / rpdownei,
+			   rpdown && rpdownei ? 100 * rpdown / rpdownei : 0,
 			   dev_priv->rps.down_threshold);
 			   dev_priv->rps.down_threshold);
 	} else {
 	} else {
 		seq_puts(m, "\nRPS Autotuning inactive\n");
 		seq_puts(m, "\nRPS Autotuning inactive\n");