summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2021-10-30 02:32:07 +0200
committerGravatar Fernando Sahmkow2022-10-06 21:00:51 +0200
commit7b7f6f1cb777aef0184169891b42ece902a616ae (patch)
tree8ecb383962c341dcd48cc9ec314fc67659fc000e /src/core
parentMerge pull request #9025 from FernandoS27/slava-ukrayini (diff)
downloadyuzu-7b7f6f1cb777aef0184169891b42ece902a616ae.tar.gz
yuzu-7b7f6f1cb777aef0184169891b42ece902a616ae.tar.xz
yuzu-7b7f6f1cb777aef0184169891b42ece902a616ae.zip
NvHost: Fix some regressions and correct signaling on timeout.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp44
1 files changed, 19 insertions, 25 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
index 527531f29..a3c11ad8a 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
@@ -105,30 +105,32 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector
105 105
106 auto& event = events_interface.events[event_id]; 106 auto& event = events_interface.events[event_id];
107 auto& gpu = system.GPU(); 107 auto& gpu = system.GPU();
108
109 // This is mostly to take into account unimplemented features. As synced
110 // gpu is always synced.
111 if (!gpu.IsAsync()) {
112 event.event->GetWritableEvent().Signal();
113 return NvResult::Success;
114 }
115 const u32 current_syncpoint_value = event.fence.value; 108 const u32 current_syncpoint_value = event.fence.value;
116 const s32 diff = current_syncpoint_value - params.threshold; 109 const s32 diff = current_syncpoint_value - params.threshold;
117 if (diff >= 0) { 110 const u32 target_value = params.value;
118 event.event->GetWritableEvent().Signal();
119 params.value = current_syncpoint_value;
120 std::memcpy(output.data(), &params, sizeof(params));
121 events_interface.failed[event_id] = false;
122 return NvResult::Success;
123 }
124 const u32 target_value = current_syncpoint_value - diff;
125 111
126 if (!is_async) { 112 if (!is_async) {
127 params.value = 0; 113 params.value = 0;
128 } 114 }
129 115
116 const auto check_failing = [&]() {
117 if (events_interface.failed[event_id]) {
118 {
119 auto lk = system.StallProcesses();
120 gpu.WaitFence(params.syncpt_id, target_value);
121 system.UnstallProcesses();
122 }
123 std::memcpy(output.data(), &params, sizeof(params));
124 events_interface.failed[event_id] = false;
125 return true;
126 }
127 return false;
128 };
129
130 if (params.timeout == 0) { 130 if (params.timeout == 0) {
131 std::memcpy(output.data(), &params, sizeof(params)); 131 if (check_failing()) {
132 return NvResult::Success;
133 }
132 return NvResult::Timeout; 134 return NvResult::Timeout;
133 } 135 }
134 136
@@ -147,15 +149,7 @@ NvResult nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector
147 params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000; 149 params.value = ((params.syncpt_id & 0xfff) << 16) | 0x10000000;
148 } 150 }
149 params.value |= event_id; 151 params.value |= event_id;
150 event.event->GetWritableEvent().Clear(); 152 if (check_failing()) {
151 if (events_interface.failed[event_id]) {
152 {
153 auto lk = system.StallProcesses();
154 gpu.WaitFence(params.syncpt_id, target_value);
155 system.UnstallProcesses();
156 }
157 std::memcpy(output.data(), &params, sizeof(params));
158 events_interface.failed[event_id] = false;
159 return NvResult::Success; 153 return NvResult::Success;
160 } 154 }
161 gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value); 155 gpu.RegisterSyncptInterrupt(params.syncpt_id, target_value);