nvdrv: Add GetTpcMasks2 support and improve memory mapping validation
This commit makes two main changes: 1. Adds support for GetTpcMasks2 (ioctl 0x13) in nvhost_ctrl_gpu: - Implements new GetTpcMasks2 method to handle TPC mask queries - Adds IoctlGetTpcMasks structure to store mask parameters - Returns conservative single TPC configuration for compatibility 2. Enhances memory mapping validation in HostMemory: - Adds verification check after memory mapping operations - Improves error handling for direct mapped address enabling - Adds logging for mapping and direct address failures Additional changes: - Updates copyright headers to include citron Emulator Project - Improves error handling and validation in several paths - Adds debug logging for TPC mask operations This improves GPU virtualization support and memory mapping reliability.
This commit is contained in:
parent
e8bbdbce42
commit
ecc32958ec
3 changed files with 49 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#ifdef _WIN32
|
||||
|
|
@ -720,10 +721,18 @@ void HostMemory::Map(size_t virtual_offset, size_t host_offset, size_t length,
|
|||
ASSERT(length % PageAlignment == 0);
|
||||
ASSERT(virtual_offset + length <= virtual_size);
|
||||
ASSERT(host_offset + length <= backing_size);
|
||||
|
||||
if (length == 0 || !virtual_base || !impl) {
|
||||
return;
|
||||
}
|
||||
|
||||
impl->Map(virtual_offset + virtual_base_offset, host_offset, length, perms);
|
||||
|
||||
// Verify mapping was successful
|
||||
if (!impl->IsValidMapping(virtual_offset + virtual_base_offset, length)) {
|
||||
LOG_CRITICAL(Common_Memory, "Failed to verify memory mapping: virtual_offset={:x}, host_offset={:x}, length={:x}",
|
||||
virtual_offset, host_offset, length);
|
||||
}
|
||||
}
|
||||
|
||||
void HostMemory::Unmap(size_t virtual_offset, size_t length, bool separate_heap) {
|
||||
|
|
@ -756,9 +765,18 @@ void HostMemory::ClearBackingRegion(size_t physical_offset, size_t length, u32 f
|
|||
}
|
||||
|
||||
void HostMemory::EnableDirectMappedAddress() {
|
||||
if (impl) {
|
||||
impl->EnableDirectMappedAddress();
|
||||
if (!impl) {
|
||||
LOG_ERROR(Common_Memory, "Implementation not initialized");
|
||||
return;
|
||||
}
|
||||
|
||||
impl->EnableDirectMappedAddress();
|
||||
|
||||
// Only update virtual_size if the direct mapping was successful
|
||||
if (impl->IsDirectMappingEnabled()) {
|
||||
virtual_size += reinterpret_cast<uintptr_t>(virtual_base);
|
||||
} else {
|
||||
LOG_ERROR(Common_Memory, "Failed to enable direct mapped address");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue