SWDEV-296301 - Avoid deadlocks in the hostcall path

Change the scope of hostcall buffer access lock during destruction.
Make sure wait() returns the signal value after timeout. That
matches ROCr behaviour for HSA signal wait.

Change-Id: I3df34207e0c2e21972ec8052777e5742bda1dca0


[ROCm/clr commit: 9a9d10a10b]
이 커밋은 다음에 포함됨:
German Andryeyev가 2021-10-04 15:00:44 -04:00를 커밋했습니다
1 부모 1778d99932
커밋 4aed0e4a01
2 파일이 변경됨
+15 -12

검색과 일치하는 파일 없음

+13 -10
파일 보기
@@ -286,10 +286,12 @@ void HostcallListener::consumePackets() {
return;
}
amd::ScopedLock lock{listenerLock};
if (!idle()) {
amd::ScopedLock lock{listenerLock};
for (auto ii : buffers_) {
ii->processPackets(messages_);
for (auto ii : buffers_) {
ii->processPackets(messages_);
}
}
}
@@ -389,14 +391,15 @@ bool enableHostcalls(const amd::Device &dev, void* bfr, uint32_t numPackets) {
}
void disableHostcalls(void* bfr) {
amd::ScopedLock lock(listenerLock);
if (!hostcallListener) {
return;
{
amd::ScopedLock lock(listenerLock);
if (!hostcallListener) {
return;
}
assert(bfr && "expected a hostcall buffer");
auto buffer = reinterpret_cast<HostcallBuffer*>(bfr);
hostcallListener->removeBuffer(buffer);
}
assert(bfr && "expected a hostcall buffer");
auto buffer = reinterpret_cast<HostcallBuffer*>(bfr);
hostcallListener->removeBuffer(buffer);
if (hostcallListener->idle()) {
hostcallListener->terminate();
delete hostcallListener;
+2 -2
파일 보기
@@ -129,7 +129,7 @@ uint64_t Signal::Wait(uint64_t value, device::Signal::Condition c, uint64_t time
float timeoutInSec = timeout / (1000 * 1000);
result = event_.Wait(timeoutInSec);
if (result != Pal::Result::Success) {
if ((result != Pal::Result::Success) && (result != Pal::Result::Timeout)) {
return -1;
}
@@ -142,7 +142,7 @@ uint64_t Signal::Wait(uint64_t value, device::Signal::Condition c, uint64_t time
auto end = amd::Os::timeNanos();
auto duration = 1000 * (end - start); // convert to us
if (duration >= timeout) {
return -1;
return amdSignal_->value;
}
if (!cmp(amdSignal_->value, value)) {