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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36471>
This commit is contained in:
Jason Macnak
2025-07-30 09:14:41 -07:00
committed by Marge Bot
parent b08a23550f
commit 72d07c16a3
3 changed files with 17 additions and 0 deletions
@@ -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) {}
@@ -31,6 +31,7 @@ class GfxStreamConnectionManager {
public:
static GfxStreamConnectionManager* getThreadLocalInstance(GfxStreamTransportType type,
VirtGpuCapset capset);
static void resetThreadLocalInstance();
GfxStreamConnectionManager(GfxStreamTransportType type, VirtGpuCapset capset);
~GfxStreamConnectionManager();
@@ -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