summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp6
-rw-r--r--src/video_core/gpu.cpp2
-rw-r--r--src/video_core/gpu.h11
3 files changed, 19 insertions, 0 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
index 8f47d63e3..8e28c2fa4 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp
@@ -60,10 +60,12 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
60 } 60 }
61 61
62 auto& gpu = Core::System::GetInstance().GPU(); 62 auto& gpu = Core::System::GetInstance().GPU();
63 gpu.Guard(true);
63 u32 current_syncpoint_value = gpu.GetSyncpointValue(params.syncpt_id); 64 u32 current_syncpoint_value = gpu.GetSyncpointValue(params.syncpt_id);
64 if (current_syncpoint_value >= params.threshold) { 65 if (current_syncpoint_value >= params.threshold) {
65 params.value = current_syncpoint_value; 66 params.value = current_syncpoint_value;
66 std::memcpy(output.data(), &params, sizeof(params)); 67 std::memcpy(output.data(), &params, sizeof(params));
68 gpu.Guard(false);
67 return NvResult::Success; 69 return NvResult::Success;
68 } 70 }
69 71
@@ -73,6 +75,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
73 75
74 if (params.timeout == 0) { 76 if (params.timeout == 0) {
75 std::memcpy(output.data(), &params, sizeof(params)); 77 std::memcpy(output.data(), &params, sizeof(params));
78 gpu.Guard(false);
76 return NvResult::Timeout; 79 return NvResult::Timeout;
77 } 80 }
78 81
@@ -81,6 +84,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
81 event_id = params.value & 0x00FF; 84 event_id = params.value & 0x00FF;
82 if (event_id >= 64) { 85 if (event_id >= 64) {
83 std::memcpy(output.data(), &params, sizeof(params)); 86 std::memcpy(output.data(), &params, sizeof(params));
87 gpu.Guard(false);
84 return NvResult::BadParameter; 88 return NvResult::BadParameter;
85 } 89 }
86 } else { 90 } else {
@@ -100,9 +104,11 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
100 params.value |= event_id; 104 params.value |= event_id;
101 gpu.RegisterEvent(event_id, params.syncpt_id, params.threshold); 105 gpu.RegisterEvent(event_id, params.syncpt_id, params.threshold);
102 std::memcpy(output.data(), &params, sizeof(params)); 106 std::memcpy(output.data(), &params, sizeof(params));
107 gpu.Guard(false);
103 return NvResult::Timeout; 108 return NvResult::Timeout;
104 } 109 }
105 std::memcpy(output.data(), &params, sizeof(params)); 110 std::memcpy(output.data(), &params, sizeof(params));
111 gpu.Guard(false);
106 return NvResult::BadParameter; 112 return NvResult::BadParameter;
107} 113}
108 114
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp
index 1fa6770ca..ee976f81f 100644
--- a/src/video_core/gpu.cpp
+++ b/src/video_core/gpu.cpp
@@ -69,6 +69,7 @@ const DmaPusher& GPU::DmaPusher() const {
69 69
70void GPU::IncrementSyncPoint(const u32 syncpoint_id) { 70void GPU::IncrementSyncPoint(const u32 syncpoint_id) {
71 syncpoints[syncpoint_id]++; 71 syncpoints[syncpoint_id]++;
72 sync_guard.lock();
72 if (!events[syncpoint_id].empty()) { 73 if (!events[syncpoint_id].empty()) {
73 u32 value = syncpoints[syncpoint_id].load(); 74 u32 value = syncpoints[syncpoint_id].load();
74 auto it = events[syncpoint_id].begin(); 75 auto it = events[syncpoint_id].begin();
@@ -81,6 +82,7 @@ void GPU::IncrementSyncPoint(const u32 syncpoint_id) {
81 it++; 82 it++;
82 } 83 }
83 } 84 }
85 sync_guard.unlock();
84} 86}
85 87
86u32 GPU::GetSyncpointValue(const u32 syncpoint_id) const { 88u32 GPU::GetSyncpointValue(const u32 syncpoint_id) const {
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index 4805a5fbc..bc63920f2 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -12,6 +12,7 @@
12#include "core/hle/service/nvdrv/nvdata.h" 12#include "core/hle/service/nvdrv/nvdata.h"
13#include "core/hle/service/nvflinger/buffer_queue.h" 13#include "core/hle/service/nvflinger/buffer_queue.h"
14#include "video_core/dma_pusher.h" 14#include "video_core/dma_pusher.h"
15#include "common/spin_lock.h"
15 16
16using CacheAddr = std::uintptr_t; 17using CacheAddr = std::uintptr_t;
17inline CacheAddr ToCacheAddr(const void* host_ptr) { 18inline CacheAddr ToCacheAddr(const void* host_ptr) {
@@ -175,6 +176,14 @@ public:
175 176
176 void CancelEvent(const u32 event_id, const u32 syncpoint_id, const u32 value); 177 void CancelEvent(const u32 event_id, const u32 syncpoint_id, const u32 value);
177 178
179 void Guard(bool guard_set) {
180 if (guard_set) {
181 sync_guard.lock();
182 } else {
183 sync_guard.unlock();
184 }
185 }
186
178 /// Returns a const reference to the GPU DMA pusher. 187 /// Returns a const reference to the GPU DMA pusher.
179 const Tegra::DmaPusher& DmaPusher() const; 188 const Tegra::DmaPusher& DmaPusher() const;
180 189
@@ -287,6 +296,8 @@ private:
287 }; 296 };
288 297
289 std::array<std::list<Event>, Service::Nvidia::MaxSyncPoints> events; 298 std::array<std::list<Event>, Service::Nvidia::MaxSyncPoints> events;
299
300 Common::SpinLock sync_guard{};
290}; 301};
291 302
292#define ASSERT_REG_POSITION(field_name, position) \ 303#define ASSERT_REG_POSITION(field_name, position) \