diff options
Diffstat (limited to 'src/core/hle/service/nvdrv/devices')
-rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp | 48 | ||||
-rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | 12 | ||||
-rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp | 8 |
3 files changed, 30 insertions, 38 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp index 3a5bebff3..f2529a12e 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp @@ -155,7 +155,7 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8>& ou const auto object{nvmap_dev->GetObject(params.nvmap_handle)}; if (!object) { - LOG_ERROR(Service_NVDRV, "invalid nvmap_handle={:X}", params.nvmap_handle); + LOG_CRITICAL(Service_NVDRV, "invalid nvmap_handle={:X}", params.nvmap_handle); std::memcpy(output.data(), ¶ms, output.size()); return NvErrCodes::InvalidInput; } @@ -167,24 +167,21 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8>& ou auto& gpu = system.GPU(); u64 page_size{params.page_size}; - if (page_size == 0) { + if (!page_size) { page_size = object->align; } if ((params.flags & AddressSpaceFlags::Remap) != AddressSpaceFlags::None) { - const auto buffer_map = FindBufferMap(static_cast<GPUVAddr>(params.offset)); - - if (buffer_map) { - const auto cpu_addr{ - static_cast<VAddr>(buffer_map->CpuAddr() + static_cast<u64>(params.buffer_offset))}; + if (const auto buffer_map{FindBufferMap(params.offset)}; buffer_map) { + const auto cpu_addr{static_cast<VAddr>(buffer_map->CpuAddr() + params.buffer_offset)}; const auto gpu_addr{static_cast<GPUVAddr>(params.offset + params.buffer_offset)}; if (!gpu.MemoryManager().Map(cpu_addr, gpu_addr, params.mapping_size)) { - LOG_ERROR(Service_NVDRV, - "Remap failed, flags={:X}, nvmap_handle={:X}, buffer_offset={}, " - "mapping_size = {}, offset={}", - params.flags, params.nvmap_handle, params.buffer_offset, - params.mapping_size, params.offset); + LOG_CRITICAL(Service_NVDRV, + "remap failed, flags={:X}, nvmap_handle={:X}, buffer_offset={}, " + "mapping_size = {}, offset={}", + params.flags, params.nvmap_handle, params.buffer_offset, + params.mapping_size, params.offset); std::memcpy(output.data(), ¶ms, output.size()); return NvErrCodes::InvalidInput; @@ -193,7 +190,7 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8>& ou std::memcpy(output.data(), ¶ms, output.size()); return NvErrCodes::Success; } else { - LOG_ERROR(Service_NVDRV, "Address not mapped. offset={}", params.offset); + LOG_CRITICAL(Service_NVDRV, "address not mapped offset={}", params.offset); std::memcpy(output.data(), ¶ms, output.size()); return NvErrCodes::InvalidInput; @@ -203,27 +200,25 @@ u32 nvhost_as_gpu::MapBufferEx(const std::vector<u8>& input, std::vector<u8>& ou // We can only map objects that have already been assigned a CPU address. ASSERT(object->status == nvmap::Object::Status::Allocated); - const auto physical_address{object->addr + static_cast<VAddr>(params.buffer_offset)}; + const auto physical_address{object->addr + params.buffer_offset}; u64 size{params.mapping_size}; - if (size == 0) { + if (!size) { size = object->size; } const bool is_alloc{(params.flags & AddressSpaceFlags::FixedOffset) == AddressSpaceFlags::None}; if (is_alloc) { - params.offset = - static_cast<s64>(gpu.MemoryManager().MapAllocate(physical_address, size, page_size)); + params.offset = gpu.MemoryManager().MapAllocate(physical_address, size, page_size); } else { - params.offset = static_cast<s64>( - gpu.MemoryManager().Map(physical_address, static_cast<GPUVAddr>(params.offset), size)); + params.offset = gpu.MemoryManager().Map(physical_address, params.offset, size); } auto result{NvErrCodes::Success}; - if (params.offset == 0) { - LOG_ERROR(Service_NVDRV, "Failed to map size={}", size); + if (!params.offset) { + LOG_CRITICAL(Service_NVDRV, "failed to map size={}", size); result = NvErrCodes::InvalidInput; } else { - AddBufferMap(static_cast<GPUVAddr>(params.offset), size, physical_address, is_alloc); + AddBufferMap(params.offset, size, physical_address, is_alloc); } std::memcpy(output.data(), ¶ms, output.size()); @@ -234,13 +229,12 @@ u32 nvhost_as_gpu::UnmapBuffer(const std::vector<u8>& input, std::vector<u8>& ou IoctlUnmapBuffer params{}; std::memcpy(¶ms, input.data(), input.size()); - const auto offset = static_cast<GPUVAddr>(params.offset); - LOG_DEBUG(Service_NVDRV, "called, offset=0x{:X}", offset); + LOG_DEBUG(Service_NVDRV, "called, offset=0x{:X}", params.offset); - if (const auto size{RemoveBufferMap(offset)}; size) { - system.GPU().MemoryManager().Unmap(offset, *size); + if (const auto size{RemoveBufferMap(params.offset)}; size) { + system.GPU().MemoryManager().Unmap(params.offset, *size); } else { - LOG_ERROR(Service_NVDRV, "invalid offset=0x{:X}", offset); + LOG_ERROR(Service_NVDRV, "invalid offset=0x{:X}", params.offset); } std::memcpy(output.data(), ¶ms, output.size()); diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index 07d851d0e..b27ee0502 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -63,7 +63,8 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>& return NvResult::BadParameter; } - const u32 event_id = params.value & 0x00FF; + u32 event_id = params.value & 0x00FF; + if (event_id >= MaxNvEvents) { std::memcpy(output.data(), ¶ms, sizeof(params)); return NvResult::BadParameter; @@ -77,17 +78,16 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>& event.writable->Signal(); return NvResult::Success; } - auto lock = gpu.LockSync(); const u32 current_syncpoint_value = gpu.GetSyncpointValue(params.syncpt_id); - const s32 diff = static_cast<s32>(current_syncpoint_value - params.threshold); + const s32 diff = current_syncpoint_value - params.threshold; if (diff >= 0) { event.writable->Signal(); params.value = current_syncpoint_value; std::memcpy(output.data(), ¶ms, sizeof(params)); return NvResult::Success; } - const u32 target_value = current_syncpoint_value - static_cast<u32>(diff); + const u32 target_value = current_syncpoint_value - diff; if (!is_async) { params.value = 0; @@ -98,7 +98,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>& return NvResult::Timeout; } - const EventState status = events_interface.status[event_id]; + EventState status = events_interface.status[event_id]; if (event_id < MaxNvEvents || status == EventState::Free || status == EventState::Registered) { events_interface.SetEventStatus(event_id, EventState::Waiting); events_interface.assigned_syncpt[event_id] = params.syncpt_id; @@ -114,7 +114,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>& if (!is_async && ctrl.fresh_call) { ctrl.must_delay = true; ctrl.timeout = params.timeout; - ctrl.event_id = static_cast<s32>(event_id); + ctrl.event_id = event_id; return NvResult::Timeout; } std::memcpy(output.data(), ¶ms, sizeof(params)); diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp index 5e51b37be..f1966ac0e 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp @@ -127,7 +127,7 @@ u32 nvhost_gpu::AllocGPFIFOEx2(const std::vector<u8>& input, std::vector<u8>& ou params.unk3); auto& gpu = system.GPU(); - params.fence_out.id = static_cast<s32>(assigned_syncpoints); + params.fence_out.id = assigned_syncpoints; params.fence_out.value = gpu.GetSyncpointValue(assigned_syncpoints); assigned_syncpoints++; std::memcpy(output.data(), ¶ms, output.size()); @@ -166,8 +166,7 @@ u32 nvhost_gpu::SubmitGPFIFO(const std::vector<u8>& input, std::vector<u8>& outp UNIMPLEMENTED_IF(params.flags.add_increment.Value() != 0); auto& gpu = system.GPU(); - const u32 current_syncpoint_value = - gpu.GetSyncpointValue(static_cast<u32>(params.fence_out.id)); + u32 current_syncpoint_value = gpu.GetSyncpointValue(params.fence_out.id); if (params.flags.increment.Value()) { params.fence_out.value += current_syncpoint_value; } else { @@ -201,8 +200,7 @@ u32 nvhost_gpu::KickoffPB(const std::vector<u8>& input, std::vector<u8>& output, UNIMPLEMENTED_IF(params.flags.add_increment.Value() != 0); auto& gpu = system.GPU(); - const u32 current_syncpoint_value = - gpu.GetSyncpointValue(static_cast<u32>(params.fence_out.id)); + u32 current_syncpoint_value = gpu.GetSyncpointValue(params.fence_out.id); if (params.flags.increment.Value()) { params.fence_out.value += current_syncpoint_value; } else { |