From fbef978b984bc80a6f4159fd143bde1c0c7e34b7 Mon Sep 17 00:00:00 2001 From: Subv Date: Thu, 21 Dec 2017 15:09:03 -0500 Subject: [PATCH] GSP: Return the correct result code if AcquireRight is called multiple times from the same thread. --- src/core/hle/service/gsp/gsp_gpu.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/core/hle/service/gsp/gsp_gpu.cpp b/src/core/hle/service/gsp/gsp_gpu.cpp index fb4343e7bc..11f9f4ae61 100644 --- a/src/core/hle/service/gsp/gsp_gpu.cpp +++ b/src/core/hle/service/gsp/gsp_gpu.cpp @@ -649,17 +649,25 @@ void GSP_GPU::AcquireRight(Kernel::HLERequestContext& ctx) { u32 flag = rp.Pop(); auto process = rp.PopObject(); + SessionData* session_data = GetSessionData(ctx.Session()); + + LOG_WARNING(Service_GSP, "called flag=%08X process=%u thread_id=%u", flag, process->process_id, + session_data->thread_id); + + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + + if (active_thread_id == session_data->thread_id) { + rb.Push(ResultCode(ErrorDescription::AlreadyDone, ErrorModule::GX, ErrorSummary::Success, + ErrorLevel::Success)); + return; + } + // TODO(Subv): This case should put the caller thread to sleep until the right is released. ASSERT_MSG(active_thread_id == -1, "GPU right has already been acquired"); - SessionData* session_data = GetSessionData(ctx.Session()); active_thread_id = session_data->thread_id; - IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(RESULT_SUCCESS); - - LOG_WARNING(Service_GSP, "called flag=%08X process=%u thread_id=%u", flag, process->process_id, - active_thread_id); } void GSP_GPU::ReleaseRight(Kernel::HLERequestContext& ctx) {