<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">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Series is:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Acked-by: Alex Deucher <alexander.deucher@amd.com><br>
</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 Cornwall, Jay <Jay.Cornwall@amd.com><br>
<b>Sent:</b> Wednesday, July 24, 2019 1:27 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Cornwall, Jay <Jay.Cornwall@amd.com><br>
<b>Subject:</b> [PATCH 2/2] drm/amdkfd: Remove dead code from gfx8/gfx9 trap handlers</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Signed-off-by: Jay Cornwall <jay.cornwall@amd.com><br>
---<br>
 .../gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx8.asm  | 395 +--------------------<br>
 .../gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx9.asm  | 375 +------------------<br>
 2 files changed, 5 insertions(+), 765 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx8.asm b/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx8.asm<br>
index a47f5b9..b195b7c 100644<br>
--- a/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx8.asm<br>
+++ b/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx8.asm<br>
@@ -24,78 +24,6 @@<br>
  * PROJECT=vi ./sp3 cwsr_trap_handler_gfx8.asm -hex tmp.hex<br>
  */<br>
 <br>
-/* HW (VI) source code for CWSR trap handler */<br>
-/* Version 18 + multiple trap handler */<br>
-<br>
-// this performance-optimal version was originally from Seven Xu at SRDC<br>
-<br>
-// Revison #18   --...<br>
-/* Rev History<br>
-** #1. Branch from gc dv.   //gfxip/gfx8/main/src/test/suites/block/cs/sr/cs_trap_handler.sp3#1,#50, #51, #52-53(Skip, Already Fixed by PV), #54-56(merged),#57-58(mergerd, skiped-already fixed by PV)<br>
-** #4. SR Memory Layout:<br>
-**             1. VGPR-SGPR-HWREG-{LDS}<br>
-**             2. tba_hi.bits.26 - reconfigured as the first wave in tg bits, for defer Save LDS for a threadgroup.. performance concern..<br>
-** #5. Update: 1. Accurate g8sr_ts_save_d timestamp<br>
-** #6. Update: 1. Fix s_barrier usage; 2. VGPR s/r using swizzle buffer?(NoNeed, already matched the swizzle pattern, more investigation)<br>
-** #7. Update: 1. don't barrier if noLDS<br>
-** #8. Branch: 1. Branch to ver#0, which is very similar to gc dv version<br>
-**             2. Fix SQ issue by s_sleep 2<br>
-** #9. Update: 1. Fix scc restore failed issue, restore wave_status at last<br>
-**             2. optimize s_buffer save by burst 16sgprs...<br>
-** #10. Update 1. Optimize restore sgpr by busrt 16 sgprs.<br>
-** #11. Update 1. Add 2 more timestamp for debug version<br>
-** #12. Update 1. Add VGPR SR using DWx4, some case improve and some case drop performance<br>
-** #13. Integ  1. Always use MUBUF for PV trap shader...<br>
-** #14. Update 1. s_buffer_store soft clause...<br>
-** #15. Update 1. PERF - sclar write with glc:0/mtype0 to allow L2 combine. perf improvement a lot.<br>
-** #16. Update 1. PRRF - UNROLL LDS_DMA got 2500cycle save in IP tree<br>
-** #17. Update 1. FUNC - LDS_DMA has issues while ATC, replace with ds_read/buffer_store for save part[TODO restore part]<br>
-**             2. PERF - Save LDS before save VGPR to cover LDS save long latency...<br>
-** #18. Update 1. FUNC - Implicitly estore STATUS.VCCZ, which is not writable by s_setreg_b32<br>
-**             2. FUNC - Handle non-CWSR traps<br>
-*/<br>
-<br>
-var G8SR_WDMEM_HWREG_OFFSET = 0<br>
-var G8SR_WDMEM_SGPR_OFFSET  = 128  // in bytes<br>
-<br>
-// Keep definition same as the app shader, These 2 time stamps are part of the app shader... Should before any Save and after restore.<br>
-<br>
-var G8SR_DEBUG_TIMESTAMP = 0<br>
-var G8SR_DEBUG_TS_SAVE_D_OFFSET = 40*4  // ts_save_d timestamp offset relative to SGPR_SR_memory_offset<br>
-var s_g8sr_ts_save_s    = s[34:35]   // save start<br>
-var s_g8sr_ts_sq_save_msg  = s[36:37]   // The save shader send SAVEWAVE msg to spi<br>
-var s_g8sr_ts_spi_wrexec   = s[38:39]   // the SPI write the sr address to SQ<br>
-var s_g8sr_ts_save_d    = s[40:41]   // save end<br>
-var s_g8sr_ts_restore_s = s[42:43]   // restore start<br>
-var s_g8sr_ts_restore_d = s[44:45]   // restore end<br>
-<br>
-var G8SR_VGPR_SR_IN_DWX4 = 0<br>
-var G8SR_SAVE_BUF_RSRC_WORD1_STRIDE_DWx4 = 0x00100000    // DWx4 stride is 4*4Bytes<br>
-var G8SR_RESTORE_BUF_RSRC_WORD1_STRIDE_DWx4  = G8SR_SAVE_BUF_RSRC_WORD1_STRIDE_DWx4<br>
-<br>
-<br>
-/*************************************************************************/<br>
-/*                  control on how to run the shader                     */<br>
-/*************************************************************************/<br>
-//any hack that needs to be made to run this code in EMU (either because various EMU code are not ready or no compute save & restore in EMU run)<br>
-var EMU_RUN_HACK                    =   0<br>
-var EMU_RUN_HACK_RESTORE_NORMAL     =   0<br>
-var EMU_RUN_HACK_SAVE_NORMAL_EXIT   =   0<br>
-var EMU_RUN_HACK_SAVE_SINGLE_WAVE   =   0<br>
-var EMU_RUN_HACK_SAVE_FIRST_TIME    =   0                   //for interrupted restore in which the first save is through EMU_RUN_HACK<br>
-var EMU_RUN_HACK_SAVE_FIRST_TIME_TBA_LO =   0                   //for interrupted restore in which the first save is through EMU_RUN_HACK<br>
-var EMU_RUN_HACK_SAVE_FIRST_TIME_TBA_HI =   0                   //for interrupted restore in which the first save is through EMU_RUN_HACK<br>
-var SAVE_LDS                        =   1<br>
-var WG_BASE_ADDR_LO                 =   0x9000a000<br>
-var WG_BASE_ADDR_HI                 =   0x0<br>
-var WAVE_SPACE                      =   0x5000              //memory size that each wave occupies in workgroup state mem<br>
-var CTX_SAVE_CONTROL                =   0x0<br>
-var CTX_RESTORE_CONTROL             =   CTX_SAVE_CONTROL<br>
-var SIM_RUN_HACK                    =   0                   //any hack that needs to be made to run this code in SIM (either because various RTL code are not ready or no compute save & restore in RTL run)<br>
-var SGPR_SAVE_USE_SQC               =   1                   //use SQC D$ to do the write<br>
-var USE_MTBUF_INSTEAD_OF_MUBUF      =   0                   //because TC EMU currently asserts on 0 of // overload DFMT field to carry 4 more bits of stride for MUBUF opcodes<br>
-var SWIZZLE_EN                      =   0                   //whether we use swizzled buffer addressing<br>
-<br>
 /**************************************************************************/<br>
 /*                      variables                                         */<br>
 /**************************************************************************/<br>
@@ -226,16 +154,7 @@ shader main<br>
   type(CS)<br>
 <br>
 <br>
-    if ((EMU_RUN_HACK) && (!EMU_RUN_HACK_RESTORE_NORMAL))                   //hack to use trap_id for determining save/restore<br>
-        //FIXME VCCZ un-init assertion s_getreg_b32     s_save_status, hwreg(HW_REG_STATUS)         //save STATUS since we will change SCC<br>
-        s_and_b32 s_save_tmp, s_save_pc_hi, 0xffff0000              //change SCC<br>
-        s_cmp_eq_u32 s_save_tmp, 0x007e0000                         //Save: trap_id = 0x7e. Restore: trap_id = 0x7f.<br>
-        s_cbranch_scc0 L_JUMP_TO_RESTORE                            //do not need to recover STATUS here  since we are going to RESTORE<br>
-        //FIXME  s_setreg_b32   hwreg(HW_REG_STATUS),   s_save_status       //need to recover STATUS since we are going to SAVE<br>
-        s_branch L_SKIP_RESTORE                                     //NOT restore, SAVE actually<br>
-    else<br>
         s_branch L_SKIP_RESTORE                                     //NOT restore. might be a regular trap or save<br>
-    end<br>
 <br>
 L_JUMP_TO_RESTORE:<br>
     s_branch L_RESTORE                                              //restore<br>
@@ -249,7 +168,7 @@ L_SKIP_RESTORE:<br>
     s_cbranch_scc1  L_SAVE                                      //this is the operation for save<br>
 <br>
     // *********    Handle non-CWSR traps       *******************<br>
-if (!EMU_RUN_HACK)<br>
+<br>
     /* read tba and tma for next level trap handler, ttmp4 is used as s_save_status */<br>
     s_load_dwordx4  [ttmp8,ttmp9,ttmp10, ttmp11], [tma_lo,tma_hi], 0<br>
     s_waitcnt lgkmcnt(0)<br>
@@ -268,7 +187,7 @@ L_EXCP_CASE:<br>
     s_and_b32   ttmp1, ttmp1, 0xFFFF<br>
     set_status_without_spi_prio(s_save_status, ttmp2) //restore HW status(SCC)<br>
     s_rfe_b64       [ttmp0, ttmp1]<br>
-end<br>
+<br>
     // *********        End handling of non-CWSR traps   *******************<br>
 <br>
 /**************************************************************************/<br>
@@ -276,12 +195,6 @@ end<br>
 /**************************************************************************/<br>
 <br>
 L_SAVE:<br>
-<br>
-if G8SR_DEBUG_TIMESTAMP<br>
-        s_memrealtime   s_g8sr_ts_save_s<br>
-        s_waitcnt lgkmcnt(0)         //FIXME, will cause xnack??<br>
-end<br>
-<br>
     s_mov_b32       s_save_tmp, 0                                                           //clear saveCtx bit<br>
     s_setreg_b32    hwreg(HW_REG_TRAPSTS, SQ_WAVE_TRAPSTS_SAVECTX_SHIFT, 1), s_save_tmp     //clear saveCtx bit<br>
 <br>
@@ -303,16 +216,7 @@ end<br>
     s_mov_b32       s_save_exec_hi, exec_hi<br>
     s_mov_b64       exec,   0x0                                                             //clear EXEC to get ready to receive<br>
 <br>
