Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp67102rwi; Sun, 9 Oct 2022 18:38:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6A2DgNJWO8jntv769UGZaxDSUDKvJN17i6qsc0HVjCTEe933UrtLdtmPEsvUXLmNWGRUeb X-Received: by 2002:a17:90b:3b47:b0:202:a81f:4059 with SMTP id ot7-20020a17090b3b4700b00202a81f4059mr29457985pjb.150.1665365893093; Sun, 09 Oct 2022 18:38:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665365893; cv=none; d=google.com; s=arc-20160816; b=APfqndmky7TaOSGXOTZGjwq6Jn2KltJ7t0u3iAIfc1LakXmEoAi9Tv+WAFTKSGIlGx NYpz4kU7LDGTSveBRwf8Az4dpAfsiBkQXEowgbP7wHpjkKMzYK22tfFJoitQOx4/qaEj F297XiiGVOZkNxVqu36pswDQPaT2Zd6oB73eyvspZEKIK3UZaEpK9Lrm1S43sw5bvZVX X62RdvkmPMKV8jvAGBLlhcD8YI30dRBnuFReBWLiYpz4vQnVbgX0HDPEiDK10Qi4AyTk rNZxcG08Hj3Ay6G8/E81/X/JEQYEY/Mmo+hvgaJ7B2qI8NVECf66W97vrmHHuAaSMJtS 6PAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EOHZ/C2sGLzAOqAVEzTfcy1PhIkdX5F4TY+qivuWJig=; b=O1QBm7n3H3Hu30prlmf235saIeDXEZSzCNIgmm9c8MqQHDt9Dq9cK8k0itsYbtxvPp hHY02w+W/kKcqAjB8PKUAcvSEzsICL2uTC6bMNkhWBbDrN+T/c2OldmlJN2Q4qgPoJQp J1VtrauvkfPNAXLdvvgFwDory/jOiBjqMxKp5RcV+TevqeLyOnB0il7R+d263Yh+Na/c oK0YM7GSgpgtgjuz/jWQipvTmxsd8BzzF9vSJY7umymNeIcp0Cg+sqL7nuBCspJHKRN6 sUgCTzUnpiFDwkk6NIuvaQ5K1M1XLfMZV8mVj/PGDSAjebIBx6azRcvYCEQD5cSdP9Q2 E4XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C6bj9ZKL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w18-20020a170902e89200b0017f93a4e32dsi11668141plg.0.2022.10.09.18.38.02; Sun, 09 Oct 2022 18:38:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C6bj9ZKL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233276AbiJJA3P (ORCPT + 99 others); Sun, 9 Oct 2022 20:29:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232952AbiJJAX4 (ORCPT ); Sun, 9 Oct 2022 20:23:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7143E2FFED; Sun, 9 Oct 2022 16:57:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0DBAA60C57; Sun, 9 Oct 2022 23:57:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E00D7C433C1; Sun, 9 Oct 2022 23:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665359874; bh=IqXIc2zb1gPqjZAiZAuDXqBufstMjobSxTTlD79UXjo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C6bj9ZKLOmLY6A3mq/CyShhW5QQdWxdXqwVpCB17oM7RGAPUbjcLaS8i3n94iEHJ7 5LX1xVNhNeu2zhy1g8GMPs10o7D5EWqaw/zSr1Yte+KvzJuSDsiEVrRhR9G3xqkDnK KJpDJVlsYfm0udwvpj6GV5xYBAP/w7VP8Jz1e+tm/VnW+bZ/aYLDgdQbhltTUhiYSA akwDpSRPxflbQoU1eBdjx4Jc3kvKdAvG0bVt5EqpBPm6lbu18nDIBSXRK8G2ubJsMF 5ZoOFw/ZLSI0pxu0wu/KC6oqirhEGct7/OfBpIJKyblMXQTAgoUMT5IqkWA59FEp8t crAbbt9OL6J9w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: David Gow , Tales Aparecida , Alex Deucher , Sasha Levin , harry.wentland@amd.com, sunpeng.li@amd.com, Rodrigo.Siqueira@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, isabbasso@riseup.net, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 4.19 03/10] drm/amd/display: fix overflow on MIN_I64 definition Date: Sun, 9 Oct 2022 19:57:38 -0400 Message-Id: <20221009235746.1232129-3-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009235746.1232129-1-sashal@kernel.org> References: <20221009235746.1232129-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Gow [ Upstream commit 6ae0632d17759852c07e2d1e0a31c728eb6ba246 ] The definition of MIN_I64 in bw_fixed.c can cause gcc to whinge about integer overflow, because it is treated as a positive value, which is then negated. The temporary positive value is not necessarily representable. This causes the following warning: ../drivers/gpu/drm/amd/amdgpu/../display/dc/dml/calcs/bw_fixed.c:30:19: warning: integer overflow in expression ‘-9223372036854775808’ of type ‘long long int’ results in ‘-9223372036854775808’ [-Woverflow] 30 | (int64_t)(-(1LL << 63)) | ^ Writing out (-MAX_I64 - 1) works instead. Signed-off-by: David Gow Signed-off-by: Tales Aparecida Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/dc/calcs/bw_fixed.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/calcs/bw_fixed.c b/drivers/gpu/drm/amd/display/dc/calcs/bw_fixed.c index 6ca288fb5fb9..2d46bc527b21 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/bw_fixed.c +++ b/drivers/gpu/drm/amd/display/dc/calcs/bw_fixed.c @@ -26,12 +26,12 @@ #include "bw_fixed.h" -#define MIN_I64 \ - (int64_t)(-(1LL << 63)) - #define MAX_I64 \ (int64_t)((1ULL << 63) - 1) +#define MIN_I64 \ + (-MAX_I64 - 1) + #define FRACTIONAL_PART_MASK \ ((1ULL << BW_FIXED_BITS_PER_FRACTIONAL_PART) - 1) -- 2.35.1