diff options
author | Zephyron <zephyron@citron-emu.org> | 2025-02-01 19:48:11 +1000 |
---|---|---|
committer | Zephyron <zephyron@citron-emu.org> | 2025-02-01 19:48:11 +1000 |
commit | ecc32958ec1a14f48d51ac48001b3b7e101d994c (patch) | |
tree | ab2812fa953ce503b8df7aa7d4fdc37f2a77d9a3 /src/core/hle | |
parent | e8bbdbce4250c5f6d7dc48d6895bd653969e5c4a (diff) |
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.
Diffstat (limited to 'src/core/hle')
-rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp | 21 | ||||
-rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h | 8 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp index ed14a3277..bbf77c5ad 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include <cstring> @@ -45,6 +46,8 @@ NvResult nvhost_ctrl_gpu::Ioctl1(DeviceFD fd, Ioctl command, std::span<const u8> return WrapFixed(this, &nvhost_ctrl_gpu::GetActiveSlotMask, input, output); case 0x1c: return WrapFixed(this, &nvhost_ctrl_gpu::GetGpuTime, input, output); + case 0x13: + return WrapFixed(this, &nvhost_ctrl_gpu::GetTpcMasks2, input, output); default: break; } @@ -261,6 +264,24 @@ NvResult nvhost_ctrl_gpu::GetGpuTime(IoctlGetGpuTime& params) { return NvResult::Success; } +NvResult nvhost_ctrl_gpu::GetTpcMasks2(IoctlGetTpcMasks& params) { + LOG_DEBUG(Service_NVDRV, "called, mask_buffer_size={}", params.mask_buf_size); + + // Validate input parameters + if (params.mask_buf_size == 0 || params.mask_buf_size > params.tpc_mask_buf.size()) { + LOG_ERROR(Service_NVDRV, "Invalid mask buffer size {}", params.mask_buf_size); + return NvResult::InvalidValue; + } + + // Set up TPC mask values based on GPU configuration + // Using conservative values for compatibility + params.mask_buf_size = 1; + params.tpc_mask_buf[0] = 0x1; // Enable first TPC only + + LOG_DEBUG(Service_NVDRV, "TPC mask set to 0x{:x}", params.tpc_mask_buf[0]); + return NvResult::Success; +} + Kernel::KEvent* nvhost_ctrl_gpu::QueryEvent(u32 event_id) { switch (event_id) { case 1: diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h index 56e9fe22c..7258c362c 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once @@ -34,6 +35,11 @@ public: Kernel::KEvent* QueryEvent(u32 event_id) override; + struct IoctlGetTpcMasks { + u32 mask_buf_size{}; + std::array<u32, 1> tpc_mask_buf{}; + }; + private: static constexpr std::size_t MaxZBCTableSize = 16; static constexpr std::size_t MaxZBCFormats = 32; @@ -201,6 +207,8 @@ private: NvResult GetTPCMasks1(IoctlGpuGetTpcMasksArgs& params); NvResult GetTPCMasks3(IoctlGpuGetTpcMasksArgs& params, std::span<u32> tpc_mask); + NvResult GetTpcMasks2(IoctlGetTpcMasks& params); + NvResult GetActiveSlotMask(IoctlActiveSlotMask& params); NvResult ZCullGetCtxSize(IoctlZcullGetCtxSize& params); NvResult ZCullGetInfo(IoctlNvgpuGpuZcullGetInfoArgs& params); |