From patchwork Mon Oct 7 05:01:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Marek X-Patchwork-Id: 13824059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A00DCFB440 for ; Mon, 7 Oct 2024 05:06:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A217310E2FD; Mon, 7 Oct 2024 05:06:03 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=marek.ca header.i=@marek.ca header.b="GPB+5gsM"; dkim-atps=neutral Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) by gabe.freedesktop.org (Postfix) with ESMTPS id D121010E2FD for ; Mon, 7 Oct 2024 05:06:01 +0000 (UTC) Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-6cb2f344dbbso32470246d6.3 for ; Sun, 06 Oct 2024 22:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marek.ca; s=google; t=1728277561; x=1728882361; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=roE3JMr9lMbeU1huQ5l+ymUGwxuvCsD8E2naNBrZpXE=; b=GPB+5gsMUts7+94TXsPX7NaA74weOfHaXCymS2WdbFhSJWsZ2iUjXexehePmvdOkTM +c8uB6nPEvpJM99tTqxdNZBkZ7PXTnUVWLzM46mb48tOzIp9LOIU3RBJLlu4W7hjis4B jaaFsjB5WO7UsDxvPGV3yRyFU+tLs3a7h6Aj2aM7FizUMnL7/45zc+T3PLZ76t/OSl0Z 1EXPYCWnOcWyFZGUbr7Z9gIiaAr0YUCtWt9nMm/Gd7uuP2B3ldFjcQT2FtVmtWiVII/5 OTGR7tk5ZozazsOMne8KBni4qOe8h9vPix45getJ01+mjH787w0T0pDJhif1865/Etz9 HgHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728277561; x=1728882361; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=roE3JMr9lMbeU1huQ5l+ymUGwxuvCsD8E2naNBrZpXE=; b=YnSvxth9tDXdzw1zlCKmpOcce7jUYN/b9lD+H2KExpJ1UQExXDJZA2hg4jmaXMXLIv OKpLf0kA5NP+YSQGg68rUlWUTtU4JeSunQbD7F0LFdhHA65xrxZMPMpr/SGdfx71bdkw s0AGqXWGrMeDRLcrwsfnDK98z96Z1s+0L52KMF9bBCaPhWSQu0iS2dRALuL9ZAeg/hK6 Om3ailjKGahz9TAgVUCS7eEACjOHf75q878Vl8EC5tNAtK+Q9t479R7G3qN+5CMmXeOU CULLaBvVTpk4BRGM1sBW4Ykwfm7M47bz4f69ZLz3KhIvH804/jJHy6hpujvqFT74tgxj zv0g== X-Forwarded-Encrypted: i=1; AJvYcCVehqFfcusZn5H299gzmdB/bBxw6WbbxPDznrMBgudSui/Z0Nf5+xLKzBHLODvhj9tVsDTO92cE2u0=@lists.freedesktop.org X-Gm-Message-State: AOJu0YzTxk8js93hHs7yGH/SU9g8SKBeoe00Zkq6mnIkFZkelWiGPjcf 5z2ZnUZjKsrfy2VDikaghaGW1JGvhumX99PMtQQWfVW8lNaWY3VgWvfBTJGm8tM= X-Google-Smtp-Source: AGHT+IEFqA0OIk3ks3aFd2muaztD8wK5Pr5n5CCRe39FVoqFWsj3k1MVbhTRHDeseeL2V/taCAEOOQ== X-Received: by 2002:a0c:f40a:0:b0:6c3:e231:960e with SMTP id 6a1803df08f44-6cb9a32e928mr162731146d6.17.1728277560758; Sun, 06 Oct 2024 22:06:00 -0700 (PDT) Received: from localhost.localdomain (modemcable125.110-19-135.mc.videotron.ca. [135.19.110.125]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cba476152asm22452216d6.126.2024.10.06.22.05.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2024 22:06:00 -0700 (PDT) From: Jonathan Marek To: freedreno@lists.freedesktop.org Cc: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Simona Vetter , Jessica Zhang , Konrad Dybcio , linux-arm-msm@vger.kernel.org (open list:DRM DRIVER for Qualcomm display hardware), dri-devel@lists.freedesktop.org (open list:DRM DRIVER for Qualcomm display hardware), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 1/2] drm/msm/dsi: improve/fix dsc pclk calculation Date: Mon, 7 Oct 2024 01:01:48 -0400 Message-ID: <20241007050157.26855-1-jonathan@marek.ca> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" drm_mode_vrefresh() can introduce a large rounding error, avoid it. Fixes: 7c9e4a554d4a ("drm/msm/dsi: Reduce pclk rate for compression") Signed-off-by: Jonathan Marek Reviewed-by: Dmitry Baryshkov Reviewed-by: Abhinav Kumar --- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c index 185d7de0bf376..1205aa398e445 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_host.c +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c @@ -542,7 +542,7 @@ static unsigned long dsi_adjust_pclk_for_compression(const struct drm_display_mo int new_htotal = mode->htotal - mode->hdisplay + new_hdisplay; - return new_htotal * mode->vtotal * drm_mode_vrefresh(mode); + return mult_frac(mode->clock * 1000u, new_htotal, mode->htotal); } static unsigned long dsi_get_pclk_rate(const struct drm_display_mode *mode, From patchwork Mon Oct 7 05:01:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Marek X-Patchwork-Id: 13824060 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 451B5CFB442 for ; Mon, 7 Oct 2024 05:06:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AC52910E300; Mon, 7 Oct 2024 05:06:06 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=marek.ca header.i=@marek.ca header.b="B2I6YJoi"; dkim-atps=neutral Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6D35D10E2FF for ; Mon, 7 Oct 2024 05:06:05 +0000 (UTC) Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-6cb399056b4so33431526d6.0 for ; Sun, 06 Oct 2024 22:06:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marek.ca; s=google; t=1728277564; x=1728882364; darn=lists.freedesktop.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c05QmqKO8Yo45LGADbAWzf+kRfAr29i9++XErp7UJmk=; b=B2I6YJoiSi/Dc3kepdyccPY+Yz+6x6+vEOoY0TV/ubj/YueqkNAaEYmY8BisBDc1Et 2q2AIP0IMk8/GswXkBNskXVWyIKPSRyEmzgBZUpNaDhbI3fsmwitMDmSi790zw2N+EDQ aVBhnOyLYZx5m0pCk0KcwJ3B6vyyhRFypclpMF/Ug5h2p5dt+k788fs3TAFTozcOXjzj 7ycA2YKQMRDkKe2acdoTXziuvDm1XvCEEjPs46wAeNEAqg3LxbwMSVwyvq8e8Ull5WF9 bAWXIpbbYTE55oanGdmFDWTp+un3Qoc8sUvWC6OVyue3CqW572BdE7q8lO+a7loA/KWR HwOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728277564; x=1728882364; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c05QmqKO8Yo45LGADbAWzf+kRfAr29i9++XErp7UJmk=; b=cJuAyzpgLLEvHIlTeEtYN7GFexAjDy9K6GuS7ZVfJXscJHKs+Nf5yG1ufhQwzlbGWd k7wkmkUu1HDNPSQ3p5/+yGx8JsCwj8OzNCIpOqHzCBuH8XRWTAdepLLg29W5HIih917j SZw6PwaU4+33OM06h/HP3QYKGNsWaoFsAJgWEz1RH4khNMHwVzjS0sXLi9/qb0d64CAC H8xnLF0Reunmi6BLGMC0emllDZovBBbDhI+Dh+krJkE5yLdQCvE+C4zSziwEHX0BhlgV IUKVrpeDbTpUKJ9VeVTVPUk04YjwpP5VEP8PuQELh1z6fZR0SL258TxB7tO/vs2abajv lwGw== X-Forwarded-Encrypted: i=1; AJvYcCUHkG2nsVWQhpf7nckIY0Su/Lh4vtVoMtT0803QN/N7dqdkX04A47pFif7+nkrSegPDhpqh/4IAz2o=@lists.freedesktop.org X-Gm-Message-State: AOJu0YzMxfY1kw0X11dqzQFGVTCZweUfTa8FthJzygLvnEUeFsU1eDHn J5O6amtw7g8AHXQyfIuHWG86s/Rg/2NYDMqcBsHjAHeBf+5lV/roGdFeg7FGm78= X-Google-Smtp-Source: AGHT+IEWxrxm89ar9oCXwy8ju2UWdzVDET69V1sE10TCiENXP3CF9q530YGphHlLEbICHowgYDYfMA== X-Received: by 2002:a05:6214:3bca:b0:6cb:2242:df32 with SMTP id 6a1803df08f44-6cb9a2ff311mr159433696d6.20.1728277564552; Sun, 06 Oct 2024 22:06:04 -0700 (PDT) Received: from localhost.localdomain (modemcable125.110-19-135.mc.videotron.ca. [135.19.110.125]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6cba476152asm22452216d6.126.2024.10.06.22.06.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Oct 2024 22:06:04 -0700 (PDT) From: Jonathan Marek To: freedreno@lists.freedesktop.org Cc: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Simona Vetter , Jessica Zhang , Konrad Dybcio , Sibi Sankar , linux-arm-msm@vger.kernel.org (open list:DRM DRIVER for Qualcomm display hardware), dri-devel@lists.freedesktop.org (open list:DRM DRIVER for Qualcomm display hardware), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 2/2] drm/msm/dsi: fix 32-bit signed integer extension in pclk_rate calculation Date: Mon, 7 Oct 2024 01:01:49 -0400 Message-ID: <20241007050157.26855-2-jonathan@marek.ca> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20241007050157.26855-1-jonathan@marek.ca> References: <20241007050157.26855-1-jonathan@marek.ca> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" When (mode->clock * 1000) is larger than (1<<31), int to unsigned long conversion will sign extend the int to 64 bits and the pclk_rate value will be incorrect. Fix this by making the result of the multiplication unsigned. Note that above (1<<32) would still be broken and require more changes, but its unlikely anyone will need that anytime soon. Fixes: c4d8cfe516dc ("drm/msm/dsi: add implementation for helper functions") Signed-off-by: Jonathan Marek Reviewed-by: Dmitry Baryshkov Reviewed-by: Abhinav Kumar --- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c index 1205aa398e445..a98d24b7cb00b 100644 --- a/drivers/gpu/drm/msm/dsi/dsi_host.c +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c @@ -550,7 +550,7 @@ static unsigned long dsi_get_pclk_rate(const struct drm_display_mode *mode, { unsigned long pclk_rate; - pclk_rate = mode->clock * 1000; + pclk_rate = mode->clock * 1000u; if (dsc) pclk_rate = dsi_adjust_pclk_for_compression(mode, dsc);