From patchwork Wed Feb 26 20:28:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vitaliy Shevtsov X-Patchwork-Id: 13993159 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 507CEC19F2E for ; Wed, 26 Feb 2025 20:30:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0640110E9E7; Wed, 26 Feb 2025 20:30:18 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=mt-integration.ru header.i=@mt-integration.ru header.b="t/KmLHxg"; dkim-atps=neutral Received: from ksmg01.maxima.ru (ksmg01.maxima.ru [81.200.124.38]) by gabe.freedesktop.org (Postfix) with ESMTPS id A697510E9E7; Wed, 26 Feb 2025 20:30:16 +0000 (UTC) Received: from ksmg01.maxima.ru (localhost [127.0.0.1]) by ksmg01.maxima.ru (Postfix) with ESMTP id 44CC9C001A; Wed, 26 Feb 2025 23:30:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 ksmg01.maxima.ru 44CC9C001A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mt-integration.ru; s=sl; t=1740601814; bh=2KT/ScqJnpt/ZJ3+IQvKjosQnxz+MuCoyqiJa/Langg=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=t/KmLHxgqDueZXfCEAbw/htWLYZWK4igPvAAbUFtQOPavHXhOjupDNYC6RtXuOqyH nQyDHwo/T0zdhHgY7xHr9bKJYOb29CkLRe9/YvGKtsXBNph55zx18cm8ohrCHLJKrU /z7l/czJLg2/CdFwhF6TSl44/0UWcNhOyXXmSOTxHFxNoz2xc8tAo+P+mGfouQ+GaG HvdM5xApsRBtvAKb4I5/UM2v/ValJAgZgy6vrS8eUvuCVNnTkXt+MQOFcQ8E5KCF68 t+FgqAPBl3oVT07GBUNUcYQ67uFD0KBM99pxZ6RDJCYs2wT3oXVlJCAv5kzGNEskgr 82d5sbhsKjFLw== Received: from ksmg01.maxima.ru (mail.maxima.ru [81.200.124.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.maxima.ru", Issuer "GlobalSign GCC R3 DV TLS CA 2020" (verified OK)) by ksmg01.maxima.ru (Postfix) with ESMTPS; Wed, 26 Feb 2025 23:30:14 +0300 (MSK) Received: from localhost.maximatelecom.ru (178.236.220.144) by mmail-p-exch01.mt.ru (81.200.124.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.4; Wed, 26 Feb 2025 23:30:13 +0300 From: Vitaliy Shevtsov To: Chaitanya Dhere CC: Vitaliy Shevtsov , Jun Lei , Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , Xinhui Pan , David Airlie , Simona Vetter , Alex Hung , Fangzhi Zuo , Aric Cyr , , , , Subject: [PATCH v3] drm/amd/display: fix type mismatch in CalculateDynamicMetadataParameters() Date: Thu, 27 Feb 2025 01:28:51 +0500 Message-ID: <20250226202853.13319-1-v.shevtsov@mt-integration.ru> X-Mailer: git-send-email 2.48.1 MIME-Version: 1.0 X-Originating-IP: [178.236.220.144] X-ClientProxiedBy: mt-exch-01.mt.ru (91.220.120.210) To mmail-p-exch01.mt.ru (81.200.124.61) X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Auth: dmarc=none header.from=mt-integration.ru; spf=none smtp.mailfrom=mt-integration.ru; dkim=none X-KSMG-AntiSpam-Envelope-From: v.shevtsov@mt-integration.ru X-KSMG-AntiSpam-Info: LuaCore: 51 0.3.51 68896fb0083a027476849bf400a331a2d5d94398, {rep_avail}, {Tracking_from_domain_doesnt_match_to}, ksmg01.maxima.ru:7.1.1; 127.0.0.199:7.1.2; 81.200.124.61:7.1.2; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1; mt-integration.ru:7.1.1, FromAlignment: s, ApMailHostAddress: 81.200.124.61 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiSpam-Lua-Profiles: 191329 [Feb 26 2025] X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Version: 6.1.1.11 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.1.8310, bases: 2025/02/26 17:13:00 #27470398 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: NotDetected X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 7 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" There is a type mismatch between what CalculateDynamicMetadataParameters() takes and what is passed to it. Currently this function accepts several args as signed long but it's called with unsigned integers and integer. On some systems where long is 32 bits and one of these unsigned int params is greater than INT_MAX it may cause passing input params as negative values. Fix this by changing these argument types from long to unsigned int and to int respectively. Also this will align the function's definition with similar functions in other dcn* drivers. Found by Linux Verification Center (linuxtesting.org) with Svace. Fixes: 6725a88f88a7 ("drm/amd/display: Add DCN3 DML") Signed-off-by: Vitaliy Shevtsov Reviewed-by: Alex Hung --- v3: Update the description to include int in addition to unsigned int. v2: Change DynamicMetadataLinesBeforeActiveRequired type from unsigned int to int as per Alex Hung's observation. Add Fixes tag missed by chance. .../amd/display/dc/dml/dcn30/display_mode_vba_30.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c b/drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c index cee1b351e105..f1fe49401bc0 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn30/display_mode_vba_30.c @@ -281,10 +281,10 @@ static void CalculateDynamicMetadataParameters( double DISPCLK, double DCFClkDeepSleep, double PixelClock, - long HTotal, - long VBlank, - long DynamicMetadataTransmittedBytes, - long DynamicMetadataLinesBeforeActiveRequired, + unsigned int HTotal, + unsigned int VBlank, + unsigned int DynamicMetadataTransmittedBytes, + int DynamicMetadataLinesBeforeActiveRequired, int InterlaceEnable, bool ProgressiveToInterlaceUnitInOPP, double *Tsetup, @@ -3265,8 +3265,8 @@ static double CalculateWriteBackDelay( static void CalculateDynamicMetadataParameters(int MaxInterDCNTileRepeaters, double DPPCLK, double DISPCLK, - double DCFClkDeepSleep, double PixelClock, long HTotal, long VBlank, long DynamicMetadataTransmittedBytes, - long DynamicMetadataLinesBeforeActiveRequired, int InterlaceEnable, bool ProgressiveToInterlaceUnitInOPP, + double DCFClkDeepSleep, double PixelClock, unsigned int HTotal, unsigned int VBlank, unsigned int DynamicMetadataTransmittedBytes, + int DynamicMetadataLinesBeforeActiveRequired, int InterlaceEnable, bool ProgressiveToInterlaceUnitInOPP, double *Tsetup, double *Tdmbf, double *Tdmec, double *Tdmsks) { double TotalRepeaterDelayTime = 0;