From babe58eb24a6ca6a1a61473ffb5f16f58aeda3ac Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Fri, 14 Jul 2023 10:43:33 -0400 Subject: [PATCH] Release lock on thread yield during blit ops Thread yield doesn't drop the scoped acquired mutex so drop it around yield to prevent a multithread deadlock. Change-Id: Ie21f3bff89f6f9e4c57e5b3ccf17968f253fa23a [ROCm/ROCR-Runtime commit: 70f0a44910177770a707bab76e3c44221a07b071] --- .../runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp index d86a113e31..88b2708486 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp @@ -829,7 +829,9 @@ hsa_status_t GpuAgent::DmaCopy(void* dst, const void* src, size_t size) { void GpuAgent::SetCopyRequestRefCount(bool set) { ScopedAcquire lock(&blit_lock_); while (pending_copy_stat_check_ref_) { + blit_lock_.Release(); os::YieldThread(); + blit_lock_.Acquire(); } if (!set && pending_copy_req_ref_) pending_copy_req_ref_--; else pending_copy_req_ref_++; @@ -838,7 +840,9 @@ void GpuAgent::SetCopyRequestRefCount(bool set) { void GpuAgent::SetCopyStatusCheckRefCount(bool set) { ScopedAcquire lock(&blit_lock_); while (pending_copy_req_ref_) { + blit_lock_.Release(); os::YieldThread(); + blit_lock_.Acquire(); } if (!set && pending_copy_stat_check_ref_) pending_copy_stat_check_ref_--; else pending_copy_stat_check_ref_++;