Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp31787019rwd; Fri, 7 Jul 2023 04:34:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlH5bwdiiMuVDF69ZtsaBTyBrKdAFYkiHO7Fns3//XMSHcnCqnGRMC8ZdIP9jiliyfsBUmgA X-Received: by 2002:aca:6546:0:b0:3a3:c743:83dc with SMTP id j6-20020aca6546000000b003a3c74383dcmr4042224oiw.59.1688729692791; Fri, 07 Jul 2023 04:34:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688729692; cv=none; d=google.com; s=arc-20160816; b=lKJstFVqX5l1fEITJ6N0dIvrKiq73l51SsfjMe05bU18NnKfqeZf2KPnDxb0IHl550 8W8ianUBwesZ2Ue0lgr+ZX/ZyD3moYnSDtHVGAJpBUty7dU3CfJaslaxH/fxXJGItbJF baRwo/RFfepMjW7RS11URppKRlX3kZN/I59JPCSpT0NpECWN/fEgVhWBTN47EYslsmMv zLqZ9QL8BLwgJH0wKdCh5Qxx6UTV77M/47VrtjoVKHWuzb72pNsN4XD3VQ4axH+qBEx0 ppsFv2PQgPNzKjKGn1mtl8gF32d79CEdMfuY6IisnYMJgkcTyd2lkPPdHXrN61/PY1td 4/qA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=UO4Jqirl0pycOYvWsCNy1c0mecVw5e6Z/N6VcWeSR/c=; fh=rrfIMZMddYzXFRHEcy15luYyB9OQGjbq7EI87EvSJfA=; b=fRGUFT27M/k947KGxhliG6B8htaP5DSUcSrrwY0be1cWNSdSnaCAf2xSTtvB4tAgke ZY0WIidksd8bwqxSsku8yHGXxc0gagC6CENiXJ9qwvl5sGOxSuuDOE0MV5cN9PGq3v7J b919Oxh5ABprIEKXz1xfkI+ADvpcOzCUnCrKQsDnoDOPPCPDmVJocqMCD5qA25johAYS 0NjBmXQD1oB5IN4ZQ4XMNtOMMpt3FLm+MORBz3a1N9HBsw0665AAB8HoZ1KMijo7h6DC plYg5UC6Ve/WcJWBi2G2Nq0oTIyRdo0WJhzRfMHFyAZM+VFLHnQ7bX4qwOHFVNKStPAy 9YPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ne/2Rigj"; 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 r21-20020a632055000000b005579890497fsi3532407pgm.205.2023.07.07.04.34.40; Fri, 07 Jul 2023 04:34:52 -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="ne/2Rigj"; 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 S231666AbjGGLMH (ORCPT + 99 others); Fri, 7 Jul 2023 07:12:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbjGGLMG (ORCPT ); Fri, 7 Jul 2023 07:12:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E2341725 for ; Fri, 7 Jul 2023 04:12:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C98E7618F1 for ; Fri, 7 Jul 2023 11:12:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B13DFC433CB; Fri, 7 Jul 2023 11:12:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688728324; bh=2NoIPMcY+haGQrbKaoQREEDgCnwtLhX96He1p8v4ak8=; h=From:To:Cc:Subject:Date:From; b=ne/2Rigj0ihkn2iVY9+viD5p8iMAXpVc9E3dlZdOVtcXs6tKHWaPAxUXywTlHrQIl dd52dv83urUzoftcpY+Y9y3orCGvxcKMJpjyq3171ghvBkwxjVkNvXMiSbR8kl1i+J ycLULiSs0XXlgdTuzPqeWqr/2Jw2jj0V+zNQ9Ff2EZzoCynUCCGOuoyYrusrbeTOK2 U7HeOQffHtSz05nEtiRe/S8Gcv7G6JqioP1pI/Hu2gu3pqzMNrsx5qRmq0TVZ0bGcZ PeisAzbZft2H19BkDqExDo6QAtxfrQ/8BZNOZafhT4RT1IbTJY8QZ2Wwz/coHQChZP xMKuLcpBf7QiA== From: Arnd Bergmann To: Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter Cc: Arnd Bergmann , Hawking Zhang , Lijo Lazar , Mario Limonciello , YiPeng Chai , Le Ma , Bokun Zhang , Srinivasan Shanmugam , Shiwu Zhang , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] drm/amdgpu: avoid integer overflow warning in amdgpu_device_resize_fb_bar() Date: Fri, 7 Jul 2023 13:11:51 +0200 Message-Id: <20230707111157.209432-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 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,T_SCC_BODY_TEXT_LINE 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: Arnd Bergmann On 32-bit architectures comparing a resource against a value larger than U32_MAX can cause a warning: drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:1344:18: error: result of comparison of constant 4294967296 with expression of type 'resource_size_t' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare] res->start > 0x100000000ull) ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~ As gcc does not warn about this in dead code, add an IS_ENABLED() check at the start of the function. This will always return success but not actually resize the BAR on 32-bit architectures without high memory, which is exactly what we want here, as the driver can fall back to bank switching the VRAM access. Fixes: 31b8adab3247e ("drm/amdgpu: require a root bus window above 4GB for BAR resize") Signed-off-by: Arnd Bergmann --- v2: return early instead of shutting up the warning with a cast and running into a failure --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 7f069e1731fee..fcf5f07c47751 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -1325,6 +1325,9 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev) u16 cmd; int r; + if (!IS_ENABLED(CONFIG_PHYS_ADDR_T_64BIT)) + return 0; + /* Bypass for VF */ if (amdgpu_sriov_vf(adev)) return 0; -- 2.39.2