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
Tento commit je obsažen v:
Saleel Kudchadker
2021-03-19 14:47:08 -07:00
rodič d279bd99bb
revize c8b9257c0b
+3 -1
Zobrazit soubor
@@ -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;