Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4389603yba; Sun, 12 May 2019 11:42:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRUr2htpAN5thcz3/8XxEaWl/GexyCMINNvHEQWyhMXnQEDu3MQy540LM9lWzaXMNLBgEz X-Received: by 2002:a17:902:3281:: with SMTP id z1mr25914514plb.44.1557686577471; Sun, 12 May 2019 11:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557686577; cv=none; d=google.com; s=arc-20160816; b=cfLVOvUL0aE8yYC1mCLP20f4PXUojMVyHXl8fqKWMHxSLrC+FJ9ZAzyomxSM5NHqRw uYdh0W08HeJ0pg0SyPVoSGdm1/a8cZwl6ea2HRa+r61PVc/hWQ+XfJwrktVY1uVLAR5I 6MDcru8m6JYjpvLAAREPPmP0NsjKAXgthRUw/hCAWCZj/z3CAhzssK1eUcRZgLOXsMgt uFfArKmaOiSGVoCtKKtpmBT8kQh7pVfiUjOSjKGzjaecire7PVoZ0Z75UCHPYmGaQz0G HKmJqojqHeP9KWMBjwBps6B7BzXM6CS5ywdAGMPv09NrVkgt/YRUwdpyxc/W0hEIOxFr Lw/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=McU3A/Y2+KH8KsiZ+LTp3qJ8zWb4gZuzV4pCEGTBglg=; b=wVqp9IGJkIqgjSNDVqjo7Ehm0KhsvNuLOsUVSGaydbAMTx1LwJX9kaCsA24cz3+szi c4pVVrecWv3iTX+uFSXnmfIndy+octzlbfUfUcVhO/V5kzqqt2FPvz54RaBEqoUJI+8E qravQnmvH3Gq8eNrGtIRjUVf1qEeI+HNNTOzAy43D0CscGvlOkei/gFs0jqQICFSrmjP tEMH07FWua7GtbDdvY8Oyh91eoizx4bAK4Tj208rFbkXNlnWD7DT127BfwgK+Pdtp1Eg S+HfFyY8clPd9hvkONPmcaCHn2X08dvXuiSao15nMIeKINR/BdTchsYiGbRq3/PvZmvl tySg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SVFjdqYS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si14128044pge.550.2019.05.12.11.42.39; Sun, 12 May 2019 11:42:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SVFjdqYS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726931AbfELSls (ORCPT + 99 others); Sun, 12 May 2019 14:41:48 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:33296 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726529AbfELSlr (ORCPT ); Sun, 12 May 2019 14:41:47 -0400 Received: by mail-pg1-f196.google.com with SMTP id h17so5578787pgv.0 for ; Sun, 12 May 2019 11:41:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=McU3A/Y2+KH8KsiZ+LTp3qJ8zWb4gZuzV4pCEGTBglg=; b=SVFjdqYSyAPhETD5SmYAsNRKu3Wf4F+fbW/+KnD9toKXS3ehMbEWA4cauoMEyZxVM3 W2/GPER2Zd9IkEVZf4W6g+lCw7bp/90c1izCMNumL1PsfyDh3Gl4sCCtp3yuJGmOxFrt ZpuHyTiZqAZYxxZSvyBL74T/y6FkIJ8C9XDws= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=McU3A/Y2+KH8KsiZ+LTp3qJ8zWb4gZuzV4pCEGTBglg=; b=Cy2m05Lr08A9NwPxPD4ldlZhx49edm3kzzDIQfYGOkqRKHS/its6Nn9CGrBwNZJWEe MT6fnOKmw+sLl4LwMisdmBcYXM8LMEaXXRxR2lC3HpmmG6VC9WdTsEIcpoCeykh5dbDK hRpl9EONnJ1NxbFBtgiCjhSL5Y1E9EoBRrWHgc9WCteIRUnPI67wCvxwEJvw2qXWQhcG cF67NiN8a3e9xD4ipsC1Z5YCPNERXE4p4z0iju1rwSiyFI3mtkLxLPDHAnelvwMwFFSv X8gK7eK/aI1kFjemqNR0tyM3eRe7DiizJNxzH+2bfyWnDOpMXIfN+7hAwRVsXy5CEgRC tk4w== X-Gm-Message-State: APjAAAUh5m3adCaCNdoWnH0kqMrF0y1PkHRI76JsHvuGDuUPq04wrstx v3o4wZw1o31FwLrI8PkquKgWlg== X-Received: by 2002:a63:f754:: with SMTP id f20mr26935381pgk.162.1557686506891; Sun, 12 May 2019 11:41:46 -0700 (PDT) Received: from localhost.localdomain ([115.97.185.144]) by smtp.gmail.com with ESMTPSA id 37sm11041291pgn.21.2019.05.12.11.41.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 May 2019 11:41:46 -0700 (PDT) From: Jagan Teki To: Maxime Ripard , David Airlie , Daniel Vetter , Chen-Yu Tsai Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Jagan Teki Subject: [PATCH v10 1/2] drm/sun4i: sun6i_mipi_dsi: Fix hsync_porch overflow Date: Mon, 13 May 2019 00:11:26 +0530 Message-Id: <20190512184128.13720-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190512184128.13720-1-jagan@amarulasolutions.com> References: <20190512184128.13720-1-jagan@amarulasolutions.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Loop N1 instruction delay for burst mode devices are computed based on horizontal sync and porch timing values. The current driver is using u16 type for computing this hsync_porch value, which would failed to fit within the u16 type for large sync and porch timings devices. This would result in hsync_porch overflow and eventually computed wrong instruction delay value. Example, timings, where it produces the overflow { .hdisplay = 1080, .hsync_start = 1080 + 408, .hsync_end = 1080 + 408 + 4, .htotal = 1080 + 408 + 4 + 38, } It reproduces the desired delay value 65487 but the correct working value should be 7. So, Fix it by computing hsync_porch value separately with u32 type. Fixes: 1c1a7aa3663c ("drm/sun4i: dsi: Add burst support") Signed-off-by: Jagan Teki --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 6ff585055a07..bfa7e2b146df 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -457,8 +457,9 @@ static void sun6i_dsi_setup_inst_loop(struct sun6i_dsi *dsi, u16 delay = 50 - 1; if (device->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) { - delay = (mode->htotal - mode->hdisplay) * 150; - delay /= (mode->clock / 1000) * 8; + u32 hsync_porch = (mode->htotal - mode->hdisplay) * 150; + + delay = (hsync_porch / ((mode->clock / 1000) * 8)); delay -= 50; } -- 2.18.0.321.gffc6fa0e3