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]
This commit is contained in:
German Andryeyev
2021-09-27 17:56:25 -04:00
والد 1778d99932
کامیت 4aed0e4a01
2فایلهای تغییر یافته به همراه15 افزوده شده و 12 حذف شده
@@ -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;