From 72d07c16a3f41312893019da131d3103c2fac76c Mon Sep 17 00:00:00 2001 From: Jason Macnak Date: Wed, 30 Jul 2025 09:14:41 -0700 Subject: [PATCH] gfxstream: Add gfxstream TLS connection manager reset ... which is still needed to keep the end2end tests happy when one thread creates and destroys instances multiple times (which happens in the MultiThreadedShutdown test). Test: GfxstreamEnd2EndTests Part-of: --- .../GfxStreamConnectionManager.cpp | 15 +++++++++++++++ .../GfxStreamConnectionManager.h | 1 + .../guest/vulkan/gfxstream_vk_device.cpp | 1 + 3 files changed, 17 insertions(+) diff --git a/src/gfxstream/guest/connection-manager/GfxStreamConnectionManager.cpp b/src/gfxstream/guest/connection-manager/GfxStreamConnectionManager.cpp index c341318db30..7b440ccf657 100644 --- a/src/gfxstream/guest/connection-manager/GfxStreamConnectionManager.cpp +++ b/src/gfxstream/guest/connection-manager/GfxStreamConnectionManager.cpp @@ -67,6 +67,21 @@ GfxStreamConnectionManager* GfxStreamConnectionManager::getThreadLocalInstance( return tls; } +void GfxStreamConnectionManager::resetThreadLocalInstance() { + if (unlikely(!gfxstream_connection_manager_tls_key_valid)) { + return; + } + + GfxStreamConnectionManager* tls = + (GfxStreamConnectionManager*)tss_get(gfxstream_connection_manager_tls_key); + if (unlikely(!tls)) { + return; + } + + delete tls; + tss_set(gfxstream_connection_manager_tls_key, nullptr); +} + GfxStreamConnectionManager::GfxStreamConnectionManager(GfxStreamTransportType type, VirtGpuCapset capset) : mTransportType(type), mCapset(capset) {} diff --git a/src/gfxstream/guest/connection-manager/GfxStreamConnectionManager.h b/src/gfxstream/guest/connection-manager/GfxStreamConnectionManager.h index 0ed114eaebe..ae82aacbe99 100644 --- a/src/gfxstream/guest/connection-manager/GfxStreamConnectionManager.h +++ b/src/gfxstream/guest/connection-manager/GfxStreamConnectionManager.h @@ -31,6 +31,7 @@ class GfxStreamConnectionManager { public: static GfxStreamConnectionManager* getThreadLocalInstance(GfxStreamTransportType type, VirtGpuCapset capset); + static void resetThreadLocalInstance(); GfxStreamConnectionManager(GfxStreamTransportType type, VirtGpuCapset capset); ~GfxStreamConnectionManager(); diff --git a/src/gfxstream/guest/vulkan/gfxstream_vk_device.cpp b/src/gfxstream/guest/vulkan/gfxstream_vk_device.cpp index 16b7a829b2d..95824d074c9 100644 --- a/src/gfxstream/guest/vulkan/gfxstream_vk_device.cpp +++ b/src/gfxstream/guest/vulkan/gfxstream_vk_device.cpp @@ -417,6 +417,7 @@ void gfxstream_vk_DestroyInstance(VkInstance _instance, const VkAllocationCallba // To make End2EndTests happy, since now the host connection is statically linked to // libvulkan_ranchu.so [separate HostConnections now]. #if defined(END2END_TESTS) + GfxStreamConnectionManager::resetThreadLocalInstance(); VirtGpuDevice::resetInstance(); gSeqno = 0; #endif