From 3736a0ffeb2f7ba15ef378e8ed1ddd9d6efb9325 Mon Sep 17 00:00:00 2001 From: Laurent Morichetti Date: Thu, 8 Jun 2023 12:38:06 -0700 Subject: [PATCH] Fix a race condition in the trap handler status.priv may be read after returning from the trap handler, which causes sq_interrupt_word_wave.priv to be 0 even though the s_sendmsg instruction was initiated when status.priv was 1. To work around this, added a s_waitcnt lgkmcnt(0) after s_sendmsg to make sure the message is sent before continuing. Signed-off-by: Jay Cornwall Signed-off-by: Laurent Morichetti Change-Id: Ieb75005ca1559ef03d0efac80e966f521e41fcb7 [ROCm/ROCR-Runtime commit: 6a82b0a0380b5bc7c36126dfcaf632a3cda1c820] --- .../runtime/hsa-runtime/core/runtime/trap_handler/trap_handler.s | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/trap_handler/trap_handler.s b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/trap_handler/trap_handler.s index 60070e507b..fdbbfabfe7 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/trap_handler/trap_handler.s +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/trap_handler/trap_handler.s @@ -212,6 +212,7 @@ trap_entry: s_mov_b32 m0, ttmp3 s_nop 0x0 // Manually inserted wait states s_sendmsg sendmsg(MSG_INTERRUPT) + s_waitcnt lgkmcnt(0) // Wait for the message to go out. s_mov_b32 m0, ttmp2 // Parking the wave requires saving the original pc in the preserved ttmps.