-if G8SR_DEBUG_TIMESTAMP<br>
-        s_memrealtime  s_g8sr_ts_sq_save_msg<br>
-        s_waitcnt lgkmcnt(0)<br>
-end<br>
-<br>
-    if (EMU_RUN_HACK)<br>
-<br>
-    else<br>
         s_sendmsg   sendmsg(MSG_SAVEWAVE)  //send SPI a message and wait for SPI's write to EXEC<br>
-    end<br>
 <br>
     // Set SPI_PRIO=2 to avoid starving instruction fetch in the waves we're waiting for.<br>
     s_or_b32 s_save_tmp, s_save_status, (2 << SQ_WAVE_STATUS_SPI_PRIO_SHIFT)<br>
@@ -321,36 +225,9 @@ end<br>
   L_SLEEP:<br>
     s_sleep 0x2                // sleep 1 (64clk) is not enough for 8 waves per SIMD, which will cause SQ hang, since the 7,8th wave could not get arbit to exec inst, while other waves are stuck into the sleep-loop and waiting for wrexec!=0<br>
 <br>
-    if (EMU_RUN_HACK)<br>
-<br>
-    else<br>
         s_cbranch_execz L_SLEEP<br>
-    end<br>
-<br>
-if G8SR_DEBUG_TIMESTAMP<br>
-        s_memrealtime  s_g8sr_ts_spi_wrexec<br>
-        s_waitcnt lgkmcnt(0)<br>
-end<br>
 <br>
     /*      setup Resource Contants    */<br>
-    if ((EMU_RUN_HACK) && (!EMU_RUN_HACK_SAVE_SINGLE_WAVE))<br>
-        //calculate wd_addr using absolute thread id<br>
-        v_readlane_b32 s_save_tmp, v9, 0<br>
-        s_lshr_b32 s_save_tmp, s_save_tmp, 6<br>
-        s_mul_i32 s_save_tmp, s_save_tmp, WAVE_SPACE<br>
-        s_add_i32 s_save_spi_init_lo, s_save_tmp, WG_BASE_ADDR_LO<br>
-        s_mov_b32 s_save_spi_init_hi, WG_BASE_ADDR_HI<br>
-        s_and_b32 s_save_spi_init_hi, s_save_spi_init_hi, CTX_SAVE_CONTROL<br>
-    else<br>
-    end<br>
-    if ((EMU_RUN_HACK) && (EMU_RUN_HACK_SAVE_SINGLE_WAVE))<br>
-        s_add_i32 s_save_spi_init_lo, s_save_tmp, WG_BASE_ADDR_LO<br>
-        s_mov_b32 s_save_spi_init_hi, WG_BASE_ADDR_HI<br>
-        s_and_b32 s_save_spi_init_hi, s_save_spi_init_hi, CTX_SAVE_CONTROL<br>
-    else<br>
-    end<br>
-<br>
-<br>
     s_mov_b32       s_save_buf_rsrc0,   s_save_spi_init_lo                                                      //base_addr_lo<br>
     s_and_b32       s_save_buf_rsrc1,   s_save_spi_init_hi, 0x0000FFFF                                          //base_addr_hi<br>
     s_or_b32        s_save_buf_rsrc1,   s_save_buf_rsrc1,  S_SAVE_BUF_RSRC_WORD1_STRIDE<br>
@@ -383,22 +260,10 @@ end<br>
 <br>
 <br>
     s_mov_b32       s_save_buf_rsrc2, 0x4                               //NUM_RECORDS   in bytes<br>
-    if (SWIZZLE_EN)<br>
-        s_add_u32       s_save_buf_rsrc2, s_save_buf_rsrc2, 0x0                     //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_save_buf_rsrc2,  0x1000000                                //NUM_RECORDS in bytes<br>
-    end<br>
 <br>
 <br>
     write_hwreg_to_mem(s_save_m0, s_save_buf_rsrc0, s_save_mem_offset)                  //M0<br>
-<br>
-    if ((EMU_RUN_HACK) && (EMU_RUN_HACK_SAVE_FIRST_TIME))<br>
-        s_add_u32 s_save_pc_lo, s_save_pc_lo, 4             //pc[31:0]+4<br>
-        s_addc_u32 s_save_pc_hi, s_save_pc_hi, 0x0          //carry bit over<br>
-        s_mov_b32   tba_lo, EMU_RUN_HACK_SAVE_FIRST_TIME_TBA_LO<br>
-        s_mov_b32   tba_hi, EMU_RUN_HACK_SAVE_FIRST_TIME_TBA_HI<br>
-    end<br>
-<br>
     write_hwreg_to_mem(s_save_pc_lo, s_save_buf_rsrc0, s_save_mem_offset)                   //PC<br>
     write_hwreg_to_mem(s_save_pc_hi, s_save_buf_rsrc0, s_save_mem_offset)<br>
     write_hwreg_to_mem(s_save_exec_lo, s_save_buf_rsrc0, s_save_mem_offset)             //EXEC<br>
@@ -440,18 +305,8 @@ end<br>
     s_add_u32       s_save_alloc_size, s_save_alloc_size, 1<br>
     s_lshl_b32      s_save_alloc_size, s_save_alloc_size, 4                         //Number of SGPRs = (sgpr_size + 1) * 16   (non-zero value)<br>
 <br>
-    if (SGPR_SAVE_USE_SQC)<br>
         s_lshl_b32      s_save_buf_rsrc2,   s_save_alloc_size, 2                    //NUM_RECORDS in bytes<br>
-    else<br>
-        s_lshl_b32      s_save_buf_rsrc2,   s_save_alloc_size, 8                    //NUM_RECORDS in bytes (64 threads)<br>
-    end<br>
-<br>
-    if (SWIZZLE_EN)<br>
-        s_add_u32       s_save_buf_rsrc2, s_save_buf_rsrc2, 0x0                     //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_save_buf_rsrc2,  0x1000000                                //NUM_RECORDS in bytes<br>
-    end<br>
-<br>
 <br>
     // backup s_save_buf_rsrc0,1 to s_save_pc_lo/hi, since write_16sgpr_to_mem function will change the rsrc0<br>
     //s_mov_b64 s_save_pc_lo, s_save_buf_rsrc0<br>
@@ -490,30 +345,14 @@ end<br>
     s_mov_b32       exec_lo, 0xFFFFFFFF                                             //need every thread from now on<br>
     s_mov_b32       exec_hi, 0xFFFFFFFF<br>
 <br>
-    if (SWIZZLE_EN)<br>
-        s_add_u32       s_save_buf_rsrc2, s_save_buf_rsrc2, 0x0                     //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_save_buf_rsrc2,  0x1000000                                //NUM_RECORDS in bytes<br>
-    end<br>
-<br>
 <br>
     // VGPR Allocated in 4-GPR granularity<br>
 <br>
-if G8SR_VGPR_SR_IN_DWX4<br>
-        // the const stride for DWx4 is 4*4 bytes<br>
-        s_and_b32 s_save_buf_rsrc1, s_save_buf_rsrc1, 0x0000FFFF   // reset const stride to 0<br>
-        s_or_b32  s_save_buf_rsrc1, s_save_buf_rsrc1, G8SR_SAVE_BUF_RSRC_WORD1_STRIDE_DWx4  // const stride to 4*4 bytes<br>
-<br>
-        buffer_store_dwordx4 v0, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1<br>
-<br>
-        s_and_b32 s_save_buf_rsrc1, s_save_buf_rsrc1, 0x0000FFFF   // reset const stride to 0<br>
-        s_or_b32  s_save_buf_rsrc1, s_save_buf_rsrc1, S_SAVE_BUF_RSRC_WORD1_STRIDE  // reset const stride to 4 bytes<br>
-else<br>
         buffer_store_dword v0, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1<br>
         buffer_store_dword v1, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1  offset:256<br>
         buffer_store_dword v2, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1  offset:256*2<br>
         buffer_store_dword v3, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1  offset:256*3<br>
-end<br>
 <br>
 <br>
 <br>
@@ -549,64 +388,10 @@ end<br>
     s_add_u32 s_save_mem_offset, s_save_mem_offset, get_hwreg_size_bytes()<br>
 <br>
 <br>
-    if (SWIZZLE_EN)<br>
-        s_add_u32       s_save_buf_rsrc2, s_save_buf_rsrc2, 0x0       //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_save_buf_rsrc2,  0x1000000                  //NUM_RECORDS in bytes<br>
-    end<br>
-<br>
     s_mov_b32       m0, 0x0                                               //lds_offset initial value = 0<br>
 <br>
 <br>
-var LDS_DMA_ENABLE = 0<br>
-var UNROLL = 0<br>
-if UNROLL==0 && LDS_DMA_ENABLE==1<br>
-        s_mov_b32  s3, 256*2<br>
-        s_nop 0<br>
-        s_nop 0<br>
-        s_nop 0<br>
-  L_SAVE_LDS_LOOP:<br>
-        //TODO: looks the 2 buffer_store/load clause for s/r will hurt performance.???<br>
-    if (SAVE_LDS)     //SPI always alloc LDS space in 128DW granularity<br>
-            buffer_store_lds_dword s_save_buf_rsrc0, s_save_mem_offset lds:1            // first 64DW<br>
-            buffer_store_lds_dword s_save_buf_rsrc0, s_save_mem_offset lds:1 offset:256 // second 64DW<br>
-    end<br>
-<br>
-    s_add_u32       m0, m0, s3                                          //every buffer_store_lds does 256 bytes<br>
-    s_add_u32       s_save_mem_offset, s_save_mem_offset, s3                            //mem offset increased by 256 bytes<br>
-    s_cmp_lt_u32    m0, s_save_alloc_size                                               //scc=(m0 < s_save_alloc_size) ? 1 : 0<br>
-    s_cbranch_scc1  L_SAVE_LDS_LOOP                                                     //LDS save is complete?<br>
-<br>
-elsif LDS_DMA_ENABLE==1 && UNROLL==1 // UNROOL  , has ichace miss<br>
-      // store from higest LDS address to lowest<br>
-      s_mov_b32  s3, 256*2<br>
-      s_sub_u32  m0, s_save_alloc_size, s3<br>
-      s_add_u32 s_save_mem_offset, s_save_mem_offset, m0<br>
-      s_lshr_b32 s_save_alloc_size, s_save_alloc_size, 9   // how many 128 trunks...<br>
-      s_sub_u32 s_save_alloc_size, 128, s_save_alloc_size   // store from higheset addr to lowest<br>
-      s_mul_i32 s_save_alloc_size, s_save_alloc_size, 6*4   // PC offset increment,  each LDS save block cost 6*4 Bytes instruction<br>
-      s_add_u32 s_save_alloc_size, s_save_alloc_size, 3*4   //2is the below 2 inst...//s_addc and s_setpc<br>
-      s_nop 0<br>
-      s_nop 0<br>
-      s_nop 0   //pad 3 dw to let LDS_DMA align with 64Bytes<br>
-      s_getpc_b64 s[0:1]                              // reuse s[0:1], since s[0:1] already saved<br>
-      s_add_u32   s0, s0,s_save_alloc_size<br>
-      s_addc_u32  s1, s1, 0<br>
-      s_setpc_b64 s[0:1]<br>
-<br>
-<br>
-       for var i =0; i< 128; i++<br>
-            // be careful to make here a 64Byte aligned address, which could improve performance...<br>
-            buffer_store_lds_dword s_save_buf_rsrc0, s_save_mem_offset lds:1 offset:0           // first 64DW<br>
-            buffer_store_lds_dword s_save_buf_rsrc0, s_save_mem_offset lds:1 offset:256           // second 64DW<br>
-<br>
-        if i!=127<br>
-        s_sub_u32  m0, m0, s3      // use a sgpr to shrink 2DW-inst to 1DW inst to improve performance , i.e.  pack more LDS_DMA inst to one Cacheline<br>
-            s_sub_u32  s_save_mem_offset, s_save_mem_offset,  s3<br>
-            end<br>
-       end<br>
-<br>
-else   // BUFFER_STORE<br>
       v_mbcnt_lo_u32_b32 v2, 0xffffffff, 0x0<br>
       v_mbcnt_hi_u32_b32 v3, 0xffffffff, v2     // tid<br>
       v_mul_i32_i24 v2, v3, 8   // tid*8<br>
