Skip to content

Commit e68f471

Browse files
lancesixgregkh
authored andcommitted
drm/amdkfd: Ensure consistent barrier state saved in gfx12 trap handler
[ Upstream commit d584198 ] It is possible for some waves in a workgroup to finish their save sequence before the group leader has had time to capture the workgroup barrier state. When this happens, having those waves exit do impact the barrier state. As a consequence, the state captured by the group leader is invalid, and is eventually incorrectly restored. This patch proposes to have all waves in a workgroup wait for each other at the end of their save sequence (just before calling s_endpgm_saved). Signed-off-by: Lancelot SIX <lancelot.six@amd.com> Reviewed-by: Jay Cornwall <jay.cornwall@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org # 6.12.x Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 1d83efc commit e68f471

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4117,7 +4117,8 @@ static const uint32_t cwsr_trap_gfx12_hex[] = {
41174117
0x0000ffff, 0x8bfe7e7e,
41184118
0x8bea6a6a, 0xb97af804,
41194119
0xbe804ec2, 0xbf94fffe,
4120-
0xbe804a6c, 0xbfb10000,
4120+
0xbe804a6c, 0xbe804ec2,
4121+
0xbf94fffe, 0xbfb10000,
41214122
0xbf9f0000, 0xbf9f0000,
41224123
0xbf9f0000, 0xbf9f0000,
41234124
0xbf9f0000, 0x00000000,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,10 @@ L_SKIP_BARRIER_RESTORE:
10491049
s_rfe_b64 s_restore_pc_lo //Return to the main shader program and resume execution
10501050

10511051
L_END_PGM:
1052+
// Make sure that no wave of the workgroup can exit the trap handler
1053+
// before the workgroup barrier state is saved.
1054+
s_barrier_signal -2
1055+
s_barrier_wait -2
10521056
s_endpgm_saved
10531057
end
10541058

0 commit comments

Comments
 (0)