Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2616395ybh; Mon, 16 Mar 2020 06:38:53 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtgooHgU/hXDMb6sfqNzF16YZlrIqWItU4/3/LzpwhvF62VHvoVX0xtX4kTBIBj3fFH+Rmf X-Received: by 2002:aca:ac46:: with SMTP id v67mr17397305oie.62.1584365933244; Mon, 16 Mar 2020 06:38:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584365933; cv=none; d=google.com; s=arc-20160816; b=HVDKEdoOONdahqCYgZSEeqeizi1w07bWG0CIVBr9hbSuN5wPaFQkKdZEZoaquO3B6y sv+/5fiRcFAIGikrTjAcOCk6vSk2C6xmlGr3l97G4SXbP5b48JZcPmYBycfu/8AQx1rf qe5H2Y/VVtNaBS0hDpeP1gPb6SjibcCzbEL30F6ETP8Xnpot0hDaFIY64oj8c6DewRoP O7wfkkAf+RsECpZy2G9iYpo/IXv+eRi8HNwq1apD8u5n65L4h3CRydUQGcCFsI6Hl9FL gEzN744nFC4T4Hl4R5xfsraOuuz0/D3iRSCtTngThyaJFBF3wZnRbpS0d1uERDz0UsUb qAsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=I9YOqCvznKIa+lsR+6QqRxbL27UJzO8C40dZ4CFdKfA=; b=1E6VuB2E7fqGNcR3EiVFVqcTSmhBXgGcb6O5GXGXGq24IjH5N67UGc2r823gmr0fqb SYDjvhsN2XmRBLnllw1ocZ1K1ke2y1YK8LMkW3Njo1xkxnOPPbqQ0Rk3fcbRyiyZy/U2 odpkuE5ZG0QHT2u1gu8he+nZp9n0igG75Gmv8KdLWR2xT2s4YOaY2Yi2L5VzsSekeR+s 5o24Fce1fhVDyaXZi/vu+/XERY8shEIgPCwwzg0zYZo8oAHqpWKCWVN8/gVib/aAsJHR UqbC5b4UwR0/vDMTKNrOfYlPWA60m+3J8XD0g15uNRSznOyBgT8lci+v0s8DVcsgO/iz 6/Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aosc.io header.s=dkim header.b=quP9cKqY; 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 9si2727oir.76.2020.03.16.06.38.40; Mon, 16 Mar 2020 06:38:53 -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=@aosc.io header.s=dkim header.b=quP9cKqY; 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 S1731402AbgCPNh4 (ORCPT + 99 others); Mon, 16 Mar 2020 09:37:56 -0400 Received: from hermes.aosc.io ([199.195.250.187]:59233 "EHLO hermes.aosc.io" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731330AbgCPNh4 (ORCPT ); Mon, 16 Mar 2020 09:37:56 -0400 Received: from localhost (localhost [127.0.0.1]) (Authenticated sender: icenowy@aosc.io) by hermes.aosc.io (Postfix) with ESMTPSA id 904224CA5E; Mon, 16 Mar 2020 13:37:47 +0000 (UTC) From: Icenowy Zheng To: Thierry Reding , Sam Ravnborg , Rob Herring , Maxime Ripard , Chen-Yu Tsai , Ondrej Jirman Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, Icenowy Zheng Subject: [PATCH v2 4/5] drm/sun4i: sun6i_mipi_dsi: fix horizontal timing calculation Date: Mon, 16 Mar 2020 21:35:02 +0800 Message-Id: <20200316133503.144650-5-icenowy@aosc.io> In-Reply-To: <20200316133503.144650-1-icenowy@aosc.io> References: <20200316133503.144650-1-icenowy@aosc.io> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aosc.io; s=dkim; t=1584365875; h=from:subject:date:message-id:to:cc:mime-version:content-transfer-encoding:in-reply-to:references; bh=I9YOqCvznKIa+lsR+6QqRxbL27UJzO8C40dZ4CFdKfA=; b=quP9cKqYYDD232RMGPzPh7YZaHSfncJHKNCNVORZvb7EzFJyswyLBv7GzoCIM/6KvGiH5Z xbpDQs4fRsR5P/Cp7hTcnx+MoFGO3XV0SD6R82gTqKwejhi4j3ozUQiiIMTMC0P2NzAMb0 tDkRk8CMwU/bfv3YHZlXvgGaYrZkMd8= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The max() function call in horizontal timing calculation shouldn't pad a length already subtracted with overhead to overhead, instead it should only prevent the set timing to underflow. Signed-off-by: Icenowy Zheng --- No changes in v2. drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 059939789730..5f2313c40328 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -555,7 +555,7 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi, */ #define HSA_PACKET_OVERHEAD 10 hsa = max((unsigned int)HSA_PACKET_OVERHEAD, - (mode->hsync_end - mode->hsync_start) * Bpp - HSA_PACKET_OVERHEAD); + (mode->hsync_end - mode->hsync_start) * Bpp) - HSA_PACKET_OVERHEAD; /* * The backporch is set using a blanking packet (4 @@ -564,7 +564,7 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi, */ #define HBP_PACKET_OVERHEAD 6 hbp = max((unsigned int)HBP_PACKET_OVERHEAD, - (mode->htotal - mode->hsync_end) * Bpp - HBP_PACKET_OVERHEAD); + (mode->htotal - mode->hsync_end) * Bpp) - HBP_PACKET_OVERHEAD; /* * The frontporch is set using a sync event (4 bytes) @@ -574,7 +574,7 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi, */ #define HFP_PACKET_OVERHEAD 16 hfp = max((unsigned int)HFP_PACKET_OVERHEAD, - (mode->hsync_start - mode->hdisplay) * Bpp - HFP_PACKET_OVERHEAD); + (mode->hsync_start - mode->hdisplay) * Bpp) - HFP_PACKET_OVERHEAD; /* * The blanking is set using a sync event (4 bytes) @@ -583,8 +583,8 @@ static void sun6i_dsi_setup_timings(struct sun6i_dsi *dsi, */ #define HBLK_PACKET_OVERHEAD 10 hblk = max((unsigned int)HBLK_PACKET_OVERHEAD, - (mode->htotal - (mode->hsync_end - mode->hsync_start)) * Bpp - - HBLK_PACKET_OVERHEAD); + (mode->htotal - (mode->hsync_end - mode->hsync_start)) * Bpp) - + HBLK_PACKET_OVERHEAD; /* * And I'm not entirely sure what vblk is about. The driver in -- 2.24.1