mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-15 22:54:00 +00:00
Gpu: Mark areas as protected.
This commit is contained in:
parent
a45643cb3b
commit
eef55f493b
3 changed files with 19 additions and 0 deletions
|
@ -60,10 +60,12 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& gpu = Core::System::GetInstance().GPU();
|
auto& gpu = Core::System::GetInstance().GPU();
|
||||||
|
gpu.Guard(true);
|
||||||
u32 current_syncpoint_value = gpu.GetSyncpointValue(params.syncpt_id);
|
u32 current_syncpoint_value = gpu.GetSyncpointValue(params.syncpt_id);
|
||||||
if (current_syncpoint_value >= params.threshold) {
|
if (current_syncpoint_value >= params.threshold) {
|
||||||
params.value = current_syncpoint_value;
|
params.value = current_syncpoint_value;
|
||||||
std::memcpy(output.data(), ¶ms, sizeof(params));
|
std::memcpy(output.data(), ¶ms, sizeof(params));
|
||||||
|
gpu.Guard(false);
|
||||||
return NvResult::Success;
|
return NvResult::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +75,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
|
||||||
|
|
||||||
if (params.timeout == 0) {
|
if (params.timeout == 0) {
|
||||||
std::memcpy(output.data(), ¶ms, sizeof(params));
|
std::memcpy(output.data(), ¶ms, sizeof(params));
|
||||||
|
gpu.Guard(false);
|
||||||
return NvResult::Timeout;
|
return NvResult::Timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,6 +84,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
|
||||||
event_id = params.value & 0x00FF;
|
event_id = params.value & 0x00FF;
|
||||||
if (event_id >= 64) {
|
if (event_id >= 64) {
|
||||||
std::memcpy(output.data(), ¶ms, sizeof(params));
|
std::memcpy(output.data(), ¶ms, sizeof(params));
|
||||||
|
gpu.Guard(false);
|
||||||
return NvResult::BadParameter;
|
return NvResult::BadParameter;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -100,9 +104,11 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
|
||||||
params.value |= event_id;
|
params.value |= event_id;
|
||||||
gpu.RegisterEvent(event_id, params.syncpt_id, params.threshold);
|
gpu.RegisterEvent(event_id, params.syncpt_id, params.threshold);
|
||||||
std::memcpy(output.data(), ¶ms, sizeof(params));
|
std::memcpy(output.data(), ¶ms, sizeof(params));
|
||||||
|
gpu.Guard(false);
|
||||||
return NvResult::Timeout;
|
return NvResult::Timeout;
|
||||||
}
|
}
|
||||||
std::memcpy(output.data(), ¶ms, sizeof(params));
|
std::memcpy(output.data(), ¶ms, sizeof(params));
|
||||||
|
gpu.Guard(false);
|
||||||
return NvResult::BadParameter;
|
return NvResult::BadParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ const DmaPusher& GPU::DmaPusher() const {
|
||||||
|
|
||||||
void GPU::IncrementSyncPoint(const u32 syncpoint_id) {
|
void GPU::IncrementSyncPoint(const u32 syncpoint_id) {
|
||||||
syncpoints[syncpoint_id]++;
|
syncpoints[syncpoint_id]++;
|
||||||
|
sync_guard.lock();
|
||||||
if (!events[syncpoint_id].empty()) {
|
if (!events[syncpoint_id].empty()) {
|
||||||
u32 value = syncpoints[syncpoint_id].load();
|
u32 value = syncpoints[syncpoint_id].load();
|
||||||
auto it = events[syncpoint_id].begin();
|
auto it = events[syncpoint_id].begin();
|
||||||
|
@ -81,6 +82,7 @@ void GPU::IncrementSyncPoint(const u32 syncpoint_id) {
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sync_guard.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GPU::GetSyncpointValue(const u32 syncpoint_id) const {
|
u32 GPU::GetSyncpointValue(const u32 syncpoint_id) const {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "core/hle/service/nvdrv/nvdata.h"
|
#include "core/hle/service/nvdrv/nvdata.h"
|
||||||
#include "core/hle/service/nvflinger/buffer_queue.h"
|
#include "core/hle/service/nvflinger/buffer_queue.h"
|
||||||
#include "video_core/dma_pusher.h"
|
#include "video_core/dma_pusher.h"
|
||||||
|
#include "common/spin_lock.h"
|
||||||
|
|
||||||
using CacheAddr = std::uintptr_t;
|
using CacheAddr = std::uintptr_t;
|
||||||
inline CacheAddr ToCacheAddr(const void* host_ptr) {
|
inline CacheAddr ToCacheAddr(const void* host_ptr) {
|
||||||
|
@ -175,6 +176,14 @@ public:
|
||||||
|
|
||||||
void CancelEvent(const u32 event_id, const u32 syncpoint_id, const u32 value);
|
void CancelEvent(const u32 event_id, const u32 syncpoint_id, const u32 value);
|
||||||
|
|
||||||
|
void Guard(bool guard_set) {
|
||||||
|
if (guard_set) {
|
||||||
|
sync_guard.lock();
|
||||||
|
} else {
|
||||||
|
sync_guard.unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns a const reference to the GPU DMA pusher.
|
/// Returns a const reference to the GPU DMA pusher.
|
||||||
const Tegra::DmaPusher& DmaPusher() const;
|
const Tegra::DmaPusher& DmaPusher() const;
|
||||||
|
|
||||||
|
@ -287,6 +296,8 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
std::array<std::list<Event>, Service::Nvidia::MaxSyncPoints> events;
|
std::array<std::list<Event>, Service::Nvidia::MaxSyncPoints> events;
|
||||||
|
|
||||||
|
Common::SpinLock sync_guard{};
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ASSERT_REG_POSITION(field_name, position) \
|
#define ASSERT_REG_POSITION(field_name, position) \
|
||||||
|
|
Loading…
Reference in a new issue