From 78add28aabf0d9835336e5b4369b11308ab362e3 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sat, 8 Jun 2019 15:13:26 -0400 Subject: [PATCH] nvhost_ctrl: Corrections to event handling --- .../hle/service/nvdrv/devices/nvhost_ctrl.cpp | 18 +++++++++++------- src/core/hle/service/nvdrv/nvdrv.cpp | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index 8e28c2fa4..5b1253f6b 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -102,6 +102,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector& input, std::vector& params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000; } params.value |= event_id; + events_interface.events[event_id].writable->Clear(); gpu.RegisterEvent(event_id, params.syncpt_id, params.threshold); std::memcpy(output.data(), ¶ms, sizeof(params)); gpu.Guard(false); @@ -115,26 +116,29 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector& input, std::vector& u32 nvhost_ctrl::IocCtrlEventRegister(const std::vector& input, std::vector& output) { IocCtrlEventRegisterParams params{}; std::memcpy(¶ms, input.data(), sizeof(params)); - if (params.user_event_id >= MaxNvEvents) { + const u32 event_id = params.user_event_id & 0x00FF; + if (event_id >= MaxNvEvents) { return NvResult::BadParameter; } - if (events_interface.registered[params.user_event_id]) { + if (events_interface.registered[event_id]) { return NvResult::BadParameter; } - events_interface.RegisterEvent(params.user_event_id); + events_interface.RegisterEvent(event_id); + events_interface.events[event_id].writable->Signal(); return NvResult::Success; } u32 nvhost_ctrl::IocCtrlEventUnregister(const std::vector& input, std::vector& output) { IocCtrlEventUnregisterParams params{}; std::memcpy(¶ms, input.data(), sizeof(params)); - if (params.user_event_id >= MaxNvEvents) { + const u32 event_id = params.user_event_id & 0x00FF; + if (event_id >= MaxNvEvents) { return NvResult::BadParameter; } - if (!events_interface.registered[params.user_event_id]) { + if (!events_interface.registered[event_id]) { return NvResult::BadParameter; } - events_interface.UnregisterEvent(params.user_event_id); + events_interface.UnregisterEvent(event_id); return NvResult::Success; } @@ -142,7 +146,7 @@ u32 nvhost_ctrl::IocCtrlEventSignal(const std::vector& input, std::vector= MaxNvEvents) { diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index 618bcbc7c..3a716e734 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp @@ -40,7 +40,7 @@ Module::Module() { for (u32 i = 0; i < MaxNvEvents; i++) { std::string event_label = fmt::format("NVDRV::NvEvent_{}", i); events_interface.events[i] = Kernel::WritableEvent::CreateEventPair( - kernel, Kernel::ResetType::Automatic, event_label); + kernel, Kernel::ResetType::Manual, event_label); events_interface.status[i] = EventState::Free; events_interface.registered[i] = false; }