From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCH] drm/i915: Avoid div-by-zero when pixel_multiplier is zero Date: Tue, 10 Jun 2014 09:12:03 +0200 Message-ID: <20140610071203.GG5821@phenom.ffwll.local> References: <1402320046-13069-1-git-send-email-ville.syrjala@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com [74.125.82.41]) by gabe.freedesktop.org (Postfix) with ESMTP id 663B36E631 for ; Tue, 10 Jun 2014 00:12:09 -0700 (PDT) Received: by mail-wg0-f41.google.com with SMTP id a1so3329479wgh.0 for ; Tue, 10 Jun 2014 00:12:08 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1402320046-13069-1-git-send-email-ville.syrjala@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: ville.syrjala@linux.intel.com Cc: intel-gfx@lists.freedesktop.org, stable@vger.kernel.org List-Id: intel-gfx@lists.freedesktop.org On Mon, Jun 09, 2014 at 04:20:46PM +0300, ville.syrjala@linux.intel.com wro= te: > From: Ville Syrj=E4l=E4 > = > On certain platforms pixel_multiplier is read out in > .get_pipe_config(), but it also gets used to calculate the > pixel clock in intel_sdvo_get_config(). If the pipe is disable > but some SDVO outputs are active, we may end up dividing by zero > in intel_sdvo_get_config(). > = > To avoid the problem simply check for zero pixel_multiplier and skip > the division. Another attempt at fixing this involved populating > pixel_multiplier to 1 even for disabled pipes, but that triggered a > WARN because SDVO_CMD_GET_CLOCK_RATE_MULT command failed and thus > encoder_pixel_multiplier was left at zero and didn't match > pipe_config->pixel_multiplier. > = > The "divide by pixel_multiplier" operation got introduced here: > commit 18442d08786472c63a0a80c27f92b033dffc26de > Author: Ville Syrj=C3=A4l=C3=A4 > Date: Fri Sep 13 16:00:08 2013 +0300 > = > drm/i915: Fix port_clock and adjusted_mode.clock readout all over > = > and it has caused a regression on certain machines since they would > hit the div-by-zero during resume. > = > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=3D76520 > Cc: # 3.13+ > Tested-by: Tim Richardson > Signed-off-by: Ville Syrj=E4l=E4 Reviewed-by: Daniel Vetter > --- > drivers/gpu/drm/i915/intel_sdvo.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > = > diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/int= el_sdvo.c > index 6a4d5bc..20375cc 100644 > --- a/drivers/gpu/drm/i915/intel_sdvo.c > +++ b/drivers/gpu/drm/i915/intel_sdvo.c > @@ -1385,7 +1385,9 @@ static void intel_sdvo_get_config(struct intel_enco= der *encoder, > >> SDVO_PORT_MULTIPLY_SHIFT) + 1; > } > = > - dotclock =3D pipe_config->port_clock / pipe_config->pixel_multiplier; > + dotclock =3D pipe_config->port_clock; > + if (pipe_config->pixel_multiplier) > + dotclock /=3D pipe_config->pixel_multiplier; > = > if (HAS_PCH_SPLIT(dev)) > ironlake_check_encoder_dotclock(pipe_config, dotclock); > -- = > 1.8.5.5 > = > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- = Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch