Skip to content

Commit 532e2c8

Browse files
lancesixalexdeucher
authored andcommitted
drm/amdkfd: Do not include VGPR MSBs in saved PC during save
The current trap handler uses the top bits of ttmp1 to store a copy of sq_wave_mode.*vgpr_msb (except for src2_vgpr_msb). This is so the effective values in sq_wave_mode can be cleared to ensure correct behavior of the trap handler. When saving sq_wave_mode, the trap handler correctly rebuilds the expected value (with *vgpr_msb restored), so the save area is correct. However, the PC itself is copied from ttmp[0:1], which contains the wave's PC as well as the saved MSBs. The debugger reads the PC from the save area and is confused when non-0 values from VGPR_MSBs are present. This patch fixes this by saving the PC in the save area's PC slot, not the composite of the PC and VGPR_MSBs. On restore, the VGPR_MSBs are restored from sq_wave_mode. Signed-off-by: Lancelot Six <lancelot.six@amd.com> Tested-by: Alexey Kondratiev <Alexey.Kondratiev@amd.com> Reviewed-by: Jay Cornwall <jay.cornwall@amd.com> Cc: Vladimir Indic <vladimir.indic@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent cf81870 commit 532e2c8

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3760,8 +3760,8 @@ static const uint32_t cwsr_trap_gfx12_hex[] = {
37603760
0xb8faf804, 0x8b7a847a,
37613761
0x91788478, 0x8c787a78,
37623762
0xd7610002, 0x0000fa6c,
3763-
0x807d817d, 0x917aff6d,
3764-
0x80000000, 0xd7610002,
3763+
0x807d817d, 0x8b7aff6d,
3764+
0x0000ffff, 0xd7610002,
37653765
0x0000fa7a, 0x807d817d,
37663766
0xd7610002, 0x0000fa6e,
37673767
0x807d817d, 0xd7610002,
@@ -4848,7 +4848,7 @@ static const uint32_t cwsr_trap_gfx12_1_0_hex[] = {
48484848
0x9178ff78, 0x0001000c,
48494849
0x8c787a78, 0xd7610002,
48504850
0x0000fa6c, 0x807d817d,
4851-
0x917aff6d, 0x80000000,
4851+
0x8b7aff6d, 0x01ffffff,
48524852
0xd7610002, 0x0000fa7a,
48534853
0x807d817d, 0xd7610002,
48544854
0x0000fa6e, 0x807d817d,

drivers/gpu/drm/amd/amdkfd/cwsr_trap_handler_gfx12.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ L_SAVE_HWREG:
547547
s_or_b32 s_save_state_priv, s_save_state_priv, s_save_tmp
548548

549549
write_hwreg_to_v2(s_save_pc_lo)
550-
s_andn2_b32 s_save_tmp, s_save_pc_hi, S_SAVE_PC_HI_FIRST_WAVE_MASK
550+
s_and_b32 s_save_tmp, s_save_pc_hi, ADDRESS_HI32_MASK
551551
write_hwreg_to_v2(s_save_tmp)
552552
write_hwreg_to_v2(s_save_exec_lo)
553553
#if WAVE32_ONLY

0 commit comments

Comments
 (0)