@@ -628,8 +413,6 @@ L_SAVE_LDS_LOOP_VECTOR:<br>
       // restore rsrc3<br>
       s_mov_b32 s_save_buf_rsrc3, s0<br>
 <br>
-end<br>
-<br>
 L_SAVE_LDS_DONE:<br>
 <br>
 <br>
@@ -647,44 +430,8 @@ L_SAVE_LDS_DONE:<br>
     s_add_u32       s_save_alloc_size, s_save_alloc_size, 1<br>
     s_lshl_b32      s_save_alloc_size, s_save_alloc_size, 2                         //Number of VGPRs = (vgpr_size + 1) * 4    (non-zero value)   //FIXME for GFX, zero is possible<br>
     s_lshl_b32      s_save_buf_rsrc2,  s_save_alloc_size, 8                         //NUM_RECORDS in bytes (64 threads*4)<br>
-    if (SWIZZLE_EN)<br>
-        s_add_u32       s_save_buf_rsrc2, s_save_buf_rsrc2, 0x0                     //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_save_buf_rsrc2,  0x1000000                                //NUM_RECORDS in bytes<br>
-    end<br>
-<br>
-<br>
-    // VGPR Allocated in 4-GPR granularity<br>
-<br>
-if G8SR_VGPR_SR_IN_DWX4<br>
-        // the const stride for DWx4 is 4*4 bytes<br>
-        s_and_b32 s_save_buf_rsrc1, s_save_buf_rsrc1, 0x0000FFFF   // reset const stride to 0<br>
-        s_or_b32  s_save_buf_rsrc1, s_save_buf_rsrc1, G8SR_SAVE_BUF_RSRC_WORD1_STRIDE_DWx4  // const stride to 4*4 bytes<br>
-<br>
-        s_mov_b32         m0, 4     // skip first 4 VGPRs<br>
-        s_cmp_lt_u32      m0, s_save_alloc_size<br>
-        s_cbranch_scc0    L_SAVE_VGPR_LOOP_END      // no more vgprs<br>
 <br>
-        s_set_gpr_idx_on  m0, 0x1   // This will change M0<br>
-        s_add_u32         s_save_alloc_size, s_save_alloc_size, 0x1000  // because above inst change m0<br>
-L_SAVE_VGPR_LOOP:<br>
-        v_mov_b32         v0, v0   // v0 = v[0+m0]<br>
-        v_mov_b32         v1, v1<br>
-        v_mov_b32         v2, v2<br>
-        v_mov_b32         v3, v3<br>
-<br>
-<br>
-        buffer_store_dwordx4 v0, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1<br>
-        s_add_u32         m0, m0, 4<br>
-        s_add_u32         s_save_mem_offset, s_save_mem_offset, 256*4<br>
-        s_cmp_lt_u32      m0, s_save_alloc_size<br>
-    s_cbranch_scc1  L_SAVE_VGPR_LOOP                                                //VGPR save is complete?<br>
-    s_set_gpr_idx_off<br>
-L_SAVE_VGPR_LOOP_END:<br>
-<br>
-        s_and_b32 s_save_buf_rsrc1, s_save_buf_rsrc1, 0x0000FFFF   // reset const stride to 0<br>
-        s_or_b32  s_save_buf_rsrc1, s_save_buf_rsrc1, S_SAVE_BUF_RSRC_WORD1_STRIDE  // reset const stride to 4 bytes<br>
-else<br>
     // VGPR store using dw burst<br>
     s_mov_b32         m0, 0x4   //VGPR initial index value =0<br>
     s_cmp_lt_u32      m0, s_save_alloc_size<br>
@@ -700,52 +447,18 @@ else<br>
     v_mov_b32       v2, v2              //v0 = v[0+m0]<br>
     v_mov_b32       v3, v3              //v0 = v[0+m0]<br>
 <br>
-    if(USE_MTBUF_INSTEAD_OF_MUBUF)<br>
-        tbuffer_store_format_x v0, v0, s_save_buf_rsrc0, s_save_mem_offset format:BUF_NUM_FORMAT_FLOAT format: BUF_DATA_FORMAT_32 slc:1 glc:1<br>
-    else<br>
         buffer_store_dword v0, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1<br>
         buffer_store_dword v1, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1  offset:256<br>
         buffer_store_dword v2, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1  offset:256*2<br>
         buffer_store_dword v3, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1  offset:256*3<br>
-    end<br>
 <br>
     s_add_u32       m0, m0, 4                                                       //next vgpr index<br>
     s_add_u32       s_save_mem_offset, s_save_mem_offset, 256*4                     //every buffer_store_dword does 256 bytes<br>
     s_cmp_lt_u32    m0, s_save_alloc_size                                           //scc = (m0 < s_save_alloc_size) ? 1 : 0<br>
     s_cbranch_scc1  L_SAVE_VGPR_LOOP                                                //VGPR save is complete?<br>
     s_set_gpr_idx_off<br>
-end<br>
 <br>
 L_SAVE_VGPR_END:<br>
-<br>
-<br>
-<br>
-<br>
-<br>
-<br>
-    /*     S_PGM_END_SAVED  */                              //FIXME  graphics ONLY<br>
-    if ((EMU_RUN_HACK) && (!EMU_RUN_HACK_SAVE_NORMAL_EXIT))<br>
-        s_and_b32 s_save_pc_hi, s_save_pc_hi, 0x0000ffff    //pc[47:32]<br>
-        s_add_u32 s_save_pc_lo, s_save_pc_lo, 4             //pc[31:0]+4<br>
-        s_addc_u32 s_save_pc_hi, s_save_pc_hi, 0x0          //carry bit over<br>
-        s_rfe_b64 s_save_pc_lo                              //Return to the main shader program<br>
-    else<br>
-    end<br>
-<br>
-// Save Done timestamp<br>
-if G8SR_DEBUG_TIMESTAMP<br>
-        s_memrealtime   s_g8sr_ts_save_d<br>
-        // SGPR SR memory offset : size(VGPR)<br>
-        get_vgpr_size_bytes(s_save_mem_offset)<br>
-        s_add_u32 s_save_mem_offset, s_save_mem_offset, G8SR_DEBUG_TS_SAVE_D_OFFSET<br>
-        s_waitcnt lgkmcnt(0)         //FIXME, will cause xnack??<br>
-        // Need reset rsrc2??<br>
-        s_mov_b32 m0, s_save_mem_offset<br>
-        s_mov_b32 s_save_buf_rsrc2,  0x1000000                                  //NUM_RECORDS in bytes<br>
-        s_buffer_store_dwordx2 s_g8sr_ts_save_d, s_save_buf_rsrc0, m0       glc:1<br>
-end<br>
-<br>
-<br>
     s_branch    L_END_PGM<br>
 <br>
 <br>
@@ -756,27 +469,6 @@ end<br>
 <br>
 L_RESTORE:<br>
     /*      Setup Resource Contants    */<br>
-    if ((EMU_RUN_HACK) && (!EMU_RUN_HACK_RESTORE_NORMAL))<br>
-        //calculate wd_addr using absolute thread id<br>
-        v_readlane_b32 s_restore_tmp, v9, 0<br>
-        s_lshr_b32 s_restore_tmp, s_restore_tmp, 6<br>
-        s_mul_i32 s_restore_tmp, s_restore_tmp, WAVE_SPACE<br>
-        s_add_i32 s_restore_spi_init_lo, s_restore_tmp, WG_BASE_ADDR_LO<br>
-        s_mov_b32 s_restore_spi_init_hi, WG_BASE_ADDR_HI<br>
-        s_and_b32 s_restore_spi_init_hi, s_restore_spi_init_hi, CTX_RESTORE_CONTROL<br>
-    else<br>
-    end<br>
-<br>
-if G8SR_DEBUG_TIMESTAMP<br>
-        s_memrealtime   s_g8sr_ts_restore_s<br>
-        s_waitcnt lgkmcnt(0)         //FIXME, will cause xnack??<br>
-        // tma_lo/hi are sgpr 110, 111, which will not used for 112 SGPR allocated case...<br>
-        s_mov_b32 s_restore_pc_lo, s_g8sr_ts_restore_s[0]<br>
-        s_mov_b32 s_restore_pc_hi, s_g8sr_ts_restore_s[1]   //backup ts to ttmp0/1, sicne exec will be finally restored..<br>
-end<br>
-<br>
-<br>
-<br>
     s_mov_b32       s_restore_buf_rsrc0,    s_restore_spi_init_lo                                                           //base_addr_lo<br>
     s_and_b32       s_restore_buf_rsrc1,    s_restore_spi_init_hi, 0x0000FFFF                                               //base_addr_hi<br>
     s_or_b32        s_restore_buf_rsrc1,    s_restore_buf_rsrc1,  S_RESTORE_BUF_RSRC_WORD1_STRIDE<br>
@@ -818,18 +510,12 @@ end<br>
     s_add_u32  s_restore_mem_offset, s_restore_mem_offset, get_hwreg_size_bytes()            //FIXME, Check if offset overflow???<br>
 <br>
 <br>
-    if (SWIZZLE_EN)<br>
-        s_add_u32       s_restore_buf_rsrc2, s_restore_buf_rsrc2, 0x0                       //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_restore_buf_rsrc2,  0x1000000                                     //NUM_RECORDS in bytes<br>
-    end<br>
     s_mov_b32       m0, 0x0                                                                 //lds_offset initial value = 0<br>
 <br>
   L_RESTORE_LDS_LOOP:<br>
-    if (SAVE_LDS)<br>
         buffer_load_dword   v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset lds:1                    // first 64DW<br>
         buffer_load_dword   v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset lds:1 offset:256         // second 64DW<br>
-    end<br>
     s_add_u32       m0, m0, 256*2                                               // 128 DW<br>
     s_add_u32       s_restore_mem_offset, s_restore_mem_offset, 256*2           //mem offset increased by 128DW<br>
     s_cmp_lt_u32    m0, s_restore_alloc_size                                    //scc=(m0 < s_restore_alloc_size) ? 1 : 0<br>
@@ -848,40 +534,8 @@ end<br>
     s_add_u32       s_restore_alloc_size, s_restore_alloc_size, 1<br>
     s_lshl_b32      s_restore_alloc_size, s_restore_alloc_size, 2                           //Number of VGPRs = (vgpr_size + 1) * 4    (non-zero value)<br>
     s_lshl_b32      s_restore_buf_rsrc2,  s_restore_alloc_size, 8                           //NUM_RECORDS in bytes (64 threads*4)<br>
-    if (SWIZZLE_EN)<br>
-        s_add_u32       s_restore_buf_rsrc2, s_restore_buf_rsrc2, 0x0                       //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_restore_buf_rsrc2,  0x1000000                                     //NUM_RECORDS in bytes<br>
-    end<br>
-<br>
-if G8SR_VGPR_SR_IN_DWX4<br>
-     get_vgpr_size_bytes(s_restore_mem_offset)<br>
-     s_sub_u32         s_restore_mem_offset, s_restore_mem_offset, 256*4<br>
-<br>
-     // the const stride for DWx4 is 4*4 bytes<br>
-     s_and_b32 s_restore_buf_rsrc1, s_restore_buf_rsrc1, 0x0000FFFF   // reset const stride to 0<br>
-     s_or_b32  s_restore_buf_rsrc1, s_restore_buf_rsrc1, G8SR_RESTORE_BUF_RSRC_WORD1_STRIDE_DWx4  // const stride to 4*4 bytes<br>
-<br>
-     s_mov_b32         m0, s_restore_alloc_size<br>
-     s_set_gpr_idx_on  m0, 0x8    // Note.. This will change m0<br>
-<br>
-L_RESTORE_VGPR_LOOP:<br>
-     buffer_load_dwordx4 v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1<br>
-     s_waitcnt vmcnt(0)<br>
-     s_sub_u32         m0, m0, 4<br>
-     v_mov_b32         v0, v0   // v[0+m0] = v0<br>
-     v_mov_b32         v1, v1<br>
-     v_mov_b32         v2, v2<br>
-     v_mov_b32         v3, v3<br>
-     s_sub_u32         s_restore_mem_offset, s_restore_mem_offset, 256*4<br>
-     s_cmp_eq_u32      m0, 0x8000<br>
-     s_cbranch_scc0    L_RESTORE_VGPR_LOOP<br>
-     s_set_gpr_idx_off<br>
-<br>
-     s_and_b32 s_restore_buf_rsrc1, s_restore_buf_rsrc1, 0x0000FFFF   // reset const stride to 0<br>
-     s_or_b32  s_restore_buf_rsrc1, s_restore_buf_rsrc1, S_RESTORE_BUF_RSRC_WORD1_STRIDE  // const stride to 4*4 bytes<br>
-<br>
-else<br>
+<br>
     // VGPR load using dw burst<br>
     s_mov_b32       s_restore_mem_offset_save, s_restore_mem_offset     // restore start with v1, v0 will be the last<br>
     s_add_u32       s_restore_mem_offset, s_restore_mem_offset, 256*4<br>
@@ -890,14 +544,10 @@ else<br>
     s_add_u32       s_restore_alloc_size, s_restore_alloc_size, 0x8000                      //add 0x8000 since we compare m0 against it later<br>
 <br>
   L_RESTORE_VGPR_LOOP:<br>
-    if(USE_MTBUF_INSTEAD_OF_MUBUF)<br>
-        tbuffer_load_format_x v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset format:BUF_NUM_FORMAT_FLOAT format: BUF_DATA_FORMAT_32 slc:1 glc:1<br>
-    else<br>
         buffer_load_dword v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1<br>
         buffer_load_dword v1, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1 offset:256<br>
         buffer_load_dword v2, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1 offset:256*2<br>
         buffer_load_dword v3, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1 offset:256*3<br>
-    end<br>
     s_waitcnt       vmcnt(0)                                                                //ensure data ready<br>
     v_mov_b32       v0, v0                                                                  //v[0+m0] = v0<br>
     v_mov_b32       v1, v1<br>
@@ -909,16 +559,10 @@ else<br>
     s_cbranch_scc1  L_RESTORE_VGPR_LOOP                                                     //VGPR restore (except v0) is complete?<br>
     s_set_gpr_idx_off<br>
                                                                                             /* VGPR restore on v0 */<br>
-    if(USE_MTBUF_INSTEAD_OF_MUBUF)<br>
-        tbuffer_load_format_x v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save format:BUF_NUM_FORMAT_FLOAT format: BUF_DATA_FORMAT_32 slc:1 glc:1<br>
-    else<br>
         buffer_load_dword v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save    slc:1 glc:1<br>
         buffer_load_dword v1, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save    slc:1 glc:1 offset:256<br>
         buffer_load_dword v2, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save    slc:1 glc:1 offset:256*2<br>
         buffer_load_dword v3, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save    slc:1 glc:1 offset:256*3<br>
-    end<br>
-<br>
-end<br>
 <br>
     /*          restore SGPRs       */<br>
     //////////////////////////////<br>
@@ -934,16 +578,8 @@ end<br>
     s_add_u32       s_restore_alloc_size, s_restore_alloc_size, 1<br>
     s_lshl_b32      s_restore_alloc_size, s_restore_alloc_size, 4                           //Number of SGPRs = (sgpr_size + 1) * 16   (non-zero value)<br>
 <br>
-    if (SGPR_SAVE_USE_SQC)<br>
         s_lshl_b32      s_restore_buf_rsrc2,    s_restore_alloc_size, 2                     //NUM_RECORDS in bytes<br>
-    else<br>
-        s_lshl_b32      s_restore_buf_rsrc2,    s_restore_alloc_size, 8                     //NUM_RECORDS in bytes (64 threads)<br>
-    end<br>
-    if (SWIZZLE_EN)<br>
-        s_add_u32       s_restore_buf_rsrc2, s_restore_buf_rsrc2, 0x0                       //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_restore_buf_rsrc2,  0x1000000                                     //NUM_RECORDS in bytes<br>
-    end<br>
 <br>
     /* If 112 SGPRs ar allocated, 4 sgprs are not used TBA(108,109),TMA(110,111),<br>
        However, we are safe to restore these 4 SGPRs anyway, since TBA,TMA will later be restored by HWREG<br>
@@ -972,12 +608,6 @@ end<br>
     //////////////////////////////<br>
   L_RESTORE_HWREG:<br>
 <br>
-<br>
-if G8SR_DEBUG_TIMESTAMP<br>
-      s_mov_b32 s_g8sr_ts_restore_s[0], s_restore_pc_lo<br>
-      s_mov_b32 s_g8sr_ts_restore_s[1], s_restore_pc_hi<br>
-end<br>
-<br>
     // HWREG SR memory offset : size(VGPR)+size(SGPR)<br>
     get_vgpr_size_bytes(s_restore_mem_offset)<br>
     get_sgpr_size_bytes(s_restore_tmp)<br>
@@ -985,11 +615,7 @@ end<br>
 <br>
 <br>
     s_mov_b32       s_restore_buf_rsrc2, 0x4                                                //NUM_RECORDS   in bytes<br>
-    if (SWIZZLE_EN)<br>
-        s_add_u32       s_restore_buf_rsrc2, s_restore_buf_rsrc2, 0x0                       //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_restore_buf_rsrc2,  0x1000000                                     //NUM_RECORDS in bytes<br>
-    end<br>
 <br>
     read_hwreg_from_mem(s_restore_m0, s_restore_buf_rsrc0, s_restore_mem_offset)                    //M0<br>
     read_hwreg_from_mem(s_restore_pc_lo, s_restore_buf_rsrc0, s_restore_mem_offset)             //PC<br>
@@ -1006,16 +632,6 @@ end<br>
 <br>
     s_waitcnt       lgkmcnt(0)                                                                                      //from now on, it is safe to restore STATUS and IB_STS<br>
 <br>
-    //for normal save & restore, the saved PC points to the next inst to execute, no adjustment needs to be made, otherwise:<br>
-    if ((EMU_RUN_HACK) && (!EMU_RUN_HACK_RESTORE_NORMAL))<br>
-        s_add_u32 s_restore_pc_lo, s_restore_pc_lo, 8            //pc[31:0]+8     //two back-to-back s_trap are used (first for save and second for restore)<br>
-        s_addc_u32  s_restore_pc_hi, s_restore_pc_hi, 0x0        //carry bit over<br>
-    end<br>
-    if ((EMU_RUN_HACK) && (EMU_RUN_HACK_RESTORE_NORMAL))<br>
-        s_add_u32 s_restore_pc_lo, s_restore_pc_lo, 4            //pc[31:0]+4     // save is hack through s_trap but restore is normal<br>
-        s_addc_u32  s_restore_pc_hi, s_restore_pc_hi, 0x0        //carry bit over<br>
-    end<br>
-<br>
     s_mov_b32       m0,         s_restore_m0<br>
     s_mov_b32       exec_lo,    s_restore_exec_lo<br>
     s_mov_b32       exec_hi,    s_restore_exec_hi<br>
@@ -1048,11 +664,6 @@ end<br>
 <br>
     s_barrier                                                   //barrier to ensure the readiness of LDS before access attempts from any other wave in the same TG //FIXME not performance-optimal at this time<br>
 <br>
-if G8SR_DEBUG_TIMESTAMP<br>
-    s_memrealtime s_g8sr_ts_restore_d<br>
-    s_waitcnt lgkmcnt(0)<br>
-end<br>
-<br>
 //  s_rfe_b64 s_restore_pc_lo                                   //Return to the main shader program and resume execution<br>
     s_rfe_restore_b64  s_restore_pc_lo, s_restore_m0            // s_restore_m0[0] is used to set STATUS.inst_atc<br>
 <br>
diff --git a/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx9.asm b/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx9.asm<br>
index cee4cfd..75f29d1 100644<br>
--- a/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx9.asm<br>
+++ b/drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx9.asm<br>
@@ -24,75 +24,6 @@<br>
  * PROJECT=greenland ./sp3 cwsr_trap_handler_gfx9.asm -hex tmp.hex<br>
  */<br>
 <br>
-/* HW (GFX9) source code for CWSR trap handler */<br>
-/* Version 18 + multiple trap handler */<br>
-<br>
-// this performance-optimal version was originally from Seven Xu at SRDC<br>
-<br>
-// Revison #18  --...<br>
-/* Rev History<br>
-** #1. Branch from gc dv.   //gfxip/gfx9/main/src/test/suites/block/cs/sr/cs_trap_handler.sp3#1,#50, #51, #52-53(Skip, Already Fixed by PV), #54-56(merged),#57-58(mergerd, skiped-already fixed by PV)<br>
-** #4. SR Memory Layout:<br>
-**                      1. VGPR-SGPR-HWREG-{LDS}<br>
-**                      2. tba_hi.bits.26 - reconfigured as the first wave in tg bits, for defer Save LDS for a threadgroup.. performance concern..<br>
-** #5. Update: 1. Accurate g8sr_ts_save_d timestamp<br>
-** #6. Update: 1. Fix s_barrier usage; 2. VGPR s/r using swizzle buffer?(NoNeed, already matched the swizzle pattern, more investigation)<br>
-** #7. Update: 1. don't barrier if noLDS<br>
-** #8. Branch: 1. Branch to ver#0, which is very similar to gc dv version<br>
-**            2. Fix SQ issue by s_sleep 2<br>
-** #9. Update: 1. Fix scc restore failed issue, restore wave_status at last<br>
-**            2. optimize s_buffer save by burst 16sgprs...<br>
-** #10. Update 1. Optimize restore sgpr by busrt 16 sgprs.<br>
-** #11. Update 1. Add 2 more timestamp for debug version<br>
-** #12. Update 1. Add VGPR SR using DWx4, some case improve and some case drop performance<br>
-** #13. Integ  1. Always use MUBUF for PV trap shader...<br>
-** #14. Update 1. s_buffer_store soft clause...<br>
-** #15. Update 1. PERF - sclar write with glc:0/mtype0 to allow L2 combine. perf improvement a lot.<br>
-** #16. Update 1. PRRF - UNROLL LDS_DMA got 2500cycle save in IP tree<br>
-** #17. Update 1. FUNC - LDS_DMA has issues while ATC, replace with ds_read/buffer_store for save part[TODO restore part]<br>
-**            2. PERF - Save LDS before save VGPR to cover LDS save long latency...<br>
-** #18. Update 1. FUNC - Implicitly estore STATUS.VCCZ, which is not writable by s_setreg_b32<br>
-**            2. FUNC - Handle non-CWSR traps<br>
-*/<br>
-<br>
-var G8SR_WDMEM_HWREG_OFFSET = 0<br>
-var G8SR_WDMEM_SGPR_OFFSET  = 128  // in bytes<br>
-<br>
-// Keep definition same as the app shader, These 2 time stamps are part of the app shader... Should before any Save and after restore.<br>
-<br>
-var G8SR_DEBUG_TIMESTAMP = 0<br>
-var G8SR_DEBUG_TS_SAVE_D_OFFSET = 40*4 // ts_save_d timestamp offset relative to SGPR_SR_memory_offset<br>
-var s_g8sr_ts_save_s   = s[34:35]   // save start<br>
-var s_g8sr_ts_sq_save_msg  = s[36:37]  // The save shader send SAVEWAVE msg to spi<br>
-var s_g8sr_ts_spi_wrexec   = s[38:39]  // the SPI write the sr address to SQ<br>
-var s_g8sr_ts_save_d   = s[40:41]   // save end<br>
-var s_g8sr_ts_restore_s = s[42:43]   // restore start<br>
-var s_g8sr_ts_restore_d = s[44:45]   // restore end<br>
-<br>
-var G8SR_VGPR_SR_IN_DWX4 = 0<br>
-var G8SR_SAVE_BUF_RSRC_WORD1_STRIDE_DWx4 = 0x00100000   // DWx4 stride is 4*4Bytes<br>
-var G8SR_RESTORE_BUF_RSRC_WORD1_STRIDE_DWx4  = G8SR_SAVE_BUF_RSRC_WORD1_STRIDE_DWx4<br>
-<br>
-<br>
-/*************************************************************************/<br>
-/*                 control on how to run the shader                      */<br>
-/*************************************************************************/<br>
-//any hack that needs to be made to run this code in EMU (either because various EMU code are not ready or no compute save & restore in EMU run)<br>
-var EMU_RUN_HACK                   =    0<br>
-var EMU_RUN_HACK_RESTORE_NORMAL            =    0<br>
-var EMU_RUN_HACK_SAVE_NORMAL_EXIT   =  0<br>
-var EMU_RUN_HACK_SAVE_SINGLE_WAVE   =  0<br>
-var EMU_RUN_HACK_SAVE_FIRST_TIME    =  0                   //for interrupted restore in which the first save is through EMU_RUN_HACK<br>
-var SAVE_LDS                       =    1<br>
-var WG_BASE_ADDR_LO                =    0x9000a000<br>
-var WG_BASE_ADDR_HI                =    0x0<br>
-var WAVE_SPACE                     =    0x5000              //memory size that each wave occupies in workgroup state mem<br>
-var CTX_SAVE_CONTROL               =    0x0<br>
-var CTX_RESTORE_CONTROL                    =    CTX_SAVE_CONTROL<br>
-var SIM_RUN_HACK                   =    0                   //any hack that needs to be made to run this code in SIM (either because various RTL code are not ready or no compute save & restore in RTL run)<br>
-var SGPR_SAVE_USE_SQC              =    1                   //use SQC D$ to do the write<br>
-var USE_MTBUF_INSTEAD_OF_MUBUF     =    0                   //because TC EMU currently asserts on 0 of // overload DFMT field to carry 4 more bits of stride for MUBUF opcodes<br>
-var SWIZZLE_EN                     =    0                   //whether we use swizzled buffer addressing<br>
 var ACK_SQC_STORE                   =    1                   //workaround for suspected SQC store bug causing incorrect stores under concurrency<br>
 var SAVE_AFTER_XNACK_ERROR          =    1                   //workaround for TCP store failure after XNACK error when ALLOW_REPLAY=0, for debugger<br>
 var SINGLE_STEP_MISSED_WORKAROUND   =   1                   //workaround for lost MODE.DEBUG_EN exception when SAVECTX raised<br>
@@ -238,16 +169,7 @@ shader main<br>
   type(CS)<br>
 <br>
 <br>
-    if ((EMU_RUN_HACK) && (!EMU_RUN_HACK_RESTORE_NORMAL))                  //hack to use trap_id for determining save/restore<br>
-       //FIXME VCCZ un-init assertion s_getreg_b32     s_save_status, hwreg(HW_REG_STATUS)         //save STATUS since we will change SCC<br>
-       s_and_b32 s_save_tmp, s_save_pc_hi, 0xffff0000              //change SCC<br>
-       s_cmp_eq_u32 s_save_tmp, 0x007e0000                         //Save: trap_id = 0x7e. Restore: trap_id = 0x7f.<br>
-       s_cbranch_scc0 L_JUMP_TO_RESTORE                            //do not need to recover STATUS here  since we are going to RESTORE<br>
-       //FIXME  s_setreg_b32    hwreg(HW_REG_STATUS),   s_save_status       //need to recover STATUS since we are going to SAVE<br>
-       s_branch L_SKIP_RESTORE                                     //NOT restore, SAVE actually<br>
-    else<br>
         s_branch L_SKIP_RESTORE                                     //NOT restore. might be a regular trap or save<br>
-    end<br>
 <br>
 L_JUMP_TO_RESTORE:<br>
     s_branch L_RESTORE                                             //restore<br>
@@ -278,7 +200,7 @@ end<br>
     s_cbranch_scc1  L_SAVE                                     //this is the operation for save<br>
 <br>
     // *********    Handle non-CWSR traps      *******************<br>
-if (!EMU_RUN_HACK)<br>
+<br>
     // Illegal instruction is a non-maskable exception which blocks context save.<br>
     // Halt the wavefront and return from the trap.<br>
     s_and_b32       ttmp2, s_save_trapsts, SQ_WAVE_TRAPSTS_ILLEGAL_INST_MASK<br>
@@ -355,7 +277,7 @@ L_EXCP_CASE:<br>
     set_status_without_spi_prio(s_save_status, ttmp2)<br>
 <br>
     s_rfe_b64       [ttmp0, ttmp1]<br>
-end<br>
+<br>
     // *********       End handling of non-CWSR traps   *******************<br>
 <br>
 /**************************************************************************/<br>
@@ -363,12 +285,6 @@ end<br>
 /**************************************************************************/<br>
 <br>
 L_SAVE:<br>
-<br>
-if G8SR_DEBUG_TIMESTAMP<br>
-       s_memrealtime   s_g8sr_ts_save_s<br>
-       s_waitcnt lgkmcnt(0)         //FIXME, will cause xnack??<br>
-end<br>
-<br>
     s_and_b32      s_save_pc_hi, s_save_pc_hi, 0x0000ffff    //pc[47:32]<br>
 <br>
     s_mov_b32      s_save_tmp, 0                                                            //clear saveCtx bit<br>
@@ -390,16 +306,7 @@ end<br>
     s_mov_b32      s_save_exec_hi, exec_hi<br>
     s_mov_b64      exec,   0x0                                                              //clear EXEC to get ready to receive<br>
 <br>
-if G8SR_DEBUG_TIMESTAMP<br>
-       s_memrealtime  s_g8sr_ts_sq_save_msg<br>
-       s_waitcnt lgkmcnt(0)<br>
-end<br>
-<br>
-    if (EMU_RUN_HACK)<br>
-<br>
-    else<br>
         s_sendmsg   sendmsg(MSG_SAVEWAVE)  //send SPI a message and wait for SPI's write to EXEC<br>
-    end<br>
 <br>
     // Set SPI_PRIO=2 to avoid starving instruction fetch in the waves we're waiting for.<br>
     s_or_b32 s_save_tmp, s_save_status, (2 << SQ_WAVE_STATUS_SPI_PRIO_SHIFT)<br>
@@ -408,33 +315,7 @@ end<br>
   L_SLEEP:<br>
     s_sleep 0x2                       // sleep 1 (64clk) is not enough for 8 waves per SIMD, which will cause SQ hang, since the 7,8th wave could not get arbit to exec inst, while other waves are stuck into the sleep-loop and waiting for wrexec!=0<br>
 <br>
-    if (EMU_RUN_HACK)<br>
-<br>
-    else<br>
         s_cbranch_execz L_SLEEP<br>
-    end<br>
-<br>
-if G8SR_DEBUG_TIMESTAMP<br>
-       s_memrealtime  s_g8sr_ts_spi_wrexec<br>
-       s_waitcnt lgkmcnt(0)<br>
-end<br>
-<br>
-    if ((EMU_RUN_HACK) && (!EMU_RUN_HACK_SAVE_SINGLE_WAVE))<br>
-       //calculate wd_addr using absolute thread id<br>
-       v_readlane_b32 s_save_tmp, v9, 0<br>
-       s_lshr_b32 s_save_tmp, s_save_tmp, 6<br>
-       s_mul_i32 s_save_tmp, s_save_tmp, WAVE_SPACE<br>
-       s_add_i32 s_save_spi_init_lo, s_save_tmp, WG_BASE_ADDR_LO<br>
-       s_mov_b32 s_save_spi_init_hi, WG_BASE_ADDR_HI<br>
-       s_and_b32 s_save_spi_init_hi, s_save_spi_init_hi, CTX_SAVE_CONTROL<br>
-    else<br>
-    end<br>
-    if ((EMU_RUN_HACK) && (EMU_RUN_HACK_SAVE_SINGLE_WAVE))<br>
-       s_add_i32 s_save_spi_init_lo, s_save_tmp, WG_BASE_ADDR_LO<br>
-       s_mov_b32 s_save_spi_init_hi, WG_BASE_ADDR_HI<br>
-       s_and_b32 s_save_spi_init_hi, s_save_spi_init_hi, CTX_SAVE_CONTROL<br>
-    else<br>
-    end<br>
 <br>
     // Save trap temporaries 4-11, 13 initialized by SPI debug dispatch logic<br>
     // ttmp SR memory offset : size(VGPR)+size(SGPR)+0x40<br>
@@ -484,20 +365,10 @@ end<br>
 <br>
 <br>
     s_mov_b32      s_save_buf_rsrc2, 0x4                                //NUM_RECORDS   in bytes<br>
-    if (SWIZZLE_EN)<br>
-       s_add_u32       s_save_buf_rsrc2, s_save_buf_rsrc2, 0x0                     //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_save_buf_rsrc2,  0x1000000                                //NUM_RECORDS in bytes<br>
-    end<br>
 <br>
 <br>
     write_hwreg_to_mem(s_save_m0, s_save_buf_rsrc0, s_save_mem_offset)                 //M0<br>
-<br>
-    if ((EMU_RUN_HACK) && (EMU_RUN_HACK_SAVE_FIRST_TIME))<br>
-       s_add_u32 s_save_pc_lo, s_save_pc_lo, 4             //pc[31:0]+4<br>
-       s_addc_u32 s_save_pc_hi, s_save_pc_hi, 0x0          //carry bit over<br>
-    end<br>
-<br>
     write_hwreg_to_mem(s_save_pc_lo, s_save_buf_rsrc0, s_save_mem_offset)                  //PC<br>
     write_hwreg_to_mem(s_save_pc_hi, s_save_buf_rsrc0, s_save_mem_offset)<br>
     write_hwreg_to_mem(s_save_exec_lo, s_save_buf_rsrc0, s_save_mem_offset)            //EXEC<br>
@@ -535,17 +406,9 @@ end<br>
     s_add_u32      s_save_alloc_size, s_save_alloc_size, 1<br>
     s_lshl_b32     s_save_alloc_size, s_save_alloc_size, 4                          //Number of SGPRs = (sgpr_size + 1) * 16   (non-zero value)<br>
 <br>
-    if (SGPR_SAVE_USE_SQC)<br>
         s_lshl_b32      s_save_buf_rsrc2,   s_save_alloc_size, 2                    //NUM_RECORDS in bytes<br>
-    else<br>
-       s_lshl_b32      s_save_buf_rsrc2,   s_save_alloc_size, 8                    //NUM_RECORDS in bytes (64 threads)<br>
-    end<br>
 <br>
-    if (SWIZZLE_EN)<br>
-       s_add_u32       s_save_buf_rsrc2, s_save_buf_rsrc2, 0x0                     //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_save_buf_rsrc2,  0x1000000                                //NUM_RECORDS in bytes<br>
-    end<br>
 <br>
 <br>
     // backup s_save_buf_rsrc0,1 to s_save_pc_lo/hi, since write_16sgpr_to_mem function will change the rsrc0<br>
@@ -588,25 +451,11 @@ end<br>
     s_mov_b32      xnack_mask_lo, 0x0<br>
     s_mov_b32      xnack_mask_hi, 0x0<br>
 <br>
-    if (SWIZZLE_EN)<br>
-       s_add_u32       s_save_buf_rsrc2, s_save_buf_rsrc2, 0x0                     //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_save_buf_rsrc2,  0x1000000                                //NUM_RECORDS in bytes<br>
-    end<br>
 <br>
 <br>
     // VGPR Allocated in 4-GPR granularity<br>
 <br>
-if G8SR_VGPR_SR_IN_DWX4<br>
-       // the const stride for DWx4 is 4*4 bytes<br>
-       s_and_b32 s_save_buf_rsrc1, s_save_buf_rsrc1, 0x0000FFFF   // reset const stride to 0<br>
-       s_or_b32  s_save_buf_rsrc1, s_save_buf_rsrc1, G8SR_SAVE_BUF_RSRC_WORD1_STRIDE_DWx4  // const stride to 4*4 bytes<br>
-<br>
-       buffer_store_dwordx4 v0, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1<br>
-<br>
-       s_and_b32 s_save_buf_rsrc1, s_save_buf_rsrc1, 0x0000FFFF   // reset const stride to 0<br>
-       s_or_b32  s_save_buf_rsrc1, s_save_buf_rsrc1, S_SAVE_BUF_RSRC_WORD1_STRIDE  // reset const stride to 4 bytes<br>
-else<br>
 if SAVE_AFTER_XNACK_ERROR<br>
         check_if_tcp_store_ok()<br>
         s_cbranch_scc1 L_SAVE_FIRST_VGPRS_WITH_TCP<br>
@@ -621,7 +470,6 @@ end<br>
         buffer_store_dword v1, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1  offset:256<br>
         buffer_store_dword v2, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1  offset:256*2<br>
         buffer_store_dword v3, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1  offset:256*3<br>
-end<br>
 <br>
 <br>
 <br>
@@ -656,64 +504,11 @@ end<br>
     s_add_u32 s_save_mem_offset, s_save_mem_offset, get_hwreg_size_bytes()<br>
 <br>
 <br>
-    if (SWIZZLE_EN)<br>
-       s_add_u32       s_save_buf_rsrc2, s_save_buf_rsrc2, 0x0       //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_save_buf_rsrc2,  0x1000000                  //NUM_RECORDS in bytes<br>
-    end<br>
 <br>
     s_mov_b32      m0, 0x0                                                //lds_offset initial value = 0<br>
 <br>
 <br>
-var LDS_DMA_ENABLE = 0<br>
-var UNROLL = 0<br>
-if UNROLL==0 && LDS_DMA_ENABLE==1<br>
-       s_mov_b32  s3, 256*2<br>
-       s_nop 0<br>
-       s_nop 0<br>
-       s_nop 0<br>
-  L_SAVE_LDS_LOOP:<br>
-       //TODO: looks the 2 buffer_store/load clause for s/r will hurt performance.???<br>
-    if (SAVE_LDS)     //SPI always alloc LDS space in 128DW granularity<br>
-           buffer_store_lds_dword s_save_buf_rsrc0, s_save_mem_offset lds:1             // first 64DW<br>
-           buffer_store_lds_dword s_save_buf_rsrc0, s_save_mem_offset lds:1 offset:256 // second 64DW<br>
-    end<br>
-<br>
-    s_add_u32      m0, m0, s3                                           //every buffer_store_lds does 256 bytes<br>
-    s_add_u32      s_save_mem_offset, s_save_mem_offset, s3                             //mem offset increased by 256 bytes<br>
-    s_cmp_lt_u32    m0, s_save_alloc_size                                              //scc=(m0 < s_save_alloc_size) ? 1 : 0<br>
-    s_cbranch_scc1  L_SAVE_LDS_LOOP                                                    //LDS save is complete?<br>
-<br>
-elsif LDS_DMA_ENABLE==1 && UNROLL==1 // UNROOL , has ichace miss<br>
-      // store from higest LDS address to lowest<br>
-      s_mov_b32         s3, 256*2<br>
-      s_sub_u32         m0, s_save_alloc_size, s3<br>
-      s_add_u32 s_save_mem_offset, s_save_mem_offset, m0<br>
-      s_lshr_b32 s_save_alloc_size, s_save_alloc_size, 9   // how many 128 trunks...<br>
-      s_sub_u32 s_save_alloc_size, 128, s_save_alloc_size   // store from higheset addr to lowest<br>
-      s_mul_i32 s_save_alloc_size, s_save_alloc_size, 6*4   // PC offset increment,  each LDS save block cost 6*4 Bytes instruction<br>
-      s_add_u32 s_save_alloc_size, s_save_alloc_size, 3*4   //2is the below 2 inst...//s_addc and s_setpc<br>
-      s_nop 0<br>
-      s_nop 0<br>
-      s_nop 0  //pad 3 dw to let LDS_DMA align with 64Bytes<br>
-      s_getpc_b64 s[0:1]                             // reuse s[0:1], since s[0:1] already saved<br>
-      s_add_u32          s0, s0,s_save_alloc_size<br>
-      s_addc_u32  s1, s1, 0<br>
-      s_setpc_b64 s[0:1]<br>
-<br>
-<br>
-       for var i =0; i< 128; i++<br>
-           // be careful to make here a 64Byte aligned address, which could improve performance...<br>
-           buffer_store_lds_dword s_save_buf_rsrc0, s_save_mem_offset lds:1 offset:0            // first 64DW<br>
-           buffer_store_lds_dword s_save_buf_rsrc0, s_save_mem_offset lds:1 offset:256            // second 64DW<br>
-<br>
-       if i!=127<br>
-       s_sub_u32  m0, m0, s3      // use a sgpr to shrink 2DW-inst to 1DW inst to improve performance , i.e.  pack more LDS_DMA inst to one Cacheline<br>
-           s_sub_u32  s_save_mem_offset, s_save_mem_offset,  s3<br>
-           end<br>
-       end<br>
-<br>
-else   // BUFFER_STORE<br>
       v_mbcnt_lo_u32_b32 v2, 0xffffffff, 0x0<br>
       v_mbcnt_hi_u32_b32 v3, 0xffffffff, v2    // tid<br>
 <br>
@@ -757,8 +552,6 @@ L_SAVE_LDS_LOOP_VECTOR:<br>
       // restore rsrc3<br>
       s_mov_b32 s_save_buf_rsrc3, s0<br>
 <br>
-end<br>
-<br>
 L_SAVE_LDS_DONE:<br>
 <br>
 <br>
@@ -776,44 +569,9 @@ L_SAVE_LDS_DONE:<br>
     s_add_u32      s_save_alloc_size, s_save_alloc_size, 1<br>
     s_lshl_b32     s_save_alloc_size, s_save_alloc_size, 2                          //Number of VGPRs = (vgpr_size + 1) * 4    (non-zero value)    //FIXME for GFX, zero is possible<br>
     s_lshl_b32     s_save_buf_rsrc2,  s_save_alloc_size, 8                          //NUM_RECORDS in bytes (64 threads*4)<br>
-    if (SWIZZLE_EN)<br>
-       s_add_u32       s_save_buf_rsrc2, s_save_buf_rsrc2, 0x0                     //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_save_buf_rsrc2,  0x1000000                                //NUM_RECORDS in bytes<br>
-    end<br>
 <br>
 <br>
-    // VGPR Allocated in 4-GPR granularity<br>
-<br>
-if G8SR_VGPR_SR_IN_DWX4<br>
-       // the const stride for DWx4 is 4*4 bytes<br>
-       s_and_b32 s_save_buf_rsrc1, s_save_buf_rsrc1, 0x0000FFFF   // reset const stride to 0<br>
-       s_or_b32  s_save_buf_rsrc1, s_save_buf_rsrc1, G8SR_SAVE_BUF_RSRC_WORD1_STRIDE_DWx4  // const stride to 4*4 bytes<br>
-<br>
-       s_mov_b32         m0, 4      // skip first 4 VGPRs<br>
-       s_cmp_lt_u32      m0, s_save_alloc_size<br>
-       s_cbranch_scc0    L_SAVE_VGPR_LOOP_END       // no more vgprs<br>
-<br>
-       s_set_gpr_idx_on  m0, 0x1   // This will change M0<br>
-       s_add_u32         s_save_alloc_size, s_save_alloc_size, 0x1000   // because above inst change m0<br>
-L_SAVE_VGPR_LOOP:<br>
-       v_mov_b32         v0, v0   // v0 = v[0+m0]<br>
-       v_mov_b32         v1, v1<br>
-       v_mov_b32         v2, v2<br>
-       v_mov_b32         v3, v3<br>
-<br>
-<br>
-       buffer_store_dwordx4 v0, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1<br>
-       s_add_u32         m0, m0, 4<br>
-       s_add_u32         s_save_mem_offset, s_save_mem_offset, 256*4<br>
-       s_cmp_lt_u32      m0, s_save_alloc_size<br>
-    s_cbranch_scc1  L_SAVE_VGPR_LOOP                                               //VGPR save is complete?<br>
-    s_set_gpr_idx_off<br>
-L_SAVE_VGPR_LOOP_END:<br>
-<br>
-       s_and_b32 s_save_buf_rsrc1, s_save_buf_rsrc1, 0x0000FFFF   // reset const stride to 0<br>
-       s_or_b32  s_save_buf_rsrc1, s_save_buf_rsrc1, S_SAVE_BUF_RSRC_WORD1_STRIDE  // reset const stride to 4 bytes<br>
-else<br>
     // VGPR store using dw burst<br>
     s_mov_b32        m0, 0x4    //VGPR initial index value =0<br>
     s_cmp_lt_u32      m0, s_save_alloc_size<br>
@@ -844,21 +602,16 @@ end<br>
     v_mov_b32      v2, v2               //v0 = v[0+m0]<br>
     v_mov_b32      v3, v3               //v0 = v[0+m0]<br>
 <br>
-    if(USE_MTBUF_INSTEAD_OF_MUBUF)<br>
-       tbuffer_store_format_x v0, v0, s_save_buf_rsrc0, s_save_mem_offset format:BUF_NUM_FORMAT_FLOAT format: BUF_DATA_FORMAT_32 slc:1 glc:1<br>
-    else<br>
         buffer_store_dword v0, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1<br>
         buffer_store_dword v1, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1  offset:256<br>
         buffer_store_dword v2, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1  offset:256*2<br>
         buffer_store_dword v3, v0, s_save_buf_rsrc0, s_save_mem_offset slc:1 glc:1  offset:256*3<br>
-    end<br>
 <br>
     s_add_u32      m0, m0, 4                                                        //next vgpr index<br>
     s_add_u32      s_save_mem_offset, s_save_mem_offset, 256*4                      //every buffer_store_dword does 256 bytes<br>
     s_cmp_lt_u32    m0, s_save_alloc_size                                          //scc = (m0 < s_save_alloc_size) ? 1 : 0<br>
     s_cbranch_scc1  L_SAVE_VGPR_LOOP                                               //VGPR save is complete?<br>
     s_set_gpr_idx_off<br>
-end<br>
 <br>
 L_SAVE_VGPR_END:<br>
 <br>
@@ -905,29 +658,6 @@ L_SAVE_ACCVGPR_LOOP:<br>
 L_SAVE_ACCVGPR_END:<br>
 end<br>
 <br>
-    /*    S_PGM_END_SAVED  */                               //FIXME  graphics ONLY<br>
-    if ((EMU_RUN_HACK) && (!EMU_RUN_HACK_SAVE_NORMAL_EXIT))<br>
-       s_and_b32 s_save_pc_hi, s_save_pc_hi, 0x0000ffff    //pc[47:32]<br>
-       s_add_u32 s_save_pc_lo, s_save_pc_lo, 4             //pc[31:0]+4<br>
-       s_addc_u32 s_save_pc_hi, s_save_pc_hi, 0x0          //carry bit over<br>
-       s_rfe_b64 s_save_pc_lo                              //Return to the main shader program<br>
-    else<br>
-    end<br>
-<br>
-// Save Done timestamp<br>
-if G8SR_DEBUG_TIMESTAMP<br>
-       s_memrealtime   s_g8sr_ts_save_d<br>
-       // SGPR SR memory offset : size(VGPR)<br>
-       get_vgpr_size_bytes(s_save_mem_offset)<br>
-       s_add_u32 s_save_mem_offset, s_save_mem_offset, G8SR_DEBUG_TS_SAVE_D_OFFSET<br>
-       s_waitcnt lgkmcnt(0)         //FIXME, will cause xnack??<br>
-       // Need reset rsrc2??<br>
-       s_mov_b32 m0, s_save_mem_offset<br>
-       s_mov_b32 s_save_buf_rsrc2,  0x1000000                                  //NUM_RECORDS in bytes<br>
-       s_buffer_store_dwordx2 s_g8sr_ts_save_d, s_save_buf_rsrc0, m0       glc:1<br>
-end<br>
-<br>
-<br>
     s_branch   L_END_PGM<br>
 <br>
 <br>
@@ -938,27 +668,6 @@ end<br>
 <br>
 L_RESTORE:<br>
     /*     Setup Resource Contants    */<br>
-    if ((EMU_RUN_HACK) && (!EMU_RUN_HACK_RESTORE_NORMAL))<br>
-       //calculate wd_addr using absolute thread id<br>
-       v_readlane_b32 s_restore_tmp, v9, 0<br>
-       s_lshr_b32 s_restore_tmp, s_restore_tmp, 6<br>
-       s_mul_i32 s_restore_tmp, s_restore_tmp, WAVE_SPACE<br>
-       s_add_i32 s_restore_spi_init_lo, s_restore_tmp, WG_BASE_ADDR_LO<br>
-       s_mov_b32 s_restore_spi_init_hi, WG_BASE_ADDR_HI<br>
-       s_and_b32 s_restore_spi_init_hi, s_restore_spi_init_hi, CTX_RESTORE_CONTROL<br>
-    else<br>
-    end<br>
-<br>
-if G8SR_DEBUG_TIMESTAMP<br>
-       s_memrealtime   s_g8sr_ts_restore_s<br>
-       s_waitcnt lgkmcnt(0)         //FIXME, will cause xnack??<br>
-       // tma_lo/hi are sgpr 110, 111, which will not used for 112 SGPR allocated case...<br>
-       s_mov_b32 s_restore_pc_lo, s_g8sr_ts_restore_s[0]<br>
-       s_mov_b32 s_restore_pc_hi, s_g8sr_ts_restore_s[1]   //backup ts to ttmp0/1, sicne exec will be finally restored..<br>
-end<br>
-<br>
-<br>
-<br>
     s_mov_b32      s_restore_buf_rsrc0,    s_restore_spi_init_lo                                                            //base_addr_lo<br>
     s_and_b32      s_restore_buf_rsrc1,    s_restore_spi_init_hi, 0x0000FFFF                                                //base_addr_hi<br>
     s_or_b32       s_restore_buf_rsrc1,    s_restore_buf_rsrc1,  S_RESTORE_BUF_RSRC_WORD1_STRIDE<br>
@@ -1000,18 +709,12 @@ end<br>
     s_add_u32  s_restore_mem_offset, s_restore_mem_offset, get_hwreg_size_bytes()           //FIXME, Check if offset overflow???<br>
 <br>
 <br>
-    if (SWIZZLE_EN)<br>
-       s_add_u32       s_restore_buf_rsrc2, s_restore_buf_rsrc2, 0x0                       //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_restore_buf_rsrc2,  0x1000000                                     //NUM_RECORDS in bytes<br>
-    end<br>
     s_mov_b32      m0, 0x0                                                                  //lds_offset initial value = 0<br>
 <br>
   L_RESTORE_LDS_LOOP:<br>
