Merge pull request #4070 from ogniK5377/GetTPCMasks-fix

nvdrv: Fix GetTPCMasks for ioctl3
This commit is contained in:
bunnei 2020-06-14 20:12:45 -04:00 committed by GitHub
commit 55ebf68636
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 21 deletions

View File

@ -25,7 +25,7 @@ u32 nvhost_ctrl_gpu::ioctl(Ioctl command, const std::vector<u8>& input,
case IoctlCommand::IocGetCharacteristicsCommand: case IoctlCommand::IocGetCharacteristicsCommand:
return GetCharacteristics(input, output, output2, version); return GetCharacteristics(input, output, output2, version);
case IoctlCommand::IocGetTPCMasksCommand: case IoctlCommand::IocGetTPCMasksCommand:
return GetTPCMasks(input, output); return GetTPCMasks(input, output, output2, version);
case IoctlCommand::IocGetActiveSlotMaskCommand: case IoctlCommand::IocGetActiveSlotMaskCommand:
return GetActiveSlotMask(input, output); return GetActiveSlotMask(input, output);
case IoctlCommand::IocZcullGetCtxSizeCommand: case IoctlCommand::IocZcullGetCtxSizeCommand:
@ -98,17 +98,22 @@ u32 nvhost_ctrl_gpu::GetCharacteristics(const std::vector<u8>& input, std::vecto
return 0; return 0;
} }
u32 nvhost_ctrl_gpu::GetTPCMasks(const std::vector<u8>& input, std::vector<u8>& output) { u32 nvhost_ctrl_gpu::GetTPCMasks(const std::vector<u8>& input, std::vector<u8>& output,
std::vector<u8>& output2, IoctlVersion version) {
IoctlGpuGetTpcMasksArgs params{}; IoctlGpuGetTpcMasksArgs params{};
std::memcpy(&params, input.data(), input.size()); std::memcpy(&params, input.data(), input.size());
LOG_INFO(Service_NVDRV, "called, mask=0x{:X}, mask_buf_addr=0x{:X}", params.mask_buf_size, LOG_DEBUG(Service_NVDRV, "called, mask_buffer_size=0x{:X}", params.mask_buffer_size);
params.mask_buf_addr); if (params.mask_buffer_size != 0) {
// TODO(ogniK): Confirm value on hardware params.tcp_mask = 3;
if (params.mask_buf_size) }
params.tpc_mask_size = 4 * 1; // 4 * num_gpc
else if (version == IoctlVersion::Version3) {
params.tpc_mask_size = 0; std::memcpy(output.data(), input.data(), output.size());
std::memcpy(output.data(), &params, sizeof(params)); std::memcpy(output2.data(), &params.tcp_mask, output2.size());
} else {
std::memcpy(output.data(), &params, output.size());
}
return 0; return 0;
} }

View File

@ -92,16 +92,11 @@ private:
"IoctlCharacteristics is incorrect size"); "IoctlCharacteristics is incorrect size");
struct IoctlGpuGetTpcMasksArgs { struct IoctlGpuGetTpcMasksArgs {
/// [in] TPC mask buffer size reserved by userspace. Should be at least u32_le mask_buffer_size{};
/// sizeof(__u32) * fls(gpc_mask) to receive TPC mask for each GPC. INSERT_PADDING_WORDS(1);
/// [out] full kernel buffer size u64_le mask_buffer_address{};
u32_le mask_buf_size; u32_le tcp_mask{};
u32_le reserved; INSERT_PADDING_WORDS(1);
/// [in] pointer to TPC mask buffer. It will receive one 32-bit TPC mask per GPC or 0 if
/// GPC is not enabled or not present. This parameter is ignored if mask_buf_size is 0.
u64_le mask_buf_addr;
u64_le tpc_mask_size; // Nintendo add this?
}; };
static_assert(sizeof(IoctlGpuGetTpcMasksArgs) == 24, static_assert(sizeof(IoctlGpuGetTpcMasksArgs) == 24,
"IoctlGpuGetTpcMasksArgs is incorrect size"); "IoctlGpuGetTpcMasksArgs is incorrect size");
@ -166,7 +161,8 @@ private:
u32 GetCharacteristics(const std::vector<u8>& input, std::vector<u8>& output, u32 GetCharacteristics(const std::vector<u8>& input, std::vector<u8>& output,
std::vector<u8>& output2, IoctlVersion version); std::vector<u8>& output2, IoctlVersion version);
u32 GetTPCMasks(const std::vector<u8>& input, std::vector<u8>& output); u32 GetTPCMasks(const std::vector<u8>& input, std::vector<u8>& output, std::vector<u8>& output2,
IoctlVersion version);
u32 GetActiveSlotMask(const std::vector<u8>& input, std::vector<u8>& output); u32 GetActiveSlotMask(const std::vector<u8>& input, std::vector<u8>& output);
u32 ZCullGetCtxSize(const std::vector<u8>& input, std::vector<u8>& output); u32 ZCullGetCtxSize(const std::vector<u8>& input, std::vector<u8>& output);
u32 ZCullGetInfo(const std::vector<u8>& input, std::vector<u8>& output); u32 ZCullGetInfo(const std::vector<u8>& input, std::vector<u8>& output);