From: "Christian König" <christian.koenig@amd.com>
To: Arnd Bergmann <arnd@kernel.org>,
Alex Deucher <alexander.deucher@amd.com>,
"Pan, Xinhui" <Xinhui.Pan@amd.com>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>
Cc: Arnd Bergmann <arnd@arndb.de>,
Hawking Zhang <Hawking.Zhang@amd.com>,
Lijo Lazar <lijo.lazar@amd.com>,
Mario Limonciello <mario.limonciello@amd.com>,
YiPeng Chai <YiPeng.Chai@amd.com>, Le Ma <le.ma@amd.com>,
Bokun Zhang <Bokun.Zhang@amd.com>,
Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>,
Shiwu Zhang <shiwu.zhang@amd.com>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [v2] drm/amdgpu: avoid integer overflow warning in amdgpu_device_resize_fb_bar()
Date: Fri, 7 Jul 2023 13:47:09 +0200 [thread overview]
Message-ID: <f32098e2-d680-d02e-8181-cad76daf2416@amd.com> (raw)
In-Reply-To: <20230707111157.209432-1-arnd@kernel.org>
Am 07.07.23 um 13:11 schrieb Arnd Bergmann:
> 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)
> ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
>
> 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 <arnd@arndb.de>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> 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;
next prev parent reply other threads:[~2023-07-07 11:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-07 11:11 [PATCH] [v2] drm/amdgpu: avoid integer overflow warning in amdgpu_device_resize_fb_bar() Arnd Bergmann
2023-07-07 11:47 ` Christian König [this message]
2023-07-07 18:40 ` Alex Deucher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f32098e2-d680-d02e-8181-cad76daf2416@amd.com \
--to=christian.koenig@amd.com \
--cc=Bokun.Zhang@amd.com \
--cc=Hawking.Zhang@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=YiPeng.Chai@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=le.ma@amd.com \
--cc=lijo.lazar@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=shiwu.zhang@amd.com \
--cc=srinivasan.shanmugam@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox