Skip to contentSkip to conversation

drm/amdkfd: Use S_ENDPGM_SAVED in trap handler

PATCH In review Jay Cornwall 2 participants 3 messages Jan 15, 2024 – Jan 24, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdkfd: Use S_ENDPGM_SAVED in trap handler

This instruction has no functional difference to S_ENDPGM but allows performance counters to track save events correctly.

---
 drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h     | 14 +++++++-------
 .../gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm |  2 +-
 .../gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx9.asm  |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h +7 -7
index df75863393fc..d1caaf0e6a7c 100644
@@ -674,7 +674,7 @@ static const uint32_t cwsr_trap_gfx9_hex[] = {
 	0x86ea6a6a, 0x8f6e837a,
 	0xb96ee0c2, 0xbf800002,
 	0xb97a0002, 0xbf8a0000,
-	0xbe801f6c, 0xbf810000,
+	0xbe801f6c, 0xbf9b0000,
 };
 
 static const uint32_t cwsr_trap_nv1x_hex[] = {
@@ -1091,7 +1091,7 @@ static const uint32_t cwsr_trap_nv1x_hex[] = {
 	0xb9eef807, 0x876dff6d,
 	0x0000ffff, 0x87fe7e7e,
 	0x87ea6a6a, 0xb9faf802,
-	0xbe80226c, 0xbf810000,
+	0xbe80226c, 0xbf9b0000,
 	0xbf9f0000, 0xbf9f0000,
 	0xbf9f0000, 0xbf9f0000,
 	0xbf9f0000, 0x00000000,
@@ -1574,7 +1574,7 @@ static const uint32_t cwsr_trap_arcturus_hex[] = {
 	0x86ea6a6a, 0x8f6e837a,
 	0xb96ee0c2, 0xbf800002,
 	0xb97a0002, 0xbf8a0000,
-	0xbe801f6c, 0xbf810000,
+	0xbe801f6c, 0xbf9b0000,
 };
 
 static const uint32_t cwsr_trap_aldebaran_hex[] = {
@@ -2065,7 +2065,7 @@ static const uint32_t cwsr_trap_aldebaran_hex[] = {
 	0x86ea6a6a, 0x8f6e837a,
 	0xb96ee0c2, 0xbf800002,
 	0xb97a0002, 0xbf8a0000,
-	0xbe801f6c, 0xbf810000,
+	0xbe801f6c, 0xbf9b0000,
 };
 
 static const uint32_t cwsr_trap_gfx10_hex[] = {
@@ -2500,7 +2500,7 @@ static const uint32_t cwsr_trap_gfx10_hex[] = {
 	0x876dff6d, 0x0000ffff,
 	0x87fe7e7e, 0x87ea6a6a,
 	0xb9faf802, 0xbe80226c,
-	0xbf810000, 0xbf9f0000,
+	0xbf9b0000, 0xbf9f0000,
 	0xbf9f0000, 0xbf9f0000,
 	0xbf9f0000, 0xbf9f0000,
 };
@@ -2944,7 +2944,7 @@ static const uint32_t cwsr_trap_gfx11_hex[] = {
 	0xb8eef802, 0xbf0d866e,
 	0xbfa20002, 0xb97af802,
 	0xbe80486c, 0xb97af802,
-	0xbe804a6c, 0xbfb00000,
+	0xbe804a6c, 0xbfb10000,
 	0xbf9f0000, 0xbf9f0000,
 	0xbf9f0000, 0xbf9f0000,
 	0xbf9f0000, 0x00000000,
@@ -3436,5 +3436,5 @@ static const uint32_t cwsr_trap_gfx9_4_3_hex[] = {
 	0x86ea6a6a, 0x8f6e837a,
 	0xb96ee0c2, 0xbf800002,
 	0xb97a0002, 0xbf8a0000,
-	0xbe801f6c, 0xbf810000,
+	0xbe801f6c, 0xbf9b0000,
 };
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm +1 -1
index e0140df0b0ec..71b3dc0c7363 100644
@@ -1104,7 +1104,7 @@ L_RETURN_WITHOUT_PRIV:
 	s_rfe_b64	s_restore_pc_lo						//Return to the main shader program and resume execution
 
 L_END_PGM:
-	s_endpgm
+	s_endpgm_saved
 end
 
 function write_hwreg_to_mem(s, s_rsrc, s_mem_offset)
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx9.asm +1 -1
index e506411ad28a..bb26338204f4 100644
@@ -921,7 +921,7 @@ L_RESTORE:
 /*			the END						  */
 /**************************************************************************/
 L_END_PGM:
-    s_endpgm
+    s_endpgm_saved
 
 end
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 93 lines · Jay Cornwall

This instruction has no functional difference to S_ENDPGM but allows performance counters to track save events correctly.

---
 drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h     | 14 +++++++-------
 .../gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm |  2 +-
 .../gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx9.asm  |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h +7 -7
index df75863393fc..d1caaf0e6a7c 100644
@@ -674,7 +674,7 @@ static const uint32_t cwsr_trap_gfx9_hex[] = {
 	0x86ea6a6a, 0x8f6e837a,
 	0xb96ee0c2, 0xbf800002,
 	0xb97a0002, 0xbf8a0000,
-	0xbe801f6c, 0xbf810000,
+	0xbe801f6c, 0xbf9b0000,
 };
 
 static const uint32_t cwsr_trap_nv1x_hex[] = {
@@ -1091,7 +1091,7 @@ static const uint32_t cwsr_trap_nv1x_hex[] = {
 	0xb9eef807, 0x876dff6d,
 	0x0000ffff, 0x87fe7e7e,
 	0x87ea6a6a, 0xb9faf802,
-	0xbe80226c, 0xbf810000,
+	0xbe80226c, 0xbf9b0000,
 	0xbf9f0000, 0xbf9f0000,
 	0xbf9f0000, 0xbf9f0000,
 	0xbf9f0000, 0x00000000,
@@ -1574,7 +1574,7 @@ static const uint32_t cwsr_trap_arcturus_hex[] = {
 	0x86ea6a6a, 0x8f6e837a,
 	0xb96ee0c2, 0xbf800002,
 	0xb97a0002, 0xbf8a0000,
-	0xbe801f6c, 0xbf810000,
+	0xbe801f6c, 0xbf9b0000,
 };
 
 static const uint32_t cwsr_trap_aldebaran_hex[] = {
@@ -2065,7 +2065,7 @@ static const uint32_t cwsr_trap_aldebaran_hex[] = {
 	0x86ea6a6a, 0x8f6e837a,
 	0xb96ee0c2, 0xbf800002,
 	0xb97a0002, 0xbf8a0000,
-	0xbe801f6c, 0xbf810000,
+	0xbe801f6c, 0xbf9b0000,
 };
 
 static const uint32_t cwsr_trap_gfx10_hex[] = {
@@ -2500,7 +2500,7 @@ static const uint32_t cwsr_trap_gfx10_hex[] = {
 	0x876dff6d, 0x0000ffff,
 	0x87fe7e7e, 0x87ea6a6a,
 	0xb9faf802, 0xbe80226c,
-	0xbf810000, 0xbf9f0000,
+	0xbf9b0000, 0xbf9f0000,
 	0xbf9f0000, 0xbf9f0000,
 	0xbf9f0000, 0xbf9f0000,
 };
@@ -2944,7 +2944,7 @@ static const uint32_t cwsr_trap_gfx11_hex[] = {
 	0xb8eef802, 0xbf0d866e,
 	0xbfa20002, 0xb97af802,
 	0xbe80486c, 0xb97af802,
-	0xbe804a6c, 0xbfb00000,
+	0xbe804a6c, 0xbfb10000,
 	0xbf9f0000, 0xbf9f0000,
 	0xbf9f0000, 0xbf9f0000,
 	0xbf9f0000, 0x00000000,
@@ -3436,5 +3436,5 @@ static const uint32_t cwsr_trap_gfx9_4_3_hex[] = {
 	0x86ea6a6a, 0x8f6e837a,
 	0xb96ee0c2, 0xbf800002,
 	0xb97a0002, 0xbf8a0000,
-	0xbe801f6c, 0xbf810000,
+	0xbe801f6c, 0xbf9b0000,
 };
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm +1 -1
index e0140df0b0ec..71b3dc0c7363 100644
@@ -1104,7 +1104,7 @@ L_RETURN_WITHOUT_PRIV:
 	s_rfe_b64	s_restore_pc_lo						//Return to the main shader program and resume execution
 
 L_END_PGM:
-	s_endpgm
+	s_endpgm_saved
 end
 
 function write_hwreg_to_mem(s, s_rsrc, s_mem_offset)
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx9.asm +0 -0
index e506411ad28a..bb26338204f4 100644

drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx9.asm L_RESTORE: · line 927

Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx9.asm +1 -1
@@ -921,7 +921,7 @@ L_RESTORE:
 /*			the END						  */
 /**************************************************************************/
 L_END_PGM:
-    s_endpgm
+    s_endpgm_saved
 
 end
 

Ping. Patch has been tested and verified, just looking for an Ack.

Acked-by
#2 lore raw
Quoted 6 lines · Jay Cornwall
Quoted 4 lines · Jay Cornwall

This instruction has no functional difference to S_ENDPGM but allows performance counters to track save events correctly.

Quoted 99 lines
Quoted 89 lines
---
 drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h     | 14 +++++++-------
 .../gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm |  2 +-
 .../gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx9.asm  |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h +7 -7
index df75863393fc..d1caaf0e6a7c 100644
@@ -674,7 +674,7 @@ static const uint32_t cwsr_trap_gfx9_hex[] = {
      0x86ea6a6a, 0x8f6e837a,
      0xb96ee0c2, 0xbf800002,
      0xb97a0002, 0xbf8a0000,
-     0xbe801f6c, 0xbf810000,
+     0xbe801f6c, 0xbf9b0000,
 };
 
 static const uint32_t cwsr_trap_nv1x_hex[] = {
@@ -1091,7 +1091,7 @@ static const uint32_t cwsr_trap_nv1x_hex[] = {
      0xb9eef807, 0x876dff6d,
      0x0000ffff, 0x87fe7e7e,
      0x87ea6a6a, 0xb9faf802,
-     0xbe80226c, 0xbf810000,
+     0xbe80226c, 0xbf9b0000,
      0xbf9f0000, 0xbf9f0000,
      0xbf9f0000, 0xbf9f0000,
      0xbf9f0000, 0x00000000,
@@ -1574,7 +1574,7 @@ static const uint32_t cwsr_trap_arcturus_hex[] = {
      0x86ea6a6a, 0x8f6e837a,
      0xb96ee0c2, 0xbf800002,
      0xb97a0002, 0xbf8a0000,
-     0xbe801f6c, 0xbf810000,
+     0xbe801f6c, 0xbf9b0000,
 };
 
 static const uint32_t cwsr_trap_aldebaran_hex[] = {
@@ -2065,7 +2065,7 @@ static const uint32_t cwsr_trap_aldebaran_hex[] = {
      0x86ea6a6a, 0x8f6e837a,
      0xb96ee0c2, 0xbf800002,
      0xb97a0002, 0xbf8a0000,
-     0xbe801f6c, 0xbf810000,
+     0xbe801f6c, 0xbf9b0000,
 };
 
 static const uint32_t cwsr_trap_gfx10_hex[] = {
@@ -2500,7 +2500,7 @@ static const uint32_t cwsr_trap_gfx10_hex[] = {
      0x876dff6d, 0x0000ffff,
      0x87fe7e7e, 0x87ea6a6a,
      0xb9faf802, 0xbe80226c,
-     0xbf810000, 0xbf9f0000,
+     0xbf9b0000, 0xbf9f0000,
      0xbf9f0000, 0xbf9f0000,
      0xbf9f0000, 0xbf9f0000,
 };
@@ -2944,7 +2944,7 @@ static const uint32_t cwsr_trap_gfx11_hex[] = {
      0xb8eef802, 0xbf0d866e,
      0xbfa20002, 0xb97af802,
      0xbe80486c, 0xb97af802,
-     0xbe804a6c, 0xbfb00000,
+     0xbe804a6c, 0xbfb10000,
      0xbf9f0000, 0xbf9f0000,
      0xbf9f0000, 0xbf9f0000,
      0xbf9f0000, 0x00000000,
@@ -3436,5 +3436,5 @@ static const uint32_t cwsr_trap_gfx9_4_3_hex[] = {
      0x86ea6a6a, 0x8f6e837a,
      0xb96ee0c2, 0xbf800002,
      0xb97a0002, 0xbf8a0000,
-     0xbe801f6c, 0xbf810000,
+     0xbe801f6c, 0xbf9b0000,
 };
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx10.asm +1 -1
index e0140df0b0ec..71b3dc0c7363 100644
@@ -1104,7 +1104,7 @@ L_RETURN_WITHOUT_PRIV:
      s_rfe_b64       s_restore_pc_lo                                         //Return to the main shader program and resume execution
 
 L_END_PGM:
-     s_endpgm
+     s_endpgm_saved
 end
 
 function write_hwreg_to_mem(s, s_rsrc, s_mem_offset)
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx9.asm +0 -0
index e506411ad28a..bb26338204f4 100644

drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx9.asm L_RESTORE: · line 927

Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx9.asm +1 -1
@@ -921,7 +921,7 @@ L_RESTORE:
 /*                   the END                                           */
 /**************************************************************************/
 L_END_PGM:
-    s_endpgm
+    s_endpgm_saved
 
 end
 

Ping. Patch has been tested and verified, just looking for an Ack.