drm/amdgpu: Modify for_each_inst macro
authorLijo Lazar <lijo.lazar@amd.com>
Thu, 15 Jun 2023 10:53:07 +0000 (16:23 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 30 Jun 2023 17:11:35 +0000 (13:11 -0400)
Modify it such that it doesn't change the instance mask parameter.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Acked-by: Victor Skvortsov <victor.skvortsov@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu.h

index a84bd4a..cc3aaea 100644 (file)
@@ -1277,9 +1277,10 @@ 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 BIT_MASK_UPPER(i) ((i) >= BITS_PER_LONG ? 0 : ~0UL << (i))
+#define for_each_inst(i, inst_mask)        \
+       for (i = ffs(inst_mask); i-- != 0; \
+            i = ffs(inst_mask & BIT_MASK_UPPER(i + 1)))
 
 #define MIN(X, Y) ((X) < (Y) ? (X) : (Y))