Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp15460rwi; Sun, 9 Oct 2022 17:31:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7bFGt6h7ormJqua+Nxj35Z2vQitffzRtvi4zgF+NBI8n7g1/bSzDc9j9dFFFZq34cfrATc X-Received: by 2002:a05:6402:e01:b0:442:dd7e:f49d with SMTP id h1-20020a0564020e0100b00442dd7ef49dmr6895213edh.355.1665361907143; Sun, 09 Oct 2022 17:31:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665361907; cv=none; d=google.com; s=arc-20160816; b=VOsipjRgEFeAiLIU20N4IXnhea3kCLALAZfY5/HR9VPl7GCTNGMK4+I+noCuCCMB2M eJWYFv65o8YvYWFRPmi9X79bVbK32MH5AOmAl4xQW7469vh3bGukX4lDdsqpSVMlhtgu chAwyt3cT6e6KJxhHvv8B+WzXmnDz+5690GwNUwxFh/xcG6YQFBtUIGmTCygHsjFkatw HUhjPGBIAewvVPioBEdLoWujSVJZmPgmEQ5RE7LsGV+gsA4qbGO4pfjlDrbli4pnBraq sCEQVF+Uw6EvRLkmWVr+zRO7deUrarNAUw0Yzwv8hKGJ+mSeqPilOzJatQQdPoQ3yceq uk6A== 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=bRi825BJFtJS77d0JuQrRf8Ck1z5F8lIdAOHcbOOBXeHNbJSODfcasLsPO0fUqITp7 1JmXsXOewZxDJoA5yTj/oVgRBUUg8kR3HBzwiJIcz8IK6hFx9BsXGeH1E3taIH2i2znS qpXi8lBVZiamMxhmp+SCQRH4eXC4323OZmLqalAfZNZlH3gSqYxeoM5rRVfQUoDhmE1z 17FBtVn9v69IaKhsQojDhp4H6dLAf/rDWYSr3blx7zrcISPEA7w7J7S6NHr0533duTTX iG1m/xvmx+tXYaQudK1fSRkH8YqxiOjaJb2wfLRCQU/P4jFL88Ec0j57B2aL9ssaGrIg hppA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="dpK/egfx"; 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 mp16-20020a1709071b1000b00781b66e7065si9967272ejc.240.2022.10.09.17.31.20; Sun, 09 Oct 2022 17:31:47 -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="dpK/egfx"; 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 S232328AbiJJA1s (ORCPT + 99 others); Sun, 9 Oct 2022 20:27:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232887AbiJJAXv (ORCPT ); Sun, 9 Oct 2022 20:23:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91C1024BF7; Sun, 9 Oct 2022 16:57:21 -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 2DFC060B85; Sun, 9 Oct 2022 23:57:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09364C433C1; Sun, 9 Oct 2022 23:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665359840; bh=IqXIc2zb1gPqjZAiZAuDXqBufstMjobSxTTlD79UXjo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dpK/egfxR0KAF1sLE1MtIehLgA6F3ktG2f6xSU8K4Ouy+NVC5rYFuqysZUXKB+2as hUrLumcy5wMrad34Q3M0zUmJL2i0cjlelktx+sroenSAIqapd8e52AVfL0mBXxMW/G vzU/k8cm/4VPkMIP5MhYtwnQOZRkTYlkgj4bPPVgmUGF+f7EiGlcKkJ8/abxiXPrR2 B0xwMZfzBm7vaFNpGmoyvaNT1lkGJJfDc6nrSPP2/orP5xnGVooVcQalZLiz+xX8nb YQb7K3xcG3+vPWWg8sSGSiv5OD+mRbbYxqM6ta9olIgPn49MQReCG9dMbiAevlV2ik TTXtl4xakKEuA== 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 5.4 04/14] drm/amd/display: fix overflow on MIN_I64 definition Date: Sun, 9 Oct 2022 19:57:00 -0400 Message-Id: <20221009235710.1231937-4-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009235710.1231937-1-sashal@kernel.org> References: <20221009235710.1231937-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