From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lelnx194.ext.ti.com ([198.47.27.80]:45093 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756046AbdJLJjg (ORCPT ); Thu, 12 Oct 2017 05:39:36 -0400 From: Jyri Sarha To: CC: , , , , Jyri Sarha , Subject: [PATCH] drm/tilcdc: Force recalculation of vrefresh in tilcdc_crtc_set_mode() Date: Thu, 12 Oct 2017 12:39:25 +0300 Message-ID: <1507801165-21285-1-git-send-email-jsarha@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: stable-owner@vger.kernel.org List-ID: =EF=BB=BFWe are using the vrefresh to check if we are too close to vertical sync to update the two framebuffer DMA registers and risk a collision. The vrefresh is coming from user space and normally it is not used for anything. For instance xserver leaves vrefresh to zero causing a division by zero when setting the mode. We want to make sure the value is valid and force its recalculation in tilcdc_crtc_set_mode(). Reported-by: Kevin Hao Fixes: 11abbc9f39e0 ("drm/tilcdc: Set framebuffer DMA address to HW only if= CRTC is enabled") Cc: # v4.11+ Signed-off-by: Jyri Sarha --- drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/= tilcdc_crtc.c index 704db24..aa5e87c 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c @@ -459,6 +459,16 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc= ) drm_framebuffer_get(fb); =20 crtc->hwmode =3D crtc->state->adjusted_mode; + + /* We are using the vrefresh to check if we are too close to + * vertical sync to update the two framebuffer DMA registers + * and risk a collision. The vrefresh is coming from user + * space and normally it is not used for anything. We want to + * make sure the value is valid and force its recalculation + * here. + */ + crtc->hwmode.vrefresh =3D 0; + crtc->hwmode.vrefresh =3D drm_mode_vrefresh(&crtc->hwmode); } =20 static void tilcdc_crtc_enable(struct drm_crtc *crtc) --=20 1.9.1 Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Bu= siness ID: 0615521-4. Kotipaikka/Domicile: Helsinki