From 98771a6363298c60225e6580822d679cb986d2c3 Mon Sep 17 00:00:00 2001 From: B3n30 Date: Thu, 1 Mar 2018 14:54:38 +0100 Subject: [PATCH] GSP_GPU: Release the GPU right if the active session closes the gsp_gpu session --- src/core/hle/kernel/hle_ipc.h | 4 ++-- src/core/hle/service/gsp/gsp_gpu.cpp | 17 ++++++++++++++--- src/core/hle/service/gsp/gsp_gpu.h | 8 ++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 90732d35a..22a96f8fc 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -52,14 +52,14 @@ public: * associated ServerSession alive for the duration of the connection. * @param server_session Owning pointer to the ServerSession associated with the connection. */ - void ClientConnected(SharedPtr server_session); + virtual void ClientConnected(SharedPtr server_session); /** * Signals that a client has just disconnected from this HLE handler and releases the * associated ServerSession. * @param server_session ServerSession associated with the connection. */ - void ClientDisconnected(SharedPtr server_session); + virtual void ClientDisconnected(SharedPtr server_session); /// Empty placeholder structure for services with no per-session data. The session data classes /// in each service must inherit from this. diff --git a/src/core/hle/service/gsp/gsp_gpu.cpp b/src/core/hle/service/gsp/gsp_gpu.cpp index 3a919e87e..19d0e439f 100644 --- a/src/core/hle/service/gsp/gsp_gpu.cpp +++ b/src/core/hle/service/gsp/gsp_gpu.cpp @@ -86,6 +86,13 @@ static inline InterruptRelayQueue* GetInterruptRelayQueue( return reinterpret_cast(ptr); } +void GSP_GPU::ClientDisconnected(Kernel::SharedPtr server_session) { + SessionData* session_data = GetSessionData(server_session); + if (active_thread_id == session_data->thread_id) + ReleaseRight(session_data); + SessionRequestHandler::ClientDisconnected(server_session); +} + /** * Writes a single GSP GPU hardware registers with a single u32 value * (For internal use.) @@ -678,13 +685,17 @@ void GSP_GPU::AcquireRight(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); } +void GSP_GPU::ReleaseRight(SessionData* session_data) { + ASSERT_MSG(active_thread_id == session_data->thread_id, + "Wrong thread tried to release GPU right"); + active_thread_id = -1; +} + void GSP_GPU::ReleaseRight(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x17, 0, 0); SessionData* session_data = GetSessionData(ctx.Session()); - ASSERT_MSG(active_thread_id == session_data->thread_id, - "Wrong thread tried to release GPU right"); - active_thread_id = -1; + ReleaseRight(session_data); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(RESULT_SUCCESS); diff --git a/src/core/hle/service/gsp/gsp_gpu.h b/src/core/hle/service/gsp/gsp_gpu.h index 214d96c0e..94dddfa6a 100644 --- a/src/core/hle/service/gsp/gsp_gpu.h +++ b/src/core/hle/service/gsp/gsp_gpu.h @@ -196,6 +196,8 @@ public: GSP_GPU(); ~GSP_GPU() = default; + void ClientDisconnected(Kernel::SharedPtr server_session) override; + /** * Signals that the specified interrupt type has occurred to userland code * @param interrupt_id ID of interrupt that is being signalled @@ -334,6 +336,12 @@ private: */ void ReleaseRight(Kernel::HLERequestContext& ctx); + /** + * Releases rights to the GPU. + * Will fail if the session_data doesn't have the GPU right + */ + void ReleaseRight(SessionData* session_data); + /** * GSP_GPU::ImportDisplayCaptureInfo service function *