Dialog: Follow the firmware's thread priorities in init/shutdown

On a PSP, dialog init and shutdown happen partly at the accessThread
priority and partly at the graphicsThread priority, one phase after the
other. Model that with one helper thread that switches priority per phase,
and let starting it reschedule normally instead of disabling interrupts.

A caller with worse priority than both now sees shutdown complete inside
ShutdownStart, as on hardware. NFL Street 3 (graphics 17, access 19,
caller 111) calls the next InitStart right after ShutdownStart and used to
loop forever on 'A save request is already running' (#19957). The utility
pspautotests, where the caller has better priority, are unchanged.

Also logs the dialog thread priorities at debug level.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-09-23 19:25:24 -06:00
1 parent 24e44cb5dd
commit 20970d5fad
3 files changed
+50 -12

No files matched your search

+11 -2
View File
@@ -27,6 +27,7 @@
#include "Core/CoreTiming.h"
#include "Core/Dialog/PSPDialog.h"
#include "Core/HLE/sceCtrl.h"
#include "Core/HLE/sceKernelThread.h"
#include "Core/HLE/scePower.h"
#include "Core/HLE/sceUtility.h"
#include "Core/MemMapHelpers.h"
@@ -66,6 +67,14 @@ const char *UtilityDialogStatusToString(PSPDialog::DialogStatus status) {
void PSPDialog::InitCommon() {
UpdateCommon();
if (const pspUtilityDialogCommon *common = GetCommonParam()) {
// How these compare with the calling thread decides what the game sees from GetStatus right
// after InitStart/ShutdownStart.
DEBUG_LOG(Log::sceUtility, "%s thread priorities: graphics=%d access=%d font=%d sound=%d (caller %d)",
UtilityDialogTypeToString(DialogType()), common->graphicsThread, common->accessThread,
common->fontThread, common->soundThread, KernelCurThreadPriority());
}
if (GetCommonParam() && GetCommonParam()->language != GetPSPLanguage()) {
WARN_LOG(Log::sceUtility, "Game requested language %d, ignoring and using user language", GetCommonParam()->language);
}
@@ -162,7 +171,7 @@ void PSPDialog::ChangeStatusInit(int delayUs) {
auto params = GetCommonParam();
if (params)
UtilityDialogInitialize(DialogType(), delayUs, params->accessThread);
UtilityDialogInitialize(DialogType(), delayUs, params->accessThread, params->graphicsThread);
else
ChangeStatus(SCE_UTILITY_STATUS_RUNNING, delayUs);
}
@@ -174,7 +183,7 @@ void PSPDialog::ChangeStatusShutdown(int delayUs) {
auto params = GetCommonParam();
if (params && !skipDialogShutdown)
UtilityDialogShutdown(DialogType(), delayUs, params->accessThread);
UtilityDialogShutdown(DialogType(), delayUs, params->accessThread, params->graphicsThread);
else
ChangeStatus(SCE_UTILITY_STATUS_NONE, delayUs);
}