SWDEV-467540 - Get lastCommand safely

We must be in protected way to get last command when calling
awaitCompletion() where lastCommand will be released and
possibly destroyed.
This can solve scope lock(notify_lock_) crash in
Event::notifyCmdQueue() with AMD_DIRECT_DISPATCH = true.

Change-Id: I4297166f912a71112f4a8945d993160ba9afdc34


[ROCm/clr commit: 749385155a]
Этот коммит содержится в:
taosang2
2024-06-24 18:29:52 -04:00
коммит произвёл Tao Sang
родитель 3f890c80b5
Коммит 881ffd6650
+13 -4
Просмотреть файл
@@ -60,10 +60,19 @@ bool HostQueue::terminate() {
if (AMD_DIRECT_DISPATCH) {
if (vdev() != nullptr) {
// If the queue still has the last command, then wait and release it
if (lastEnqueueCommand_ != nullptr) {
lastEnqueueCommand_->awaitCompletion();
lastEnqueueCommand_->release();
lastEnqueueCommand_ = nullptr;
// We must be in protected way to get last command when calling
// awaitCompletion() where lastCommand will be released and possibly
// destroyed.
Command* lastCommand = getLastQueuedCommand(true);
if (lastCommand != nullptr) {
lastCommand->awaitCompletion();
// Note that if lastCommand isn't a marker, it may not be lastEnqueueCommand_ now
// after lastCommand->awaitCompletion() is called.
if (lastEnqueueCommand_ != nullptr) {
lastEnqueueCommand_ ->release(); // lastEnqueueCommand_ should be a marker
lastEnqueueCommand_ = nullptr;
}
lastCommand->release();
}
}
thread_.Release();