From patchwork Thu Oct 12 09:39:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jyri Sarha X-Patchwork-Id: 10001367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DB94B6028A for ; Thu, 12 Oct 2017 09:39:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C60A222B27 for ; Thu, 12 Oct 2017 09:39:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA3B628402; Thu, 12 Oct 2017 09:39:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AC6D122B27 for ; Thu, 12 Oct 2017 09:39:37 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 33BD86E2A0; Thu, 12 Oct 2017 09:39:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelnx194.ext.ti.com (lelnx194.ext.ti.com [198.47.27.80]) by gabe.freedesktop.org (Postfix) with ESMTPS id 98D266E2A0 for ; Thu, 12 Oct 2017 09:39:35 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id v9C9dWg3020259; Thu, 12 Oct 2017 04:39:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1507801172; bh=eRm/NCuwaqx/AWxlQg5A/FdYCYsmH0XL5i2XIEB49O4=; h=From:To:CC:Subject:Date; b=jjgPf57vfLDVPQa6s/oNq/hZY04IhAuW/gyNSNGiplHHB1/QiD9ljJr2IxDCS+vz9 UZrDajQqBoCxzHjrdkXV0hUkvckSHWkSmLSE9mYAmr3HHvr195rqtz4UclccJJKkK6 o2iXvAramDMS00xwXzaDpA1O6zWQm5ilgz90mbOA= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v9C9dWdA008729; Thu, 12 Oct 2017 04:39:32 -0500 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Thu, 12 Oct 2017 04:39:32 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Thu, 12 Oct 2017 04:39:32 -0500 Received: from jadmar.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v9C9dUH9023190; Thu, 12 Oct 2017 04:39:30 -0500 From: Jyri Sarha To: 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> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Cc: kexin.hao@windriver.com, Jyri Sarha , stable@vger.kernel.org, tomi.valkeinen@ti.com, laurent.pinchart@ideasonboard.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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. 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); crtc->hwmode = 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 = 0; + crtc->hwmode.vrefresh = drm_mode_vrefresh(&crtc->hwmode); } static void tilcdc_crtc_enable(struct drm_crtc *crtc)