All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: avoid division by zero on skl_calc_wrpll_link
@ 2018-12-17 12:23 Yang Xiao
  2018-12-19 10:28 ` ✓ Fi.CI.BAT: success for " Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yang Xiao @ 2018-12-17 12:23 UTC (permalink / raw)
  To: jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com,
	rodrigo.vivi@intel.com, airlied@linux.ie
  Cc: intel-gfx@lists.freedesktop.org, Yang Xiao,
	dri-devel@lists.freedesktop.org

From: Young Xiao <YangX92@hotmail.com>

If for some unexpected reason the registers all read zero it's better
to WARN and return instead of dividing by zero and completely freezing
the machine.

See commit 0e005888b833 ("drm/i915: avoid division by zero on
cnl_calc_wrpll_link") for detail.

Signed-off-by: Young Xiao <YangX92@hotmail.com>
---
 drivers/gpu/drm/i915/intel_ddi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
index 5186cd7..cfa7d6f 100644
--- a/drivers/gpu/drm/i915/intel_ddi.c
+++ b/drivers/gpu/drm/i915/intel_ddi.c
@@ -1360,6 +1360,9 @@ static int skl_calc_wrpll_link(struct drm_i915_private *dev_priv,
 	dco_freq += (((cfgcr1_val & DPLL_CFGCR1_DCO_FRACTION_MASK) >> 9) * 24 *
 		1000) / 0x8000;
 
+	if (WARN_ON(p0 == 0 || p1 == 0 || p2 == 0))
+		return 0;
+
 	return dco_freq / (p0 * p1 * p2 * 5);
 }
 
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-28  9:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-17 12:23 [PATCH] drm/i915: avoid division by zero on skl_calc_wrpll_link Yang Xiao
2018-12-19 10:28 ` ✓ Fi.CI.BAT: success for " Patchwork
2018-12-19 12:41 ` ✓ Fi.CI.IGT: " Patchwork
2018-12-28  9:36 ` [PATCH] " Jani Nikula

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.