Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: "joonas.lahtinen@linux.intel.com"
	<joonas.lahtinen@linux.intel.com>,
	"rodrigo.vivi@intel.com" <rodrigo.vivi@intel.com>,
	"airlied@linux.ie" <airlied@linux.ie>
Cc: "intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>,
	Yang Xiao <YangX92@hotmail.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] drm/i915: avoid division by zero on skl_calc_wrpll_link
Date: Fri, 28 Dec 2018 11:36:54 +0200	[thread overview]
Message-ID: <874layvvpl.fsf@intel.com> (raw)
In-Reply-To: <SG2PR01MB2169F6E95BC8BB5E29477042ADBC0@SG2PR01MB2169.apcprd01.prod.exchangelabs.com>

On Mon, 17 Dec 2018, Yang Xiao <YangX92@hotmail.com> wrote:
> 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>

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
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

      parent reply	other threads:[~2018-12-28  9:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Jani Nikula [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874layvvpl.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=YangX92@hotmail.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=rodrigo.vivi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox