diff options
| author | 2021-11-01 15:02:47 +0100 | |
|---|---|---|
| committer | 2022-10-06 21:00:51 +0200 | |
| commit | d30b885d713fa2b9393aeb3c515f4d881bf838f2 (patch) | |
| tree | 4445e1621b403fd6603e9773841107ba9c10822e | |
| parent | NvHost: Remake Ctrl Implementation. (diff) | |
| download | yuzu-d30b885d713fa2b9393aeb3c515f4d881bf838f2.tar.gz yuzu-d30b885d713fa2b9393aeb3c515f4d881bf838f2.tar.xz yuzu-d30b885d713fa2b9393aeb3c515f4d881bf838f2.zip | |
NVDRV: Implement QueryEvent.
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvdevice.h | 8 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | 23 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp | 20 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h | 14 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp | 26 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_gpu.h | 13 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv.cpp | 46 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv.h | 6 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/nvdrv_interface.cpp | 15 |
10 files changed, 133 insertions, 40 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvdevice.h b/src/core/hle/service/nvdrv/devices/nvdevice.h index 696e8121e..204b0e757 100644 --- a/src/core/hle/service/nvdrv/devices/nvdevice.h +++ b/src/core/hle/service/nvdrv/devices/nvdevice.h | |||
| @@ -11,6 +11,10 @@ namespace Core { | |||
| 11 | class System; | 11 | class System; |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | namespace Kernel { | ||
| 15 | class KEvent; | ||
| 16 | } | ||
| 17 | |||
| 14 | namespace Service::Nvidia::Devices { | 18 | namespace Service::Nvidia::Devices { |
| 15 | 19 | ||
| 16 | /// Represents an abstract nvidia device node. It is to be subclassed by concrete device nodes to | 20 | /// Represents an abstract nvidia device node. It is to be subclassed by concrete device nodes to |
| @@ -64,6 +68,10 @@ public: | |||
| 64 | */ | 68 | */ |
| 65 | virtual void OnClose(DeviceFD fd) = 0; | 69 | virtual void OnClose(DeviceFD fd) = 0; |
| 66 | 70 | ||
| 71 | virtual Kernel::KEvent* QueryEvent(u32 event_id) { | ||
| 72 | return nullptr; | ||
| 73 | } | ||
| 74 | |||
| 67 | protected: | 75 | protected: |
| 68 | Core::System& system; | 76 | Core::System& system; |
| 69 | }; | 77 | }; |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index f2b015c8f..9b393521a 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp | |||
| @@ -255,4 +255,27 @@ NvResult nvhost_ctrl::IocCtrlClearEventWait(const std::vector<u8>& input, std::v | |||
| 255 | return NvResult::Success; | 255 | return NvResult::Success; |
| 256 | } | 256 | } |
| 257 | 257 | ||
| 258 | Kernel::KEvent* nvhost_ctrl::QueryEvent(u32 event_id) { | ||
| 259 | const auto event = SyncpointEventValue{.raw = event_id}; | ||
| 260 | |||
| 261 | const bool allocated = event.event_allocated.Value() != 0; | ||
| 262 | const u32 slot{allocated ? event.partial_slot.Value() : static_cast<u32>(event.slot)}; | ||
| 263 | if (slot >= MaxNvEvents) { | ||
| 264 | ASSERT(false); | ||
| 265 | return nullptr; | ||
| 266 | } | ||
| 267 | |||
| 268 | const u32 syncpoint_id{allocated ? event.syncpoint_id_for_allocation.Value() | ||
| 269 | : event.syncpoint_id.Value()}; | ||
| 270 | |||
| 271 | auto lock = events_interface.Lock(); | ||
| 272 | |||
| 273 | if (events_interface.registered[slot] && | ||
| 274 | events_interface.assigned_syncpt[slot] == syncpoint_id) { | ||
| 275 | ASSERT(events_interface.events[slot]); | ||
| 276 | return events_interface.events[slot]; | ||
| 277 | } | ||
| 278 | return nullptr; | ||
| 279 | } | ||
| 280 | |||
| 258 | } // namespace Service::Nvidia::Devices | 281 | } // namespace Service::Nvidia::Devices |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h index 0471c09b2..d548a7827 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h | |||
| @@ -28,6 +28,8 @@ public: | |||
| 28 | void OnOpen(DeviceFD fd) override; | 28 | void OnOpen(DeviceFD fd) override; |
| 29 | void OnClose(DeviceFD fd) override; | 29 | void OnClose(DeviceFD fd) override; |
| 30 | 30 | ||
| 31 | Kernel::KEvent* QueryEvent(u32 event_id) override; | ||
| 32 | |||
| 31 | union SyncpointEventValue { | 33 | union SyncpointEventValue { |
| 32 | u32 raw; | 34 | u32 raw; |
| 33 | 35 | ||
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 2b3b7efea..e353408eb 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp | |||
| @@ -7,10 +7,15 @@ | |||
| 7 | #include "core/core.h" | 7 | #include "core/core.h" |
| 8 | #include "core/core_timing.h" | 8 | #include "core/core_timing.h" |
| 9 | #include "core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h" | 9 | #include "core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h" |
| 10 | #include "core/hle/service/nvdrv/nvdrv.h" | ||
| 10 | 11 | ||
| 11 | namespace Service::Nvidia::Devices { | 12 | namespace Service::Nvidia::Devices { |
| 12 | 13 | ||
| 13 | nvhost_ctrl_gpu::nvhost_ctrl_gpu(Core::System& system_) : nvdevice{system_} {} | 14 | nvhost_ctrl_gpu::nvhost_ctrl_gpu(Core::System& system_, EventInterface& events_interface_) |
| 15 | : nvdevice{system_}, events_interface{events_interface_} { | ||
| 16 | error_notifier_event = events_interface.CreateNonCtrlEvent("CtrlGpuErrorNotifier"); | ||
| 17 | unknown_event = events_interface.CreateNonCtrlEvent("CtrlGpuUknownEvent"); | ||
| 18 | } | ||
| 14 | nvhost_ctrl_gpu::~nvhost_ctrl_gpu() = default; | 19 | nvhost_ctrl_gpu::~nvhost_ctrl_gpu() = default; |
| 15 | 20 | ||
| 16 | NvResult nvhost_ctrl_gpu::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, | 21 | NvResult nvhost_ctrl_gpu::Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, |
| @@ -286,4 +291,17 @@ NvResult nvhost_ctrl_gpu::GetGpuTime(const std::vector<u8>& input, std::vector<u | |||
| 286 | return NvResult::Success; | 291 | return NvResult::Success; |
| 287 | } | 292 | } |
| 288 | 293 | ||
| 294 | Kernel::KEvent* nvhost_ctrl_gpu::QueryEvent(u32 event_id) { | ||
| 295 | switch (event_id) { | ||
| 296 | case 1: | ||
| 297 | return error_notifier_event; | ||
| 298 | case 2: | ||
| 299 | return unknown_event; | ||
| 300 | default: { | ||
| 301 | LOG_CRITICAL(Service_NVDRV, "Unknown Ctrl GPU Event {}", event_id); | ||
| 302 | } | ||
| 303 | } | ||
| 304 | return nullptr; | ||
| 305 | } | ||
| 306 | |||
| 289 | } // namespace Service::Nvidia::Devices | 307 | } // namespace Service::Nvidia::Devices |
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 97e9a90cb..1e8f254e2 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h | |||
| @@ -10,11 +10,15 @@ | |||
| 10 | #include "common/swap.h" | 10 | #include "common/swap.h" |
| 11 | #include "core/hle/service/nvdrv/devices/nvdevice.h" | 11 | #include "core/hle/service/nvdrv/devices/nvdevice.h" |
| 12 | 12 | ||
| 13 | namespace Service::Nvidia { | ||
| 14 | class EventInterface; | ||
| 15 | } | ||
| 16 | |||
| 13 | namespace Service::Nvidia::Devices { | 17 | namespace Service::Nvidia::Devices { |
| 14 | 18 | ||
| 15 | class nvhost_ctrl_gpu final : public nvdevice { | 19 | class nvhost_ctrl_gpu final : public nvdevice { |
| 16 | public: | 20 | public: |
| 17 | explicit nvhost_ctrl_gpu(Core::System& system_); | 21 | explicit nvhost_ctrl_gpu(Core::System& system_, EventInterface& events_interface_); |
| 18 | ~nvhost_ctrl_gpu() override; | 22 | ~nvhost_ctrl_gpu() override; |
| 19 | 23 | ||
| 20 | NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, | 24 | NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, |
| @@ -27,6 +31,8 @@ public: | |||
| 27 | void OnOpen(DeviceFD fd) override; | 31 | void OnOpen(DeviceFD fd) override; |
| 28 | void OnClose(DeviceFD fd) override; | 32 | void OnClose(DeviceFD fd) override; |
| 29 | 33 | ||
| 34 | Kernel::KEvent* QueryEvent(u32 event_id) override; | ||
| 35 | |||
| 30 | private: | 36 | private: |
| 31 | struct IoctlGpuCharacteristics { | 37 | struct IoctlGpuCharacteristics { |
| 32 | u32_le arch; // 0x120 (NVGPU_GPU_ARCH_GM200) | 38 | u32_le arch; // 0x120 (NVGPU_GPU_ARCH_GM200) |
| @@ -160,6 +166,12 @@ private: | |||
| 160 | NvResult ZBCQueryTable(const std::vector<u8>& input, std::vector<u8>& output); | 166 | NvResult ZBCQueryTable(const std::vector<u8>& input, std::vector<u8>& output); |
| 161 | NvResult FlushL2(const std::vector<u8>& input, std::vector<u8>& output); | 167 | NvResult FlushL2(const std::vector<u8>& input, std::vector<u8>& output); |
| 162 | NvResult GetGpuTime(const std::vector<u8>& input, std::vector<u8>& output); | 168 | NvResult GetGpuTime(const std::vector<u8>& input, std::vector<u8>& output); |
| 169 | |||
| 170 | EventInterface& events_interface; | ||
| 171 | |||
| 172 | // Events | ||
| 173 | Kernel::KEvent* error_notifier_event; | ||
| 174 | Kernel::KEvent* unknown_event; | ||
| 163 | }; | 175 | }; |
| 164 | 176 | ||
| 165 | } // namespace Service::Nvidia::Devices | 177 | } // namespace Service::Nvidia::Devices |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp index b98e63011..e87fa5992 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/core.h" | 7 | #include "core/core.h" |
| 8 | #include "core/hle/service/nvdrv/devices/nvhost_gpu.h" | 8 | #include "core/hle/service/nvdrv/devices/nvhost_gpu.h" |
| 9 | #include "core/hle/service/nvdrv/nvdrv.h" | ||
| 9 | #include "core/hle/service/nvdrv/syncpoint_manager.h" | 10 | #include "core/hle/service/nvdrv/syncpoint_manager.h" |
| 10 | #include "core/memory.h" | 11 | #include "core/memory.h" |
| 11 | #include "video_core/gpu.h" | 12 | #include "video_core/gpu.h" |
| @@ -21,10 +22,16 @@ Tegra::CommandHeader BuildFenceAction(Tegra::GPU::FenceOperation op, u32 syncpoi | |||
| 21 | } // namespace | 22 | } // namespace |
| 22 | 23 | ||
| 23 | nvhost_gpu::nvhost_gpu(Core::System& system_, std::shared_ptr<nvmap> nvmap_dev_, | 24 | nvhost_gpu::nvhost_gpu(Core::System& system_, std::shared_ptr<nvmap> nvmap_dev_, |
| 24 | SyncpointManager& syncpoint_manager_) | 25 | EventInterface& events_interface_, SyncpointManager& syncpoint_manager_) |
| 25 | : nvdevice{system_}, nvmap_dev{std::move(nvmap_dev_)}, syncpoint_manager{syncpoint_manager_} { | 26 | : nvdevice{system_}, nvmap_dev{std::move(nvmap_dev_)}, events_interface{events_interface_}, |
| 27 | syncpoint_manager{syncpoint_manager_} { | ||
| 26 | channel_fence.id = syncpoint_manager_.AllocateSyncpoint(); | 28 | channel_fence.id = syncpoint_manager_.AllocateSyncpoint(); |
| 27 | channel_fence.value = system_.GPU().GetSyncpointValue(channel_fence.id); | 29 | channel_fence.value = system_.GPU().GetSyncpointValue(channel_fence.id); |
| 30 | sm_exception_breakpoint_int_report_event = | ||
| 31 | events_interface.CreateNonCtrlEvent("GpuChannelSMExceptionBreakpointInt"); | ||
| 32 | sm_exception_breakpoint_pause_report_event = | ||
| 33 | events_interface.CreateNonCtrlEvent("GpuChannelSMExceptionBreakpointPause"); | ||
| 34 | error_notifier_event = events_interface.CreateNonCtrlEvent("GpuChannelErrorNotifier"); | ||
| 28 | } | 35 | } |
| 29 | 36 | ||
| 30 | nvhost_gpu::~nvhost_gpu() = default; | 37 | nvhost_gpu::~nvhost_gpu() = default; |
| @@ -328,4 +335,19 @@ NvResult nvhost_gpu::ChannelSetTimeslice(const std::vector<u8>& input, std::vect | |||
| 328 | return NvResult::Success; | 335 | return NvResult::Success; |
| 329 | } | 336 | } |
| 330 | 337 | ||
| 338 | Kernel::KEvent* nvhost_gpu::QueryEvent(u32 event_id) { | ||
| 339 | switch (event_id) { | ||
| 340 | case 1: | ||
| 341 | return sm_exception_breakpoint_int_report_event; | ||
| 342 | case 2: | ||
| 343 | return sm_exception_breakpoint_pause_report_event; | ||
| 344 | case 3: | ||
| 345 | return error_notifier_event; | ||
| 346 | default: { | ||
| 347 | LOG_CRITICAL(Service_NVDRV, "Unknown Ctrl GPU Event {}", event_id); | ||
| 348 | } | ||
| 349 | } | ||
| 350 | return nullptr; | ||
| 351 | } | ||
| 352 | |||
| 331 | } // namespace Service::Nvidia::Devices | 353 | } // namespace Service::Nvidia::Devices |
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h index 8a9f7775a..eb4936df0 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h | |||
| @@ -15,7 +15,8 @@ | |||
| 15 | 15 | ||
| 16 | namespace Service::Nvidia { | 16 | namespace Service::Nvidia { |
| 17 | class SyncpointManager; | 17 | class SyncpointManager; |
| 18 | } | 18 | class EventInterface; |
| 19 | } // namespace Service::Nvidia | ||
| 19 | 20 | ||
| 20 | namespace Service::Nvidia::Devices { | 21 | namespace Service::Nvidia::Devices { |
| 21 | 22 | ||
| @@ -23,7 +24,7 @@ class nvmap; | |||
| 23 | class nvhost_gpu final : public nvdevice { | 24 | class nvhost_gpu final : public nvdevice { |
| 24 | public: | 25 | public: |
| 25 | explicit nvhost_gpu(Core::System& system_, std::shared_ptr<nvmap> nvmap_dev_, | 26 | explicit nvhost_gpu(Core::System& system_, std::shared_ptr<nvmap> nvmap_dev_, |
| 26 | SyncpointManager& syncpoint_manager_); | 27 | EventInterface& events_interface_, SyncpointManager& syncpoint_manager_); |
| 27 | ~nvhost_gpu() override; | 28 | ~nvhost_gpu() override; |
| 28 | 29 | ||
| 29 | NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, | 30 | NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector<u8>& input, |
| @@ -36,6 +37,8 @@ public: | |||
| 36 | void OnOpen(DeviceFD fd) override; | 37 | void OnOpen(DeviceFD fd) override; |
| 37 | void OnClose(DeviceFD fd) override; | 38 | void OnClose(DeviceFD fd) override; |
| 38 | 39 | ||
| 40 | Kernel::KEvent* QueryEvent(u32 event_id) override; | ||
| 41 | |||
| 39 | private: | 42 | private: |
| 40 | enum class CtxObjects : u32_le { | 43 | enum class CtxObjects : u32_le { |
| 41 | Ctx2D = 0x902D, | 44 | Ctx2D = 0x902D, |
| @@ -192,8 +195,14 @@ private: | |||
| 192 | NvResult ChannelSetTimeslice(const std::vector<u8>& input, std::vector<u8>& output); | 195 | NvResult ChannelSetTimeslice(const std::vector<u8>& input, std::vector<u8>& output); |
| 193 | 196 | ||
| 194 | std::shared_ptr<nvmap> nvmap_dev; | 197 | std::shared_ptr<nvmap> nvmap_dev; |
| 198 | EventInterface& events_interface; | ||
| 195 | SyncpointManager& syncpoint_manager; | 199 | SyncpointManager& syncpoint_manager; |
| 196 | NvFence channel_fence; | 200 | NvFence channel_fence; |
| 201 | |||
| 202 | // Events | ||
| 203 | Kernel::KEvent* sm_exception_breakpoint_int_report_event; | ||
| 204 | Kernel::KEvent* sm_exception_breakpoint_pause_report_event; | ||
| 205 | Kernel::KEvent* error_notifier_event; | ||
| 197 | }; | 206 | }; |
| 198 | 207 | ||
| 199 | } // namespace Service::Nvidia::Devices | 208 | } // namespace Service::Nvidia::Devices |
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index fa259abed..7c0f89c12 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp | |||
| @@ -96,6 +96,12 @@ u32 EventInterface::FindFreeEvent(u32 syncpoint_id) { | |||
| 96 | return 0; | 96 | return 0; |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | Kernel::KEvent* EventInterface::CreateNonCtrlEvent(std::string name) { | ||
| 100 | Kernel::KEvent* new_event = module.service_context.CreateEvent(std::move(name)); | ||
| 101 | basic_events.push_back(new_event); | ||
| 102 | return new_event; | ||
| 103 | } | ||
| 104 | |||
| 99 | void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger, | 105 | void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger, |
| 100 | Core::System& system) { | 106 | Core::System& system) { |
| 101 | auto module_ = std::make_shared<Module>(system); | 107 | auto module_ = std::make_shared<Module>(system); |
| @@ -119,9 +125,10 @@ Module::Module(Core::System& system) | |||
| 119 | } | 125 | } |
| 120 | auto nvmap_dev = std::make_shared<Devices::nvmap>(system); | 126 | auto nvmap_dev = std::make_shared<Devices::nvmap>(system); |
| 121 | devices["/dev/nvhost-as-gpu"] = std::make_shared<Devices::nvhost_as_gpu>(system, nvmap_dev); | 127 | devices["/dev/nvhost-as-gpu"] = std::make_shared<Devices::nvhost_as_gpu>(system, nvmap_dev); |
| 122 | devices["/dev/nvhost-gpu"] = | 128 | devices["/dev/nvhost-gpu"] = std::make_shared<Devices::nvhost_gpu>( |
| 123 | std::make_shared<Devices::nvhost_gpu>(system, nvmap_dev, syncpoint_manager); | 129 | system, nvmap_dev, events_interface, syncpoint_manager); |
| 124 | devices["/dev/nvhost-ctrl-gpu"] = std::make_shared<Devices::nvhost_ctrl_gpu>(system); | 130 | devices["/dev/nvhost-ctrl-gpu"] = |
| 131 | std::make_shared<Devices::nvhost_ctrl_gpu>(system, events_interface); | ||
| 125 | devices["/dev/nvmap"] = nvmap_dev; | 132 | devices["/dev/nvmap"] = nvmap_dev; |
| 126 | devices["/dev/nvdisp_disp0"] = std::make_shared<Devices::nvdisp_disp0>(system, nvmap_dev); | 133 | devices["/dev/nvdisp_disp0"] = std::make_shared<Devices::nvdisp_disp0>(system, nvmap_dev); |
| 127 | devices["/dev/nvhost-ctrl"] = | 134 | devices["/dev/nvhost-ctrl"] = |
| @@ -255,31 +262,24 @@ void Module::SignalSyncpt(const u32 syncpoint_id, const u32 value) { | |||
| 255 | } | 262 | } |
| 256 | } | 263 | } |
| 257 | 264 | ||
| 258 | Kernel::KEvent* Module::GetEvent(u32 event_id) { | 265 | NvResult Module::QueryEvent(DeviceFD fd, u32 event_id, Kernel::KEvent*& event) { |
| 259 | const auto event = Devices::nvhost_ctrl::SyncpointEventValue{.raw = event_id}; | 266 | if (fd < 0) { |
| 260 | 267 | LOG_ERROR(Service_NVDRV, "Invalid DeviceFD={}!", fd); | |
| 261 | const bool allocated = event.event_allocated.Value() != 0; | 268 | return NvResult::InvalidState; |
| 262 | const u32 slot{allocated ? event.partial_slot.Value() : static_cast<u32>(event.slot)}; | ||
| 263 | if (slot >= MaxNvEvents) { | ||
| 264 | ASSERT(false); | ||
| 265 | return nullptr; | ||
| 266 | } | 269 | } |
| 267 | 270 | ||
| 268 | const u32 syncpoint_id{allocated ? event.syncpoint_id_for_allocation.Value() | 271 | const auto itr = open_files.find(fd); |
| 269 | : event.syncpoint_id.Value()}; | ||
| 270 | 272 | ||
| 271 | auto lock = events_interface.Lock(); | 273 | if (itr == open_files.end()) { |
| 274 | LOG_ERROR(Service_NVDRV, "Could not find DeviceFD={}!", fd); | ||
| 275 | return NvResult::NotImplemented; | ||
| 276 | } | ||
| 272 | 277 | ||
| 273 | if (events_interface.registered[slot] && | 278 | event = itr->second->QueryEvent(event_id); |
| 274 | events_interface.assigned_syncpt[slot] == syncpoint_id) { | 279 | if (!event) { |
| 275 | ASSERT(events_interface.events[slot]); | 280 | return NvResult::BadParameter; |
| 276 | return events_interface.events[slot]; | ||
| 277 | } | 281 | } |
| 278 | // Temporary hack. | 282 | return NvResult::Success; |
| 279 | events_interface.Create(slot); | ||
| 280 | events_interface.assigned_syncpt[slot] = syncpoint_id; | ||
| 281 | ASSERT(false); | ||
| 282 | return events_interface.events[slot]; | ||
| 283 | } | 283 | } |
| 284 | 284 | ||
| 285 | } // namespace Service::Nvidia | 285 | } // namespace Service::Nvidia |
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index 8ce036508..be8813c97 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #pragma once | 6 | #pragma once |
| 7 | 7 | ||
| 8 | #include <memory> | 8 | #include <memory> |
| 9 | #include <string> | ||
| 9 | #include <unordered_map> | 10 | #include <unordered_map> |
| 10 | #include <vector> | 11 | #include <vector> |
| 11 | 12 | ||
| @@ -79,9 +80,12 @@ public: | |||
| 79 | 80 | ||
| 80 | u32 FindFreeEvent(u32 syncpoint_id); | 81 | u32 FindFreeEvent(u32 syncpoint_id); |
| 81 | 82 | ||
| 83 | Kernel::KEvent* CreateNonCtrlEvent(std::string name); | ||
| 84 | |||
| 82 | private: | 85 | private: |
| 83 | std::mutex events_mutex; | 86 | std::mutex events_mutex; |
| 84 | Module& module; | 87 | Module& module; |
| 88 | std::vector<Kernel::KEvent*> basic_events; | ||
| 85 | }; | 89 | }; |
| 86 | 90 | ||
| 87 | class Module final { | 91 | class Module final { |
| @@ -118,7 +122,7 @@ public: | |||
| 118 | 122 | ||
| 119 | void SignalSyncpt(const u32 syncpoint_id, const u32 value); | 123 | void SignalSyncpt(const u32 syncpoint_id, const u32 value); |
| 120 | 124 | ||
| 121 | Kernel::KEvent* GetEvent(u32 event_id); | 125 | NvResult QueryEvent(DeviceFD fd, u32 event_id, Kernel::KEvent*& event); |
| 122 | 126 | ||
| 123 | private: | 127 | private: |
| 124 | friend class EventInterface; | 128 | friend class EventInterface; |
diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.cpp b/src/core/hle/service/nvdrv/nvdrv_interface.cpp index 07883feb2..81ee28f31 100644 --- a/src/core/hle/service/nvdrv/nvdrv_interface.cpp +++ b/src/core/hle/service/nvdrv/nvdrv_interface.cpp | |||
| @@ -173,25 +173,20 @@ void NVDRV::QueryEvent(Kernel::HLERequestContext& ctx) { | |||
| 173 | return; | 173 | return; |
| 174 | } | 174 | } |
| 175 | 175 | ||
| 176 | const auto nv_result = nvdrv->VerifyFD(fd); | 176 | Kernel::KEvent* event = nullptr; |
| 177 | if (nv_result != NvResult::Success) { | 177 | NvResult result = nvdrv->QueryEvent(fd, event_id, event); |
| 178 | LOG_ERROR(Service_NVDRV, "Invalid FD specified DeviceFD={}!", fd); | ||
| 179 | ServiceError(ctx, nv_result); | ||
| 180 | return; | ||
| 181 | } | ||
| 182 | |||
| 183 | auto* event = nvdrv->GetEvent(event_id); | ||
| 184 | 178 | ||
| 185 | if (event) { | 179 | if (result == NvResult::Success) { |
| 186 | IPC::ResponseBuilder rb{ctx, 3, 1}; | 180 | IPC::ResponseBuilder rb{ctx, 3, 1}; |
| 187 | rb.Push(ResultSuccess); | 181 | rb.Push(ResultSuccess); |
| 188 | auto& readable_event = event->GetReadableEvent(); | 182 | auto& readable_event = event->GetReadableEvent(); |
| 189 | rb.PushCopyObjects(readable_event); | 183 | rb.PushCopyObjects(readable_event); |
| 190 | rb.PushEnum(NvResult::Success); | 184 | rb.PushEnum(NvResult::Success); |
| 191 | } else { | 185 | } else { |
| 186 | LOG_ERROR(Service_NVDRV, "Invalid event request!"); | ||
| 192 | IPC::ResponseBuilder rb{ctx, 3}; | 187 | IPC::ResponseBuilder rb{ctx, 3}; |
| 193 | rb.Push(ResultSuccess); | 188 | rb.Push(ResultSuccess); |
| 194 | rb.PushEnum(NvResult::BadParameter); | 189 | rb.PushEnum(result); |
| 195 | } | 190 | } |
| 196 | } | 191 | } |
| 197 | 192 | ||