public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: avoid integer overflow warning in amdgpu_device_resize_fb_bar()
@ 2023-07-03 12:35 Arnd Bergmann
  2023-07-04  6:54 ` Christian König
  0 siblings, 1 reply; 8+ messages in thread
From: Arnd Bergmann @ 2023-07-03 12:35 UTC (permalink / raw)
  To: Alex Deucher, Christian König, 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, dri-devel, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

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)
                    ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~

The compiler is right that this cannot happen in this configuration, which
is ok, so just add a cast to shut up the warning.

Fixes: 31b8adab3247e ("drm/amdgpu: require a root bus window above 4GB for BAR resize")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 7f069e1731fee..abd13942aac5d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1341,7 +1341,7 @@ int amdgpu_device_resize_fb_bar(struct amdgpu_device *adev)
 
 	pci_bus_for_each_resource(root, res, i) {
 		if (res && res->flags & (IORESOURCE_MEM | IORESOURCE_MEM_64) &&
-		    res->start > 0x100000000ull)
+		    (u64)res->start > 0x100000000ull)
 			break;
 	}
 
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-07-05 12:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-03 12:35 [PATCH] drm/amdgpu: avoid integer overflow warning in amdgpu_device_resize_fb_bar() Arnd Bergmann
2023-07-04  6:54 ` Christian König
2023-07-04 12:24   ` Arnd Bergmann
2023-07-04 12:33     ` Christian König
2023-07-04 14:31       ` Arnd Bergmann
2023-07-04 14:51         ` Christian König
2023-07-04 15:24           ` Arnd Bergmann
2023-07-05 12:27             ` Christian König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox