From d86896bed980a784839957dba9123fc1d20582b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 29 Sep 2026 16:04:12 -0600 Subject: [PATCH] Tlspl: Time out at once like other waits Recorded on hardware (pspautotests threads/tls/timeout), a Tlspl allocation follows the same timeout rule as the other waits, including failing at once for 0 and 1us without writing the timeout back, which the shared rule it moved to in the last commits didn't give it yet. Before that it waited the raw timeout, ~30us short. Co-Authored-By: Claude Opus 5.5 (1M context) --- Core/HLE/sceKernelMemory.cpp | 2 ++ test.py | 1 + 2 files changed, 3 insertions(+) diff --git a/Core/HLE/sceKernelMemory.cpp b/Core/HLE/sceKernelMemory.cpp index 84ca204ba1..fc197cd42c 100644 --- a/Core/HLE/sceKernelMemory.cpp +++ b/Core/HLE/sceKernelMemory.cpp @@ -2087,6 +2087,8 @@ int _sceKernelAllocateTlspl(SceUID uid, u32 addrPtr, u32 timeoutPtr) { u32 allocAddress = __KernelAllocateTls(tls); if (allocAddress == 0) { + if (__KernelWaitTimesOutAtOnce(timeoutPtr)) + return hleLogDebug(Log::sceKernel, SCE_KERNEL_ERROR_WAIT_TIMEOUT, "timed out at once"); SceUID threadID = __KernelGetCurThread(); tls->waitingThreads.push_back(threadID); __KernelWaitCurThreadWithTimeout(WAITTYPE_TLSPL, uid, addrPtr, timeoutPtr, false, "allocate tls"); diff --git a/test.py b/test.py index 97534a33fa..988b1a712f 100755 --- a/test.py +++ b/test.py @@ -433,6 +433,7 @@ tests_good = [ "threads/tls/free", "threads/tls/priority", "threads/tls/refer", + "threads/tls/timeout", "threads/vpl/allocate", "threads/vpl/cancel", "threads/vpl/create",