drm/amdgpu: Modify for_each_inst macro
Subsystems (2)
PATCH 1/1 drm/amdgpu: Modify for_each_inst macro
Modify it such that it doesn't change the instance mask parameter.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -3
@@ -1295,9 +1295,9 @@ int emu_soc_asic_init(struct amdgpu_device *adev);#define amdgpu_inc_vram_lost (adev) atomic_inc(&((adev)->vram_lost_counter)); -#define for_each_inst (i, inst_mask) \ - for (i = ffs(inst_mask) - 1; inst_mask; \ - inst_mask &= ~(1U << i), i = ffs(inst_mask) - 1) +#define for_each_inst (i, inst_mask) \ + for (i = ffs(inst_mask); i-- != 0; \ + i = ffs((inst_mask & (~0U << (i + 1)))))#define MIN (X ,Y ) ((X) < (Y) ? (X) : (Y))
Signature · 1 line
2.25.1
[Public]
________________________________
From: Lazar, Lijo <[email protected]>
Sent: Friday, June 16, 2023 6:23 AM
To: [email protected] <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Kamal, Asad <[email protected]>; Ma, Le <[email protected]>
Subject: [PATCH] drm/amdgpu: Modify for_each_inst macro
Modify it such that it doesn't change the instance mask parameter.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -3
@@ -1295,9 +1295,9 @@ int emu_soc_asic_init(struct amdgpu_device *adev);#define amdgpu_inc_vram_lost (adev) atomic_inc(&((adev)->vram_lost_counter)); -#define for_each_inst (i, inst_mask) \ - for (i = ffs(inst_mask) - 1; inst_mask; \ - inst_mask &= ~(1U << i), i = ffs(inst_mask) - 1) +#define for_each_inst (i, inst_mask) \ + for (i = ffs(inst_mask); i-- != 0; \ + i = ffs((inst_mask & (~0U << (i + 1)))))#define MIN (X ,Y ) ((X) < (Y) ? (X) : (Y))
--
2.25.1
Am 2023-06-16 um 06:23 schrieb Lijo Lazar:
Quoted 3 lines
Modify it such that it doesn't change the instance mask parameter.
Signed-off-by Lijo Lazar <[email protected]>
Quoted 21 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu.h +3
-3@@ -1295,9 +1295,9 @@ int emu_soc_asic_init(struct amdgpu_device *adev);#define amdgpu_inc_vram_lost (adev) atomic_inc(&((adev)->vram_lost_counter)); -#define for_each_inst (i, inst_mask) \ - for (i = ffs(inst_mask) - 1; inst_mask; \ - inst_mask &= ~(1U << i), i = ffs(inst_mask) - 1) +#define for_each_inst (i, inst_mask) \ + for (i = ffs(inst_mask); i-- != 0; \ + i = ffs((inst_mask & (~0U << (i + 1)))))#define MIN (X ,Y ) ((X) < (Y) ? (X) : (Y))
[AMD Official Use Only - General]
Victor pointed at a shift beyond MSB condition. Will send a v2.
Thanks,
Lijo
________________________________
From: amd-gfx <[email protected]> on behalf of Lijo Lazar <[email protected]>
Sent: Friday, June 16, 2023 3:53:40 PM
To: [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Ma, Le <[email protected]>; Kamal, Asad <[email protected]>; Zhang, Hawking <[email protected]>
Subject: [PATCH] drm/amdgpu: Modify for_each_inst macro
Modify it such that it doesn't change the instance mask parameter.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -3
@@ -1295,9 +1295,9 @@ int emu_soc_asic_init(struct amdgpu_device *adev);#define amdgpu_inc_vram_lost (adev) atomic_inc(&((adev)->vram_lost_counter)); -#define for_each_inst (i, inst_mask) \ - for (i = ffs(inst_mask) - 1; inst_mask; \ - inst_mask &= ~(1U << i), i = ffs(inst_mask) - 1) +#define for_each_inst (i, inst_mask) \ + for (i = ffs(inst_mask); i-- != 0; \ + i = ffs((inst_mask & (~0U << (i + 1)))))#define MIN (X ,Y ) ((X) < (Y) ? (X) : (Y))
--
2.25.1