From patchwork Sun Mar 3 17:35:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 10837171 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0498E1575 for ; Sun, 3 Mar 2019 17:36:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC7E929B73 for ; Sun, 3 Mar 2019 17:36:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C319D29FBA; Sun, 3 Mar 2019 17:36:28 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7125F29B73 for ; Sun, 3 Mar 2019 17:36:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ItJZP8qgeBrXLmldKg0Qo/kVUttwcH3hEF/4Lq8zqDk=; b=Ard9kkfTovbwIU cZZKiBNGhggsCkWFKUWLPz1EMcdZUYFOL/RkCpaUjsH5vqXiPvbex8PSbcOaWe31AV+tsrcQtr5J8 SjSIIsB67DQ9IuhRPWcbRaNdhqRfcjq2KsU2BfboO/oreN8EnbFt8+n3vFImt5chcOyVRgf6QdX3I x1znfeeJoZNHfPPtfZNUNR3f9434wkjlS1Fdg9vzaJLfdAxEVZVlTa6EAxWi5WiIuhDDbWvlJW6YI 4RqIoR7vG82VYU+J0usuCgRaMFddww8T9dRvL19zvLbMsqgrEBcACuTon3NdetJAaEEk+dHoIqOOJ qLiLS77qk16gYY1qrmIA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0V2G-0001uU-TM; Sun, 03 Mar 2019 17:36:24 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0V2A-0001hj-PP for linux-arm-kernel@lists.infradead.org; Sun, 03 Mar 2019 17:36:22 +0000 Received: by mail-pl1-x644.google.com with SMTP id v11so1358088plg.9 for ; Sun, 03 Mar 2019 09:36:16 -0800 (PST) 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=YvQ56Xx1Bmp0kWQNDK2nAiI9K4YgbqYzq9u72/Tb/Wo=; b=LflUIddUoNDPr+yhSqv8YqZrx+sPJX8q6IeVAKXozXBQmd+7QqdF5FC/Nnfuh4HgEb P0P7322O1SSJswkLmEli+W4c4fUmqaQsvLpS23zbRTSmaNeBpt5i1mKVUS9aYaD6d08r 50szGzTOFiwKeoS4HmqpCI/fn6Ka88k8gLleo= 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=YvQ56Xx1Bmp0kWQNDK2nAiI9K4YgbqYzq9u72/Tb/Wo=; b=f289XbpZ8Rhkr1Fv7zZRK5QPfxY1xcZu8VSNVAiWcBnPTgMtZ0JYnQvAXnNdcDfuD4 i55rEZ0Dkr0clA8upX7IjU7ukfa+2TL+CflFRcl2xSXJP5ca1grbsFcY2npTAIwcM21Y ktXlS+/+eRj3ImIICMTLgsAydS/WMsZEdEtj4wb3XWR3VWcVL6afjrExBf2CA+/b4sPd 2Dvvjt5ep+27oRC+B5FHsxIINgveJngdx6hbneIqvoE5MaYgrihaokQTPcLZVHr9n69w ENuplLojLNYQ+bwruQccs0URlINRqs6t/sqj9l+VWP0PQq4uV/LmQcWiRNfqiZs3Y+O5 IzHg== X-Gm-Message-State: APjAAAUji+/ZpO6/At8e6duhboW7c+1R5SPDje9AzJQd3d6kY2Xr1MCZ T9WGYFfTtvWtNrjQXDmxUc81lA== X-Google-Smtp-Source: APXvYqwMfcEqRj8CRJW1LCxN3K8d+OryA2fDRcxHfLMc10INVG90SRQRlL8++UlhSKwM0Kz41FXC0Q== X-Received: by 2002:a17:902:52c:: with SMTP id 41mr16382818plf.331.1551634575454; Sun, 03 Mar 2019 09:36:15 -0800 (PST) Received: from localhost.localdomain ([115.97.184.151]) by smtp.gmail.com with ESMTPSA id d129sm5614737pgc.59.2019.03.03.09.36.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:36:14 -0800 (PST) From: Jagan Teki To: Maxime Ripard , David Airlie , Daniel Vetter , Chen-Yu Tsai Subject: [PATCH v9 1/5] drm/sun4i: sun6i_mipi_dsi: Fix hsync_porch overflow Date: Sun, 3 Mar 2019 23:05:23 +0530 Message-Id: <20190303173527.31055-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190303173527.31055-1-jagan@amarulasolutions.com> References: <20190303173527.31055-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190303_093619_117503_3E14EA0A X-CRM114-Status: GOOD ( 13.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-sunxi@googlegroups.com, Jagan Teki , Michael Trimarchi , linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Tested-by: Merlijn Wajer --- 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..465e7fc57899 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); + + delay = ((hsync_porch * 150) / ((mode->clock / 1000) * 8)); delay -= 50; }