* [PATCH] amdgpu: fix integer overflow on 32-bit architectures
@ 2020-05-05 14:15 Arnd Bergmann
2020-05-05 14:16 ` Christian König
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2020-05-05 14:15 UTC (permalink / raw)
To: Alex Deucher, Christian König, David (ChunMing) Zhou,
David Airlie, Daniel Vetter, Evan Quan
Cc: Arnd Bergmann, Hawking Zhang, Andrey Grodzovsky, Monk Liu,
Kent Russell, amd-gfx, dri-devel, linux-kernel,
clang-built-linux
Multiplying 1000000000 by four overruns a 'long' variable, as clang
points out:
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:4160:53: error: overflow in expression; result is -294967296 with type 'long' [-Werror,-Winteger-overflow]
expires = ktime_get_mono_fast_ns() + NSEC_PER_SEC * 4L;
^
Make this a 'long long' constant instead.
Fixes: 3f12acc8d6d4 ("drm/amdgpu: put the audio codec into suspend state before gpu reset V3")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
I'm not sure the ktime_get_mono_fast_ns() call is necessary here
either. Is it intentional because ktime_get_ns() doesn't work
during a driver suspend, or just a mistake?
---
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 6f93af972b0a..2e07e3e6b036 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4157,7 +4157,7 @@ static int amdgpu_device_suspend_display_audio(struct amdgpu_device *adev)
* the audio controller default autosuspend delay setting.
* 4S used here is guaranteed to cover that.
*/
- expires = ktime_get_mono_fast_ns() + NSEC_PER_SEC * 4L;
+ expires = ktime_get_mono_fast_ns() + NSEC_PER_SEC * 4LL;
while (!pm_runtime_status_suspended(&(p->dev))) {
if (!pm_runtime_suspend(&(p->dev)))
--
2.26.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] amdgpu: fix integer overflow on 32-bit architectures
2020-05-05 14:15 [PATCH] amdgpu: fix integer overflow on 32-bit architectures Arnd Bergmann
@ 2020-05-05 14:16 ` Christian König
2020-05-05 15:39 ` Nick Desaulniers
0 siblings, 1 reply; 3+ messages in thread
From: Christian König @ 2020-05-05 14:16 UTC (permalink / raw)
To: Arnd Bergmann, Alex Deucher, David (ChunMing) Zhou, David Airlie,
Daniel Vetter, Evan Quan
Cc: Hawking Zhang, Andrey Grodzovsky, Monk Liu, Kent Russell,
amd-gfx, dri-devel, linux-kernel, clang-built-linux
Am 05.05.20 um 16:15 schrieb Arnd Bergmann:
> Multiplying 1000000000 by four overruns a 'long' variable, as clang
> points out:
>
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:4160:53: error: overflow in expression; result is -294967296 with type 'long' [-Werror,-Winteger-overflow]
> expires = ktime_get_mono_fast_ns() + NSEC_PER_SEC * 4L;
> ^
> Make this a 'long long' constant instead.
>
> Fixes: 3f12acc8d6d4 ("drm/amdgpu: put the audio codec into suspend state before gpu reset V3")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Christian König <christian.koenig@amd.com>
> ---
> I'm not sure the ktime_get_mono_fast_ns() call is necessary here
> either. Is it intentional because ktime_get_ns() doesn't work
> during a driver suspend, or just a mistake?
> ---
> 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 6f93af972b0a..2e07e3e6b036 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -4157,7 +4157,7 @@ static int amdgpu_device_suspend_display_audio(struct amdgpu_device *adev)
> * the audio controller default autosuspend delay setting.
> * 4S used here is guaranteed to cover that.
> */
> - expires = ktime_get_mono_fast_ns() + NSEC_PER_SEC * 4L;
> + expires = ktime_get_mono_fast_ns() + NSEC_PER_SEC * 4LL;
>
> while (!pm_runtime_status_suspended(&(p->dev))) {
> if (!pm_runtime_suspend(&(p->dev)))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] amdgpu: fix integer overflow on 32-bit architectures
2020-05-05 14:16 ` Christian König
@ 2020-05-05 15:39 ` Nick Desaulniers
0 siblings, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2020-05-05 15:39 UTC (permalink / raw)
To: Christian König, Arnd Bergmann
Cc: Alex Deucher, David (ChunMing) Zhou, David Airlie, Daniel Vetter,
Evan Quan, Hawking Zhang, Andrey Grodzovsky, Monk Liu,
Kent Russell, amd-gfx list, dri-devel, LKML, clang-built-linux,
Nathan Chancellor, Alex Deucher
See also https://lore.kernel.org/lkml/CADnq5_NdtZh5_RGDWKJ9c_42XLvrncCs5DDU1YSptfZP94KXkQ@mail.gmail.com/T/#me707e09e92c6e487285e8bb382a607e4e782c249
On Tue, May 5, 2020 at 7:17 AM Christian König <christian.koenig@amd.com> wrote:
>
> Am 05.05.20 um 16:15 schrieb Arnd Bergmann:
> > Multiplying 1000000000 by four overruns a 'long' variable, as clang
> > points out:
> >
> > drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:4160:53: error: overflow in expression; result is -294967296 with type 'long' [-Werror,-Winteger-overflow]
> > expires = ktime_get_mono_fast_ns() + NSEC_PER_SEC * 4L;
> > ^
> > Make this a 'long long' constant instead.
> >
> > Fixes: 3f12acc8d6d4 ("drm/amdgpu: put the audio codec into suspend state before gpu reset V3")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Reviewed-by: Christian König <christian.koenig@amd.com>
>
> > ---
> > I'm not sure the ktime_get_mono_fast_ns() call is necessary here
> > either. Is it intentional because ktime_get_ns() doesn't work
> > during a driver suspend, or just a mistake?
> > ---
> > 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 6f93af972b0a..2e07e3e6b036 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > @@ -4157,7 +4157,7 @@ static int amdgpu_device_suspend_display_audio(struct amdgpu_device *adev)
> > * the audio controller default autosuspend delay setting.
> > * 4S used here is guaranteed to cover that.
> > */
> > - expires = ktime_get_mono_fast_ns() + NSEC_PER_SEC * 4L;
> > + expires = ktime_get_mono_fast_ns() + NSEC_PER_SEC * 4LL;
> >
> > while (!pm_runtime_status_suspended(&(p->dev))) {
> > if (!pm_runtime_suspend(&(p->dev)))
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/e4a852b2-807b-bc73-7328-bcc399341085%40amd.com.
--
Thanks,
~Nick Desaulniers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-05 15:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 14:15 [PATCH] amdgpu: fix integer overflow on 32-bit architectures Arnd Bergmann
2020-05-05 14:16 ` Christian König
2020-05-05 15:39 ` Nick Desaulniers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).