From 6e16a8db1c9711beee9eb5827eeeb854a44edd02 Mon Sep 17 00:00:00 2001 From: Zephyron Date: Sun, 9 Feb 2025 11:43:08 +1000 Subject: [PATCH] service/nvdrv: Implement NVGPU_GPU_IOCTL_NUM_VSMS - Add IoctlNumVsms struct definition - Implement ioctl 0x13 to return number of SM units (2 for Tegra X1) --- .../service/nvdrv/devices/nvhost_ctrl_gpu.cpp | 20 ++++++++++++++++--- .../service/nvdrv/devices/nvhost_ctrl_gpu.h | 8 ++++++-- 2 files changed, 23 insertions(+), 5 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 f03d80955..3cf0b034c 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp @@ -74,9 +74,23 @@ NvResult nvhost_ctrl_gpu::Ioctl3(DeviceFD fd, Ioctl command, std::span case 0x6: return WrapFixedInlOut(this, &nvhost_ctrl_gpu::GetTPCMasks3, input, output, inline_output); - case 0x13: - LOG_DEBUG(Service_NVDRV, "(STUBBED) called."); - return NvResult::NotImplemented; + case 0x13: { + // NVGPU_GPU_IOCTL_NUM_VSMS + struct Parameters { + u32 num_vsms; // Output: number of SM units + u32 reserved; // Output: reserved/padding + }; + static_assert(sizeof(Parameters) == 8, "Parameters is incorrect size"); + + // The Tegra X1 used in Switch has 2 SM units + Parameters params{ + .num_vsms = 2, + .reserved = 0 + }; + + std::memcpy(output.data(), ¶ms, sizeof(Parameters)); + return NvResult::Success; + } default: break; } 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 0bfa47c03..657433aac 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h @@ -200,6 +200,12 @@ private: }; static_assert(sizeof(IoctlGetGpuTime) == 0x10, "IoctlGetGpuTime is incorrect size"); + struct IoctlNumVsms { + u32_le num_vsms; // Output: number of SM units + u32_le reserved; // Output: reserved/padding + }; + static_assert(sizeof(IoctlNumVsms) == 8, "IoctlNumVsms is incorrect size"); + NvResult GetCharacteristics1(IoctlCharacteristics& params); NvResult GetCharacteristics3(IoctlCharacteristics& params, std::span gpu_characteristics); @@ -208,8 +214,6 @@ private: NvResult GetTpcMasks2(IoctlGetTpcMasks& params); NvResult GetTPCMasks3(IoctlGpuGetTpcMasksArgs& params, std::span tpc_mask); - - NvResult GetActiveSlotMask(IoctlActiveSlotMask& params); NvResult ZCullGetCtxSize(IoctlZcullGetCtxSize& params); NvResult ZCullGetInfo(IoctlNvgpuGpuZcullGetInfoArgs& params);