GSP_GPU: Release the GPU right if the active session closes the gsp_gpu session

This commit is contained in:
B3n30 2018-03-01 14:54:38 +01:00
parent 941ccaeed6
commit 98771a6363
3 changed files with 24 additions and 5 deletions

View File

@ -52,14 +52,14 @@ public:
* associated ServerSession alive for the duration of the connection. * associated ServerSession alive for the duration of the connection.
* @param server_session Owning pointer to the ServerSession associated with the connection. * @param server_session Owning pointer to the ServerSession associated with the connection.
*/ */
void ClientConnected(SharedPtr<ServerSession> server_session); virtual void ClientConnected(SharedPtr<ServerSession> server_session);
/** /**
* Signals that a client has just disconnected from this HLE handler and releases the * Signals that a client has just disconnected from this HLE handler and releases the
* associated ServerSession. * associated ServerSession.
* @param server_session ServerSession associated with the connection. * @param server_session ServerSession associated with the connection.
*/ */
void ClientDisconnected(SharedPtr<ServerSession> server_session); virtual void ClientDisconnected(SharedPtr<ServerSession> server_session);
/// Empty placeholder structure for services with no per-session data. The session data classes /// Empty placeholder structure for services with no per-session data. The session data classes
/// in each service must inherit from this. /// in each service must inherit from this.

View File

@ -86,6 +86,13 @@ static inline InterruptRelayQueue* GetInterruptRelayQueue(
return reinterpret_cast<InterruptRelayQueue*>(ptr); return reinterpret_cast<InterruptRelayQueue*>(ptr);
} }
void GSP_GPU::ClientDisconnected(Kernel::SharedPtr<Kernel::ServerSession> 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 * Writes a single GSP GPU hardware registers with a single u32 value
* (For internal use.) * (For internal use.)
@ -678,13 +685,17 @@ void GSP_GPU::AcquireRight(Kernel::HLERequestContext& ctx) {
rb.Push(RESULT_SUCCESS); 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) { void GSP_GPU::ReleaseRight(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx, 0x17, 0, 0); IPC::RequestParser rp(ctx, 0x17, 0, 0);
SessionData* session_data = GetSessionData(ctx.Session()); SessionData* session_data = GetSessionData(ctx.Session());
ASSERT_MSG(active_thread_id == session_data->thread_id, ReleaseRight(session_data);
"Wrong thread tried to release GPU right");
active_thread_id = -1;
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);

View File

@ -196,6 +196,8 @@ public:
GSP_GPU(); GSP_GPU();
~GSP_GPU() = default; ~GSP_GPU() = default;
void ClientDisconnected(Kernel::SharedPtr<Kernel::ServerSession> server_session) override;
/** /**
* Signals that the specified interrupt type has occurred to userland code * Signals that the specified interrupt type has occurred to userland code
* @param interrupt_id ID of interrupt that is being signalled * @param interrupt_id ID of interrupt that is being signalled
@ -334,6 +336,12 @@ private:
*/ */
void ReleaseRight(Kernel::HLERequestContext& ctx); 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 * GSP_GPU::ImportDisplayCaptureInfo service function
* *