<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<p style="font-family:Arial;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - General]<br>
</p>
<br>
<div>
<div style="" dir="auto">cc: Victor</div>
<div style="" dir="auto"><br>
</div>
<div style="" dir="auto">Victor pointed at a shift beyond MSB condition. Will send a v2.</div>
<div id="ms-outlook-mobile-signature" dir="auto">
<div><br>
</div>
Thanks,<br>
Lijo</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Lijo Lazar <lijo.lazar@amd.com><br>
<b>Sent:</b> Friday, June 16, 2023 3:53:40 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; Ma, Le <Le.Ma@amd.com>; Kamal, Asad <Asad.Kamal@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com><br>
<b>Subject:</b> [PATCH] drm/amdgpu: Modify for_each_inst macro</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Modify it such that it doesn't change the instance mask parameter.<br>
<br>
Signed-off-by: Lijo Lazar <lijo.lazar@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/amdgpu.h | 6 +++---<br>
 1 file changed, 3 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
index f4029c13a9be..c5451a9b0ee4 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h<br>
@@ -1295,9 +1295,9 @@ int emu_soc_asic_init(struct amdgpu_device *adev);<br>
 <br>
 #define amdgpu_inc_vram_lost(adev) atomic_inc(&((adev)->vram_lost_counter));<br>
 <br>
-#define for_each_inst(i, inst_mask)                                            \<br>
-       for (i = ffs(inst_mask) - 1; inst_mask;                                \<br>
-            inst_mask &= ~(1U << i), i = ffs(inst_mask) - 1)<br>
+#define for_each_inst(i, inst_mask)        \<br>
+       for (i = ffs(inst_mask); i-- != 0; \<br>
+            i = ffs((inst_mask & (~0U << (i + 1)))))<br>
 <br>
 #define MIN(X, Y) ((X) < (Y) ? (X) : (Y))<br>
 <br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>