Skip to content

Commit

Permalink
drm/i915: avoid division by zero on skl_calc_wrpll_link
Browse files Browse the repository at this point in the history
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 0e00588 ("drm/i915: avoid division by zero on
cnl_calc_wrpll_link") for detail.

Signed-off-by: Young Xiao <YangX92@hotmail.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/SG2PR01MB2169F6E95BC8BB5E29477042ADBC0@SG2PR01MB2169.apcprd01.prod.exchangelabs.com
  • Loading branch information
Young Xiao authored and Jani Nikula committed Dec 28, 2018
1 parent 6879216 commit b8449c4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/gpu/drm/i915/intel_ddi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,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);
}

Expand Down

0 comments on commit b8449c4

Please sign in to comment.