-    if (SAVE_LDS)<br>
         buffer_load_dword   v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset lds:1                    // first 64DW<br>
         buffer_load_dword   v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset lds:1 offset:256         // second 64DW<br>
-    end<br>
     s_add_u32      m0, m0, 256*2                                                // 128 DW<br>
     s_add_u32      s_restore_mem_offset, s_restore_mem_offset, 256*2            //mem offset increased by 128DW<br>
     s_cmp_lt_u32    m0, s_restore_alloc_size                                   //scc=(m0 < s_restore_alloc_size) ? 1 : 0<br>
@@ -1035,40 +738,8 @@ if ASIC_TARGET_ARCTURUS<br>
     s_mov_b32      s_restore_accvgpr_offset, s_restore_buf_rsrc2                           //ACC VGPRs at end of VGPRs<br>
 end<br>
 <br>
-    if (SWIZZLE_EN)<br>
-       s_add_u32       s_restore_buf_rsrc2, s_restore_buf_rsrc2, 0x0                       //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_restore_buf_rsrc2,  0x1000000                                     //NUM_RECORDS in bytes<br>
-    end<br>
 <br>
-if G8SR_VGPR_SR_IN_DWX4<br>
-     get_vgpr_size_bytes(s_restore_mem_offset)<br>
-     s_sub_u32        s_restore_mem_offset, s_restore_mem_offset, 256*4<br>
-<br>
-     // the const stride for DWx4 is 4*4 bytes<br>
-     s_and_b32 s_restore_buf_rsrc1, s_restore_buf_rsrc1, 0x0000FFFF   // reset const stride to 0<br>
-     s_or_b32  s_restore_buf_rsrc1, s_restore_buf_rsrc1, G8SR_RESTORE_BUF_RSRC_WORD1_STRIDE_DWx4  // const stride to 4*4 bytes<br>
-<br>
-     s_mov_b32        m0, s_restore_alloc_size<br>
-     s_set_gpr_idx_on  m0, 0x8   // Note.. This will change m0<br>
-<br>
-L_RESTORE_VGPR_LOOP:<br>
-     buffer_load_dwordx4 v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1<br>
-     s_waitcnt vmcnt(0)<br>
-     s_sub_u32        m0, m0, 4<br>
-     v_mov_b32        v0, v0    // v[0+m0] = v0<br>
-     v_mov_b32        v1, v1<br>
-     v_mov_b32        v2, v2<br>
-     v_mov_b32        v3, v3<br>
-     s_sub_u32        s_restore_mem_offset, s_restore_mem_offset, 256*4<br>
-     s_cmp_eq_u32      m0, 0x8000<br>
-     s_cbranch_scc0    L_RESTORE_VGPR_LOOP<br>
-     s_set_gpr_idx_off<br>
-<br>
-     s_and_b32 s_restore_buf_rsrc1, s_restore_buf_rsrc1, 0x0000FFFF   // reset const stride to 0<br>
-     s_or_b32  s_restore_buf_rsrc1, s_restore_buf_rsrc1, S_RESTORE_BUF_RSRC_WORD1_STRIDE  // const stride to 4*4 bytes<br>
-<br>
-else<br>
     // VGPR load using dw burst<br>
     s_mov_b32      s_restore_mem_offset_save, s_restore_mem_offset      // restore start with v1, v0 will be the last<br>
     s_add_u32      s_restore_mem_offset, s_restore_mem_offset, 256*4<br>
@@ -1081,9 +752,6 @@ end<br>
     s_add_u32      s_restore_alloc_size, s_restore_alloc_size, 0x8000                       //add 0x8000 since we compare m0 against it later<br>
 <br>
   L_RESTORE_VGPR_LOOP:<br>
-    if(USE_MTBUF_INSTEAD_OF_MUBUF)<br>
-       tbuffer_load_format_x v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset format:BUF_NUM_FORMAT_FLOAT format: BUF_DATA_FORMAT_32 slc:1 glc:1<br>
-    else<br>
 <br>
 if ASIC_TARGET_ARCTURUS<br>
         buffer_load_dword v0, v0, s_restore_buf_rsrc0, s_restore_accvgpr_offset slc:1 glc:1<br>
@@ -1102,7 +770,6 @@ end<br>
         buffer_load_dword v1, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1 offset:256<br>
         buffer_load_dword v2, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1 offset:256*2<br>
         buffer_load_dword v3, v0, s_restore_buf_rsrc0, s_restore_mem_offset slc:1 glc:1 offset:256*3<br>
-    end<br>
     s_waitcnt      vmcnt(0)                                                                 //ensure data ready<br>
     v_mov_b32      v0, v0                                                                   //v[0+m0] = v0<br>
     v_mov_b32      v1, v1<br>
@@ -1126,16 +793,10 @@ if ASIC_TARGET_ARCTURUS<br>
         end<br>
 end<br>
 <br>
-    if(USE_MTBUF_INSTEAD_OF_MUBUF)<br>
-       tbuffer_load_format_x v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save format:BUF_NUM_FORMAT_FLOAT format: BUF_DATA_FORMAT_32 slc:1 glc:1<br>
-    else<br>
         buffer_load_dword v0, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save    slc:1 glc:1<br>
         buffer_load_dword v1, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save    slc:1 glc:1 offset:256<br>
         buffer_load_dword v2, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save    slc:1 glc:1 offset:256*2<br>
         buffer_load_dword v3, v0, s_restore_buf_rsrc0, s_restore_mem_offset_save    slc:1 glc:1 offset:256*3<br>
-    end<br>
-<br>
-end<br>
 <br>
     /*         restore SGPRs       */<br>
     //////////////////////////////<br>
@@ -1151,16 +812,8 @@ end<br>
     s_add_u32      s_restore_alloc_size, s_restore_alloc_size, 1<br>
     s_lshl_b32     s_restore_alloc_size, s_restore_alloc_size, 4                            //Number of SGPRs = (sgpr_size + 1) * 16   (non-zero value)<br>
 <br>
-    if (SGPR_SAVE_USE_SQC)<br>
         s_lshl_b32      s_restore_buf_rsrc2,    s_restore_alloc_size, 2                     //NUM_RECORDS in bytes<br>
-    else<br>
-       s_lshl_b32      s_restore_buf_rsrc2,    s_restore_alloc_size, 8                     //NUM_RECORDS in bytes (64 threads)<br>
-    end<br>
-    if (SWIZZLE_EN)<br>
-       s_add_u32       s_restore_buf_rsrc2, s_restore_buf_rsrc2, 0x0                       //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_restore_buf_rsrc2,  0x1000000                                     //NUM_RECORDS in bytes<br>
-    end<br>
 <br>
     s_mov_b32 m0, s_restore_alloc_size<br>
 <br>
@@ -1188,11 +841,6 @@ end<br>
   L_RESTORE_HWREG:<br>
 <br>
 <br>
-if G8SR_DEBUG_TIMESTAMP<br>
-      s_mov_b32 s_g8sr_ts_restore_s[0], s_restore_pc_lo<br>
-      s_mov_b32 s_g8sr_ts_restore_s[1], s_restore_pc_hi<br>
-end<br>
-<br>
     // HWREG SR memory offset : size(VGPR)+size(SGPR)<br>
     get_vgpr_size_bytes(s_restore_mem_offset)<br>
     get_sgpr_size_bytes(s_restore_tmp)<br>
@@ -1200,11 +848,7 @@ end<br>
 <br>
 <br>
     s_mov_b32      s_restore_buf_rsrc2, 0x4                                                 //NUM_RECORDS   in bytes<br>
-    if (SWIZZLE_EN)<br>
-       s_add_u32       s_restore_buf_rsrc2, s_restore_buf_rsrc2, 0x0                       //FIXME need to use swizzle to enable bounds checking?<br>
-    else<br>
         s_mov_b32       s_restore_buf_rsrc2,  0x1000000                                     //NUM_RECORDS in bytes<br>
-    end<br>
 <br>
     read_hwreg_from_mem(s_restore_m0, s_restore_buf_rsrc0, s_restore_mem_offset)                   //M0<br>
     read_hwreg_from_mem(s_restore_pc_lo, s_restore_buf_rsrc0, s_restore_mem_offset)            //PC<br>
@@ -1219,16 +863,6 @@ end<br>
 <br>
     s_waitcnt      lgkmcnt(0)                                                                                       //from now on, it is safe to restore STATUS and IB_STS<br>
 <br>
-    //for normal save & restore, the saved PC points to the next inst to execute, no adjustment needs to be made, otherwise:<br>
-    if ((EMU_RUN_HACK) && (!EMU_RUN_HACK_RESTORE_NORMAL))<br>
-       s_add_u32 s_restore_pc_lo, s_restore_pc_lo, 8            //pc[31:0]+8      //two back-to-back s_trap are used (first for save and second for restore)<br>
-       s_addc_u32  s_restore_pc_hi, s_restore_pc_hi, 0x0        //carry bit over<br>
-    end<br>
-    if ((EMU_RUN_HACK) && (EMU_RUN_HACK_RESTORE_NORMAL))<br>
-       s_add_u32 s_restore_pc_lo, s_restore_pc_lo, 4            //pc[31:0]+4      // save is hack through s_trap but restore is normal<br>
-       s_addc_u32  s_restore_pc_hi, s_restore_pc_hi, 0x0        //carry bit over<br>
-    end<br>
-<br>
     s_mov_b32      m0,          s_restore_m0<br>
     s_mov_b32      exec_lo,     s_restore_exec_lo<br>
     s_mov_b32      exec_hi,     s_restore_exec_hi<br>
@@ -1275,11 +909,6 @@ end<br>
 <br>
     s_barrier                                                  //barrier to ensure the readiness of LDS before access attempts from any other wave in the same TG //FIXME not performance-optimal at this time<br>
 <br>
-if G8SR_DEBUG_TIMESTAMP<br>
-    s_memrealtime s_g8sr_ts_restore_d<br>
-    s_waitcnt lgkmcnt(0)<br>
-end<br>
-<br>
 //  s_rfe_b64 s_restore_pc_lo                                   //Return to the main shader program and resume execution<br>
     s_rfe_restore_b64  s_restore_pc_lo, s_restore_m0           // s_restore_m0[0] is used to set STATUS.inst_atc<br>
 <br>
-- <br>
2.7.4<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a></div>
</span></font></div>
</body>
</html>