[PATCH] drm/i915: avoid division by zero on skl_calc_wrpll_link
Jani Nikula
jani.nikula at linux.intel.com
Fri Dec 28 09:36:54 UTC 2018
On Mon, 17 Dec 2018, Yang Xiao <YangX92 at hotmail.com> wrote:
> From: Young Xiao <YangX92 at 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 at hotmail.com>
Pushed to drm-intel-next-queued, thanks for the patch.
BR,
Jani.
> ---
> 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);
> }
--
Jani Nikula, Intel Open Source Graphics Center
More information about the dri-devel
mailing list