fix host side miss seqno issue.
host side wait for a seqno that was blocked on the guest side.
Bug: b/243339973
Change-Id: I96d89c3121ef2b17c043b0b0e7c4e0ece3f7a9c5
diff --git a/system/vulkan_enc/ResourceTracker.cpp b/system/vulkan_enc/ResourceTracker.cpp
index c73bbda..b4ac139 100644
--- a/system/vulkan_enc/ResourceTracker.cpp
+++ b/system/vulkan_enc/ResourceTracker.cpp
@@ -5017,15 +5017,17 @@
VkDevice device, VkImage image, const VkAllocationCallbacks *pAllocator) {
#ifdef VK_USE_PLATFORM_ANDROID_KHR
- AutoLock<RecursiveLock> lock(mLock);
+ {
+ AutoLock<RecursiveLock> lock(mLock); // do not guard encoder may cause
+ // deadlock b/243339973
- // Wait for any pending QSRIs to prevent a race between the Gfxstream host
- // potentially processing the below `vkDestroyImage()` from the VK encoder
- // command stream before processing a previously submitted
- // `VIRTIO_GPU_NATIVE_SYNC_VULKAN_QSRI_EXPORT` from the virtio-gpu command
- // stream which relies on the image existing.
- auto imageInfoIt = info_VkImage.find(image);
- if (imageInfoIt != info_VkImage.end()) {
+ // Wait for any pending QSRIs to prevent a race between the Gfxstream host
+ // potentially processing the below `vkDestroyImage()` from the VK encoder
+ // command stream before processing a previously submitted
+ // `VIRTIO_GPU_NATIVE_SYNC_VULKAN_QSRI_EXPORT` from the virtio-gpu command
+ // stream which relies on the image existing.
+ auto imageInfoIt = info_VkImage.find(image);
+ if (imageInfoIt != info_VkImage.end()) {
auto& imageInfo = imageInfoIt->second;
for (int syncFd : imageInfo.pendingQsriSyncFds) {
int syncWaitRet = sync_wait(syncFd, 3000);
@@ -5036,9 +5038,9 @@
close(syncFd);
}
imageInfo.pendingQsriSyncFds.clear();
+ }
}
#endif
-
VkEncoder* enc = (VkEncoder*)context;
enc->vkDestroyImage(device, image, pAllocator, true /* do lock */);
}
@@ -7021,18 +7023,18 @@
return enc->vkQueueSignalReleaseImageANDROID(queue, waitSemaphoreCount, pWaitSemaphores, image, pNativeFenceFd, true /* lock */);
}
- AutoLock<RecursiveLock> lock(mLock);
-
- auto it = info_VkImage.find(image);
- if (it == info_VkImage.end()) {
- if (pNativeFenceFd) *pNativeFenceFd = -1;
- return VK_ERROR_INITIALIZATION_FAILED;
+ {
+ AutoLock<RecursiveLock> lock(mLock);
+ auto it = info_VkImage.find(image);
+ if (it == info_VkImage.end()) {
+ if (pNativeFenceFd) *pNativeFenceFd = -1;
+ return VK_ERROR_INITIALIZATION_FAILED;
+ }
}
- auto& imageInfo = it->second;
-
enc->vkQueueSignalReleaseImageANDROIDAsyncGOOGLE(queue, waitSemaphoreCount, pWaitSemaphores, image, true /* lock */);
+ AutoLock<RecursiveLock> lock(mLock);
if (pNativeFenceFd) {
*pNativeFenceFd =
exportSyncFdForQSRILocked(image);