Core: Fix get nvmap object random crash
This commit is contained in:
parent
fe24c65153
commit
9982cff98b
12 changed files with 66 additions and 35 deletions
|
@ -207,6 +207,19 @@ void NvMap::UnpinHandle(Handle::Id handle) {
|
|||
}
|
||||
}
|
||||
|
||||
void NvMap::DuplicateHandle(Handle::Id handle) {
|
||||
auto handle_description{GetHandle(handle)};
|
||||
if (!handle_description) {
|
||||
LOG_CRITICAL(Service_NVDRV, "Unregistered handle!");
|
||||
return;
|
||||
}
|
||||
|
||||
auto result = handle_description->Duplicate(false);
|
||||
if (result != NvResult::Success) {
|
||||
LOG_CRITICAL(Service_NVDRV, "Could not duplicate handle!");
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<NvMap::FreeInfo> NvMap::FreeHandle(Handle::Id handle, bool internal_session) {
|
||||
std::weak_ptr<Handle> hWeak{GetHandle(handle)};
|
||||
FreeInfo freeInfo;
|
||||
|
@ -254,7 +267,7 @@ std::optional<NvMap::FreeInfo> NvMap::FreeHandle(Handle::Id handle, bool interna
|
|||
|
||||
// Handle hasn't been freed from memory, set address to 0 to mark that the handle wasn't freed
|
||||
if (!hWeak.expired()) {
|
||||
LOG_ERROR(Service_NVDRV, "nvmap handle: {} wasn't freed as it is still in use", handle);
|
||||
LOG_DEBUG(Service_NVDRV, "nvmap handle: {} wasn't freed as it is still in use", handle);
|
||||
freeInfo.address = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -162,6 +162,11 @@ public:
|
|||
*/
|
||||
void UnpinHandle(Handle::Id handle);
|
||||
|
||||
/**
|
||||
* @brief Tries to duplicate a handle
|
||||
*/
|
||||
void DuplicateHandle(Handle::Id handle);
|
||||
|
||||
/**
|
||||
* @brief Tries to free a handle and remove a single dupe
|
||||
* @note If a handle has no dupes left and has no other users a FreeInfo struct will be returned
|
||||
|
|
|
@ -69,18 +69,6 @@ NvResult nvmap::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& input,
|
|||
void nvmap::OnOpen(DeviceFD fd) {}
|
||||
void nvmap::OnClose(DeviceFD fd) {}
|
||||
|
||||
VAddr nvmap::GetObjectAddress(u32 handle) const {
|
||||
auto obj = file.GetHandle(handle);
|
||||
if (obj) {
|
||||
return obj->address;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::shared_ptr<NvCore::NvMap::Handle> nvmap::GetObject(u32 handle) const {
|
||||
return file.GetHandle(handle);
|
||||
}
|
||||
|
||||
NvResult nvmap::IocCreate(const std::vector<u8>& input, std::vector<u8>& output) {
|
||||
IocCreateParams params;
|
||||
std::memcpy(¶ms, input.data(), sizeof(params));
|
||||
|
|
|
@ -36,11 +36,6 @@ public:
|
|||
void OnOpen(DeviceFD fd) override;
|
||||
void OnClose(DeviceFD fd) override;
|
||||
|
||||
/// Returns the allocated address of an nvmap object given its handle.
|
||||
VAddr GetObjectAddress(u32 handle) const;
|
||||
|
||||
std::shared_ptr<NvCore::NvMap::Handle> GetObject(u32 handle) const;
|
||||
|
||||
enum class HandleParameterType : u32_le {
|
||||
Size = 1,
|
||||
Alignment = 2,
|
||||
|
|
|
@ -96,6 +96,7 @@ public:
|
|||
|
||||
private:
|
||||
friend class EventInterface;
|
||||
friend class Service::NVFlinger::NVFlinger;
|
||||
|
||||
/// Id to use for the next open file descriptor.
|
||||
DeviceFD next_fd = 1;
|
||||
|
@ -111,8 +112,6 @@ private:
|
|||
/// Manages syncpoints on the host
|
||||
NvCore::Container container;
|
||||
|
||||
void CreateEvent(u32 event_id);
|
||||
void FreeEvent(u32 event_id);
|
||||
std::unordered_map<std::string, std::function<FilesContainerType::iterator(DeviceFD)>> builders;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue