yuzu-emu
/
yuzu-mainline
Archived
1
0
Fork 0

nvservices: close map handles on session close

This commit is contained in:
Liam 2024-01-19 13:52:19 -05:00
parent 96833cd809
commit a120f8ff4d
3 changed files with 16 additions and 0 deletions

View File

@ -112,6 +112,7 @@ SessionId Container::OpenSession(Kernel::KProcess* process) {
void Container::CloseSession(SessionId session_id) {
std::scoped_lock lk(impl->session_guard);
impl->file.UnmapAllHandles(session_id);
auto& session = impl->sessions[session_id.id];
auto& smmu = impl->host1x.MemoryManager();
if (session.has_preallocated_area) {

View File

@ -326,4 +326,17 @@ std::optional<NvMap::FreeInfo> NvMap::FreeHandle(Handle::Id handle, bool interna
return freeInfo;
}
void NvMap::UnmapAllHandles(NvCore::SessionId session_id) {
auto handles_copy = [&] {
std::scoped_lock lk{handles_lock};
return handles;
}();
for (auto& [id, handle] : handles_copy) {
if (handle->session_id.id == session_id.id) {
FreeHandle(id, false);
}
}
}
} // namespace Service::Nvidia::NvCore

View File

@ -152,6 +152,8 @@ public:
*/
std::optional<FreeInfo> FreeHandle(Handle::Id handle, bool internal_session);
void UnmapAllHandles(NvCore::SessionId session_id);
private:
std::list<std::shared_ptr<Handle>> unmap_queue{};
std::mutex unmap_queue_lock{}; //!< Protects access to `unmap_queue`