[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <788147c6-defd-496a-8174-1571b73d1a71@app.fastmail.com>
Date: Tue, 04 Jul 2023 14:24:09 +0200
From: "Arnd Bergmann" <arnd@...db.de>
To: Christian König <christian.koenig@....com>,
"Arnd Bergmann" <arnd@...nel.org>,
"Alex Deucher" <alexander.deucher@....com>,
"Pan, Xinhui" <Xinhui.Pan@....com>,
"Dave Airlie" <airlied@...il.com>,
"Daniel Vetter" <daniel@...ll.ch>
Cc: "Hawking Zhang" <Hawking.Zhang@....com>,
"Lijo Lazar" <lijo.lazar@....com>,
"Mario Limonciello" <mario.limonciello@....com>,
"YiPeng Chai" <YiPeng.Chai@....com>, "Le Ma" <le.ma@....com>,
"Bokun Zhang" <Bokun.Zhang@....com>,
"Srinivasan Shanmugam" <srinivasan.shanmugam@....com>,
"Shiwu Zhang" <shiwu.zhang@....com>, amd-gfx@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drm/amdgpu: avoid integer overflow warning in
amdgpu_device_resize_fb_bar()
On Tue, Jul 4, 2023, at 08:54, Christian König wrote:
> Am 03.07.23 um 14:35 schrieb Arnd Bergmann:
>> From: Arnd Bergmann <arnd@...db.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.
>
> Well it doesn't make sense to compile that driver on systems with only
> 32bit phys_addr_t in the first place.
Not sure I understand the specific requirement. Do you mean the entire
amdgpu driver requires 64-bit BAR addressing, or just the bits that
resize the BARs?
> It might be cleaner to just not build the whole driver on such systems
> or at least leave out this function.
How about this version? This also addresses the build failure, but
I don't know if this makes any sense:
--- 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;
Arnd
Powered by blists - more mailing lists