<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<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="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Acked-by: Alex Deucher <alexander.deucher@amd.com></div>
<div id="appendonsend"></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 Laurent Morichetti <laurent.morichetti@amd.com><br>
<b>Sent:</b> Thursday, February 1, 2024 4:33 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> jay.cornwall.six@amd.com <jay.cornwall.six@amd.com>; Morichetti, Laurent <Laurent.Morichetti@amd.com>; Six, Lancelot <Lancelot.Six@amd.com>; Cornwall, Jay <Jay.Cornwall@amd.com><br>
<b>Subject:</b> [PATCH v2] amdkfd: pass debug exceptions to second-level trap handler</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Call the 2nd level trap handler if the cwsr handler is entered with any<br>
one of wave_start, wave_end, or trap_after_inst exceptions.<br>
<br>
Signed-off-by: Laurent Morichetti <laurent.morichetti@amd.com><br>
Tested-by: Lancelot Six <lancelot.six@amd.com><br>
Reviewed-by: Jay Cornwall <jay.cornwall@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h  |  2 +-<br>
 .../drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm  | 17 ++++++++++++++++-<br>
 2 files changed, 17 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h b/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h<br>
index d1caaf0e6a7c..2e9b64edb8d2 100644<br>
--- a/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h<br>
+++ b/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h<br>
@@ -2518,7 +2518,7 @@ static const uint32_t cwsr_trap_gfx11_hex[] = {<br>
         0x8b6eff7b, 0x00000400,<br>
         0xbfa20045, 0xbf830010,<br>
         0xb8fbf803, 0xbfa0fffa,<br>
-       0x8b6eff7b, 0x00000900,<br>
+       0x8b6eff7b, 0x00160900,<br>
         0xbfa20015, 0x8b6eff7b,<br>
         0x000071ff, 0xbfa10008,<br>
         0x8b6fff7b, 0x00007080,<br>
diff --git a/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm b/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm<br>
index 71b3dc0c7363..7568ff3af978 100644<br>
--- a/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm<br>
+++ b/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm<br>
@@ -81,6 +81,11 @@ var SQ_WAVE_TRAPSTS_POST_SAVECTX_SHIFT               = 11<br>
 var SQ_WAVE_TRAPSTS_POST_SAVECTX_SIZE           = 21<br>
 var SQ_WAVE_TRAPSTS_ILLEGAL_INST_MASK           = 0x800<br>
 var SQ_WAVE_TRAPSTS_EXCP_HI_MASK                = 0x7000<br>
+#if ASIC_FAMILY >= CHIP_PLUM_BONITO<br>
+var SQ_WAVE_TRAPSTS_WAVE_START_MASK            = 0x20000<br>
+var SQ_WAVE_TRAPSTS_WAVE_END_MASK              = 0x40000<br>
+var SQ_WAVE_TRAPSTS_TRAP_AFTER_INST_MASK       = 0x100000<br>
+#endif<br>
 <br>
 var SQ_WAVE_MODE_EXCP_EN_SHIFT                  = 12<br>
 var SQ_WAVE_MODE_EXCP_EN_ADDR_WATCH_SHIFT       = 19<br>
@@ -92,6 +97,16 @@ var SQ_WAVE_IB_STS_RCNT_FIRST_REPLAY_MASK    = 0x003F8000<br>
 <br>
 var SQ_WAVE_MODE_DEBUG_EN_MASK                  = 0x800<br>
 <br>
+#if ASIC_FAMILY < CHIP_PLUM_BONITO<br>
+var S_TRAPSTS_NON_MASKABLE_EXCP_MASK           = SQ_WAVE_TRAPSTS_MEM_VIOL_MASK|SQ_WAVE_TRAPSTS_ILLEGAL_INST_MASK<br>
+#else<br>
+var S_TRAPSTS_NON_MASKABLE_EXCP_MASK           = SQ_WAVE_TRAPSTS_MEM_VIOL_MASK         |\<br>
+                                                 SQ_WAVE_TRAPSTS_ILLEGAL_INST_MASK      |\<br>
+                                                 SQ_WAVE_TRAPSTS_WAVE_START_MASK        |\<br>
+                                                 SQ_WAVE_TRAPSTS_WAVE_END_MASK          |\<br>
+                                                 SQ_WAVE_TRAPSTS_TRAP_AFTER_INST_MASK<br>
+#endif<br>
+<br>
 // bits [31:24] unused by SPI debug data<br>
 var TTMP11_SAVE_REPLAY_W64H_SHIFT               = 31<br>
 var TTMP11_SAVE_REPLAY_W64H_MASK                = 0x80000000<br>
@@ -224,7 +239,7 @@ L_NOT_HALTED:<br>
         // Check non-maskable exceptions. memory_violation, illegal_instruction<br>
         // and xnack_error exceptions always cause the wave to enter the trap<br>
         // handler.<br>
-       s_and_b32       ttmp2, s_save_trapsts, SQ_WAVE_TRAPSTS_MEM_VIOL_MASK|SQ_WAVE_TRAPSTS_ILLEGAL_INST_MASK<br>
+       s_and_b32       ttmp2, s_save_trapsts, S_TRAPSTS_NON_MASKABLE_EXCP_MASK<br>
         s_cbranch_scc1  L_FETCH_2ND_TRAP<br>
 <br>
         // Check for maskable exceptions in trapsts.excp and trapsts.excp_hi.<br>
<br>
base-commit: c4b562a17829454713e45219fa754be1bfda9004<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>