wsl/hsakmt: Add ring ptr check before lock

This patch also move the invalid packet check outside the critical section.

Signed-off-by: Shi.Leslie <Yuliang.Shi@amd.com>
Reviewed-by: Shane Xiao <shane.xiao@amd.com>
This commit is contained in:
Shi.Leslie
2024-09-13 10:33:21 +08:00
gecommit door Frank Min
bovenliggende efd0158724
commit 3161be1619
+14 -9
Bestand weergeven
@@ -198,18 +198,23 @@ void ComputeQueue::AqlToPm4Thread(ComputeQueue *queue) {
queue->HandleError(status);
break;
}
sleep = false;
} else {
if (current_position == cq->GetAqlWriteIndex()) {
time = std::chrono::steady_clock::now();
if (time - start_time > kMaxElapsed)
sleep = true;
} else {
start_time = std::chrono::steady_clock::now();
current_position = cq->GetAqlWriteIndex();
sleep = false;
}
}
if ((cq->GetRingWptr()->load() > cq->GetRingRptr()->load()) && !sleep)
continue;
std::unique_lock<std::mutex> lock(queue->thread_cond_lock_);
if (current_position == cq->GetAqlWriteIndex()) {
time = std::chrono::steady_clock::now();
if (time - start_time > kMaxElapsed)
sleep = true;
} else {
start_time = std::chrono::steady_clock::now();
current_position = cq->GetAqlWriteIndex();
sleep = false;
}
// CPU wait for valid packet
if (cq->GetRingWptr()->load() <= cq->GetRingRptr()->load() ||
(sleep && cq->IsInvalidPacket())) {