From patchwork Sat Oct 5 14:38:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Marek X-Patchwork-Id: 13823300 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 1DF8CCF34C4 for ; Sat, 5 Oct 2024 14:43:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 389C810E0A4; Sat, 5 Oct 2024 14:43:08 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=marek.ca header.i=@marek.ca header.b="JGLHk3zu"; dkim-atps=neutral Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8756B10E0B5 for ; Sat, 5 Oct 2024 14:43:06 +0000 (UTC) Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-7ae6f77f3a0so167740485a.1 for ; Sat, 05 Oct 2024 07:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marek.ca; s=google; t=1728139385; x=1728744185; 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=9jvG7B8d1XuNSMX2AC6pIuFzaK4tQX72GKOrHfdpQSI=; b=JGLHk3zuc8Wc3BQcVDUPxjNCjzpopZo721LCm05/zMkwlBhPk880tWM8urK8iL63L9 KRVzvSLdrjBVHTNvnp/ohjH2/RaR7PcJbqDL7s+CTOyMvnvFzB7Y3cyVxcUpFVST4J9q lBIVA6HEb6I9vnZnCTElpXVQ8a8sb8YpkxURZ/0nezs+Nsqub/jD/G+AvKcyfVRxk8pZ hXuRAVDlAO8VzN/k3x+BzPZJjNd4M4NUfOyur0I0b07kOvVtd67UvkNT+bjpkGdnJAZ1 6B5Ud4ot5mFGnhcJs1DVa6tgv4ErOmoHOY7Kk/E91OOGbdDDjQOsPssxV9Jvg7qi4H3W yscQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728139385; x=1728744185; 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=9jvG7B8d1XuNSMX2AC6pIuFzaK4tQX72GKOrHfdpQSI=; b=WhqedLDKp6t6i3DRojnowNZGyPf3OjBiDCaJ5W1yC5b67LdY9XH7ArtcBz9OCJOuvx UNZdo9hph6MtodBjo7mLMW0X25BY/kXOimHiLc0VkSFLoeZRWrZHQk/MVSK4InwWsVg/ 4DNnF3CZ7WnPVHj4kj3mv2yHsSX7b4FBfUZyh5lYmVhCGJ2SZtTmLLcCBAmbN0ibGhOq nA+bCMyC58ExRIjinfsLhMEhWcU1t9r9hajVjeph13LLBtm9xQ5Ls+Z603bU1d0SJY8S El/4gSDw3LAiOEEkloZNJa7uVdThZCZAe7dYmsO0FkZ4HJEKdGZqcCAWb4abmmy7ja4s Sg+w== X-Forwarded-Encrypted: i=1; AJvYcCWzJeWCj2kQ+XLiBxD/L8a1533DNzGSBEFxIHR3/H6GVh1Dl1stHBIyo3RdvILbDZwvb6aqLzxrzIg=@lists.freedesktop.org X-Gm-Message-State: AOJu0YxhiCGz8LhnRItqpPQ4JF1aqrKlZxZzpsLJelJ6J6ZXoZBF6dYI VqtoHSiN238J+IL9rPnFJL5UwVlaIc0gbXwaAtxHzszfP9K7EQyt5BHnXN/Wvvw= X-Google-Smtp-Source: AGHT+IG4yLQuqZlhB/sDECpjfl6wbKTckYqFqL/GvxMFZI5CjeRNaknjtbVKfLUd5sUZjtNEqkV/ag== X-Received: by 2002:a05:620a:4441:b0:7a2:c13:458d with SMTP id af79cd13be357-7ae6f48868bmr934680785a.42.1728139385226; Sat, 05 Oct 2024 07:43:05 -0700 (PDT) Received: from localhost.localdomain (modemcable125.110-19-135.mc.videotron.ca. [135.19.110.125]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45da74e9fdasm9072351cf.31.2024.10.05.07.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 07:43: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 , 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 1/2] drm/msm/dsi: improve/fix dsc pclk calculation Date: Sat, 5 Oct 2024 10:38:09 -0400 Message-ID: <20241005143818.2036-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. Signed-off-by: Jonathan Marek --- 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 Sat Oct 5 14:38:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Marek X-Patchwork-Id: 13823301 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 5C096CF34C4 for ; Sat, 5 Oct 2024 14:43:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9C27110E0B5; Sat, 5 Oct 2024 14:43:11 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=marek.ca header.i=@marek.ca header.b="Q1M+1p/9"; dkim-atps=neutral Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5B6A710E0C8 for ; Sat, 5 Oct 2024 14:43:10 +0000 (UTC) Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-45812fdcd0aso35507731cf.0 for ; Sat, 05 Oct 2024 07:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marek.ca; s=google; t=1728139389; x=1728744189; 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=/q3v6t9jn9wO97ckfMU06Nl7EyqPnybN5v1LXUZU22Y=; b=Q1M+1p/9sDWvrDr8U3yXKG1I/EqsB0JBKSA7XbHK39mGjtayQxlTVd35nHfxl/TUY2 nByjiZI42IJOhbyVXeWbkaqc8ZFOtnzfkIJ9Fy0pxIgXHiA272G69eAc/zpnA/xMfdlq CAwcq3uNF/EcznybILXsBDsbtn01y2Hk0VixChZGhcwh02u/o93PwIo8Nzw0aKdF4Bd6 FDGLrfh7fSuiKKb1r+qRxoYc9F6xZm8T7zx0+qm0XMuE5rsjCuCGihZhrx2RcthIQrr3 yWRCPSlQrl3qr9MgllXhLOB2/UyF/QMzaNnZwjmuOcs+Qp5lpY2RhZYbCcXOUXrIKXDR Mu3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728139389; x=1728744189; 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=/q3v6t9jn9wO97ckfMU06Nl7EyqPnybN5v1LXUZU22Y=; b=G3b055XqPUrs0+qy2bSt0clmFApbfiFB35Fct2bj8vtAUjwW+wdsct6J4a3vaOW6vx KfRdrHcYO1zDnhQjzTQjOcC0yolm7ap9g07ro5mn4sO5yHnEZ4XL8G8NDUW+L0mF5BQ9 8J1kSuPr7kOmnJMmQz2d6WuEFdpvk2nRWtJDVUuFk2FMKCplvSNqBmrhFR7FiZuGBD1q LJVItFpQxtC+gL9Ff245IX16Yd7Dw/wzpUWlH/TF82w66AweZ1oaKXAP5gcZi5HUJyks A9NJwQZIvYGze0bGAw/k85zlClPnTMoKQIu8xOL5qg+TKAn2MSXC7H+wyIzscdE1zwyC KTKQ== X-Forwarded-Encrypted: i=1; AJvYcCVMPfnvDb4T0f5jRqo5XDpPEQJlk/k4dkXraCCEyefYZTvRa0Q9Wy/DUqLqZoCg92+l1ooZRifWNNQ=@lists.freedesktop.org X-Gm-Message-State: AOJu0Yxxbo4nWGBE32opcKbmceYrytaHYl6IU05orG7Pw8z/9E7CmEoV /kr3cHn/Kxk/Zmjtpf3rQDkEYIGN9FyNPwkvn+vJr+xlmzWJgiz86f3n5ErPMyQ= X-Google-Smtp-Source: AGHT+IEWb5+x3Y3IeQmM4IyDOj16+X6mmg0F0tQXBBJrX9v3mbYYdikTmesnSGEJYTvU+WKfBsip3g== X-Received: by 2002:a05:622a:142:b0:459:a824:a1c2 with SMTP id d75a77b69052e-45d9badbcdfmr100318231cf.22.1728139389155; Sat, 05 Oct 2024 07:43:09 -0700 (PDT) Received: from localhost.localdomain (modemcable125.110-19-135.mc.videotron.ca. [135.19.110.125]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45da74e9fdasm9072351cf.31.2024.10.05.07.43.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 07:43:08 -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 2/2] drm/msm/dsi: fix 32-bit signed integer extension in pclk_rate calculation Date: Sat, 5 Oct 2024 10:38:10 -0400 Message-ID: <20241005143818.2036-2-jonathan@marek.ca> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20241005143818.2036-1-jonathan@marek.ca> References: <20241005143818.2036-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. Signed-off-by: Jonathan Marek --- 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);