SWDEV-277847 - Move event lock_ to the beginning

For addMarker, assume T1 comes in first and enqueues a command C1.
Before T1 grabs the event_::lock_ it gets preempted. At this time,
T2 comes in, enqueues C2 and grabs the lock_ and updates event_. Now T1
wakes up and updates a older command C1 for the event.

Change-Id: Ia423782b23026302c40976385623cfdede32d70b


[ROCm/clr commit: b1657c4159]
Tá an tiomantas seo le fáil i:
Saleel Kudchadker tiomanta 2021-03-19 15:28:08 -07:00
1 tuismitheoir 88c0959afb
tiomantas 0a5d415c1d
1 comhad athraithe
+3 -1
+3 -1
Féach ar an gComhad
@@ -148,6 +148,9 @@ hipError_t Event::streamWait(amd::HostQueue* hostQueue, uint flags) {
}
void Event::addMarker(amd::HostQueue* queue, amd::Command* command, bool record) {
// Keep the lock always at the beginning of this to avoid a race. SWDEV-277847
amd::ScopedLock lock(lock_);
if (command == nullptr) {
command = queue->getLastQueuedCommand(true);
@@ -171,7 +174,6 @@ void Event::addMarker(amd::HostQueue* queue, amd::Command* command, bool record)
command->enqueue();
}
}
amd::ScopedLock lock(lock_);
if (event_ == &command->event()) return;