* [PATCH] drm/amdgpu: Fix shift type in amdgpu_debugfs_sdma_sched_mask_set()
@ 2025-01-08 9:41 Dan Carpenter
2025-01-08 18:39 ` Mario Limonciello
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-01-08 9:41 UTC (permalink / raw)
To: Jesse Zhang
Cc: Alex Deucher, Christian König, Xinhui Pan, David Airlie,
Simona Vetter, Hawking Zhang, Tim Huang, Jesse.zhang, Likun Gao,
Mario Limonciello, Yang Wang, Le Ma, amd-gfx, dri-devel,
linux-kernel, kernel-janitors
The "mask" and "val" variables are type u64. The problem is that the
BIT() macros are type unsigned long which is just 32 bits on 32bit
systems.
It's unlikely that people will be using this driver on 32bit kernels
and even if they did we only use the lower AMDGPU_MAX_SDMA_INSTANCES (16)
bits. So this bug does not affect anything in real life.
Still, for correctness sake, u64 bit masks should use BIT_ULL().
Fixes: d2e3961ae371 ("drm/amdgpu: add amdgpu_sdma_sched_mask debugfs")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
index 632295bf3875..174badca27e7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
@@ -362,13 +362,13 @@ static int amdgpu_debugfs_sdma_sched_mask_set(void *data, u64 val)
if (!adev)
return -ENODEV;
- mask = (1 << adev->sdma.num_instances) - 1;
+ mask = BIT_ULL(adev->sdma.num_instances) - 1;
if ((val & mask) == 0)
return -EINVAL;
for (i = 0; i < adev->sdma.num_instances; ++i) {
ring = &adev->sdma.instance[i].ring;
- if (val & (1 << i))
+ if (val & BIT_ULL(i))
ring->sched.ready = true;
else
ring->sched.ready = false;
--
2.45.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/amdgpu: Fix shift type in amdgpu_debugfs_sdma_sched_mask_set()
2025-01-08 9:41 [PATCH] drm/amdgpu: Fix shift type in amdgpu_debugfs_sdma_sched_mask_set() Dan Carpenter
@ 2025-01-08 18:39 ` Mario Limonciello
0 siblings, 0 replies; 2+ messages in thread
From: Mario Limonciello @ 2025-01-08 18:39 UTC (permalink / raw)
To: Dan Carpenter, Jesse Zhang
Cc: Alex Deucher, Christian König, Xinhui Pan, David Airlie,
Simona Vetter, Hawking Zhang, Tim Huang, Likun Gao, Yang Wang,
Le Ma, amd-gfx, dri-devel, linux-kernel, kernel-janitors
On 1/8/2025 03:41, Dan Carpenter wrote:
> The "mask" and "val" variables are type u64. The problem is that the
> BIT() macros are type unsigned long which is just 32 bits on 32bit
> systems.
>
> It's unlikely that people will be using this driver on 32bit kernels
> and even if they did we only use the lower AMDGPU_MAX_SDMA_INSTANCES (16)
> bits. So this bug does not affect anything in real life.
>
> Still, for correctness sake, u64 bit masks should use BIT_ULL().
>
> Fixes: d2e3961ae371 ("drm/amdgpu: add amdgpu_sdma_sched_mask debugfs")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
Applied, thanks!
> drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
> index 632295bf3875..174badca27e7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sdma.c
> @@ -362,13 +362,13 @@ static int amdgpu_debugfs_sdma_sched_mask_set(void *data, u64 val)
> if (!adev)
> return -ENODEV;
>
> - mask = (1 << adev->sdma.num_instances) - 1;
> + mask = BIT_ULL(adev->sdma.num_instances) - 1;
> if ((val & mask) == 0)
> return -EINVAL;
>
> for (i = 0; i < adev->sdma.num_instances; ++i) {
> ring = &adev->sdma.instance[i].ring;
> - if (val & (1 << i))
> + if (val & BIT_ULL(i))
> ring->sched.ready = true;
> else
> ring->sched.ready = false;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-08 18:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-08 9:41 [PATCH] drm/amdgpu: Fix shift type in amdgpu_debugfs_sdma_sched_mask_set() Dan Carpenter
2025-01-08 18:39 ` Mario Limonciello
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®