[PATCH] drm/amdgpu: Modify for_each_inst macro

Lazar, Lijo Lijo.Lazar at amd.com
Fri Jun 16 15:27:57 UTC 2023


[AMD Official Use Only - General]

cc: Victor

Victor pointed at a shift beyond MSB condition. Will send a v2.

Thanks,
Lijo
________________________________
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> on behalf of Lijo Lazar <lijo.lazar at amd.com>
Sent: Friday, June 16, 2023 3:53:40 PM
To: amd-gfx at lists.freedesktop.org <amd-gfx at lists.freedesktop.org>
Cc: Deucher, Alexander <Alexander.Deucher at amd.com>; Ma, Le <Le.Ma at amd.com>; Kamal, Asad <Asad.Kamal at amd.com>; Zhang, Hawking <Hawking.Zhang at amd.com>
Subject: [PATCH] drm/amdgpu: Modify for_each_inst macro

Modify it such that it doesn't change the instance mask parameter.

Signed-off-by: Lijo Lazar <lijo.lazar at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index f4029c13a9be..c5451a9b0ee4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20230616/acdf0f5a/attachment.htm>


More information about the amd-gfx mailing list