mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-16 01:20:05 +00:00
GPU: Correct Interrupts to interrupt on syncpt/value instead of event, mirroring hardware
This commit is contained in:
parent
61697864c3
commit
7d1b974bca
@ -8,14 +8,17 @@ namespace Core::Hardware {
|
|||||||
|
|
||||||
InterruptManager::InterruptManager(Core::System& system_in) : system(system_in) {
|
InterruptManager::InterruptManager(Core::System& system_in) : system(system_in) {
|
||||||
gpu_interrupt_event =
|
gpu_interrupt_event =
|
||||||
system.CoreTiming().RegisterEvent("GPUInterrupt", [this](u64 event_index, s64) {
|
system.CoreTiming().RegisterEvent("GPUInterrupt", [this](u64 message, s64) {
|
||||||
auto nvdrv = system.ServiceManager().GetService<Service::Nvidia::NVDRV>("nvdrv");
|
auto nvdrv = system.ServiceManager().GetService<Service::Nvidia::NVDRV>("nvdrv");
|
||||||
nvdrv->SignalGPUInterrupt(static_cast<u32>(event_index));
|
const u32 syncpt = static_cast<u32>(message >> 32);
|
||||||
|
const u32 value = static_cast<u32>(message & 0x00000000FFFFFFFFULL);
|
||||||
|
nvdrv->SignalGPUInterruptSyncpt(syncpt, value);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterruptManager::InterruptGPU(const u32 event_index) {
|
void InterruptManager::GPUInterruptSyncpt(const u32 syncpoint_id, const u32 value) {
|
||||||
system.CoreTiming().ScheduleEvent(10, gpu_interrupt_event, static_cast<u64>(event_index));
|
const u64 msg = (static_cast<u64>(syncpoint_id) << 32ULL) | value;
|
||||||
|
system.CoreTiming().ScheduleEvent(10, gpu_interrupt_event, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Core::Hardware
|
} // namespace Core::Hardware
|
||||||
|
@ -14,7 +14,7 @@ public:
|
|||||||
InterruptManager(Core::System& system);
|
InterruptManager(Core::System& system);
|
||||||
~InterruptManager() = default;
|
~InterruptManager() = default;
|
||||||
|
|
||||||
void InterruptGPU(const u32 event_index);
|
void GPUInterruptSyncpt(const u32 syncpoint_id, const u32 value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
|
@ -109,7 +109,7 @@ u32 nvhost_ctrl::IocCtrlEventWait(const std::vector<u8>& input, std::vector<u8>&
|
|||||||
}
|
}
|
||||||
params.value |= event_id;
|
params.value |= event_id;
|
||||||
events_interface.events[event_id].writable->Clear();
|
events_interface.events[event_id].writable->Clear();
|
||||||
gpu.RegisterEvent(event_id, params.syncpt_id, params.threshold);
|
gpu.RegisterSyncptInterrupt(params.syncpt_id, params.threshold);
|
||||||
std::memcpy(output.data(), ¶ms, sizeof(params));
|
std::memcpy(output.data(), ¶ms, sizeof(params));
|
||||||
gpu.Guard(false);
|
gpu.Guard(false);
|
||||||
return NvResult::Timeout;
|
return NvResult::Timeout;
|
||||||
@ -159,9 +159,6 @@ u32 nvhost_ctrl::IocCtrlEventSignal(const std::vector<u8>& input, std::vector<u8
|
|||||||
return NvResult::BadParameter;
|
return NvResult::BadParameter;
|
||||||
}
|
}
|
||||||
if (events_interface.status[event_id] == EventState::Waiting) {
|
if (events_interface.status[event_id] == EventState::Waiting) {
|
||||||
auto& gpu = system.GPU();
|
|
||||||
gpu.CancelEvent(event_id, events_interface.assigned_syncpt[event_id],
|
|
||||||
events_interface.assigned_value[event_id]);
|
|
||||||
events_interface.LiberateEvent(event_id);
|
events_interface.LiberateEvent(event_id);
|
||||||
}
|
}
|
||||||
return NvResult::Success;
|
return NvResult::Success;
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
namespace Service::Nvidia {
|
namespace Service::Nvidia {
|
||||||
|
|
||||||
void NVDRV::SignalGPUInterrupt(const u32 event_id) {
|
void NVDRV::SignalGPUInterruptSyncpt(const u32 syncpoint_id, const u32 value) {
|
||||||
nvdrv->SignalEvent(event_id);
|
nvdrv->SignalSyncpt(syncpoint_id, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NVDRV::Open(Kernel::HLERequestContext& ctx) {
|
void NVDRV::Open(Kernel::HLERequestContext& ctx) {
|
||||||
|
@ -19,7 +19,7 @@ public:
|
|||||||
NVDRV(std::shared_ptr<Module> nvdrv, const char* name);
|
NVDRV(std::shared_ptr<Module> nvdrv, const char* name);
|
||||||
~NVDRV() override;
|
~NVDRV() override;
|
||||||
|
|
||||||
void SignalGPUInterrupt(const u32 event_id);
|
void SignalGPUInterruptSyncpt(const u32 syncpoint_id, const u32 value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Open(Kernel::HLERequestContext& ctx);
|
void Open(Kernel::HLERequestContext& ctx);
|
||||||
|
@ -89,13 +89,14 @@ ResultCode Module::Close(u32 fd) {
|
|||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::SignalEvent(const u32 event_id) {
|
void Module::SignalSyncpt(const u32 syncpoint_id, const u32 value) {
|
||||||
if (event_id >= 64) {
|
for (u32 i = 0; i < MaxNvEvents; i++) {
|
||||||
LOG_ERROR(Service_NVDRV, "Unexpected Event signalled!");
|
if (events_interface.assigned_syncpt[i] == syncpoint_id &&
|
||||||
return;
|
events_interface.assigned_value[i] == value) {
|
||||||
|
events_interface.LiberateEvent(i);
|
||||||
|
events_interface.events[i].writable->Signal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
events_interface.LiberateEvent(event_id);
|
|
||||||
events_interface.events[event_id].writable->Signal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Kernel::SharedPtr<Kernel::ReadableEvent> Module::GetEvent(const u32 event_id) {
|
Kernel::SharedPtr<Kernel::ReadableEvent> Module::GetEvent(const u32 event_id) {
|
||||||
|
@ -73,6 +73,8 @@ struct EventsInterface {
|
|||||||
void LiberateEvent(const u32 event_id) {
|
void LiberateEvent(const u32 event_id) {
|
||||||
status[event_id] = registered[event_id] ? EventState::Registered : EventState::Free;
|
status[event_id] = registered[event_id] ? EventState::Registered : EventState::Free;
|
||||||
events_mask &= ~(1 << event_id);
|
events_mask &= ~(1 << event_id);
|
||||||
|
assigned_syncpt[event_id] = 0xFFFFFFFF;
|
||||||
|
assigned_value[event_id] = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -97,7 +99,7 @@ public:
|
|||||||
/// Closes a device file descriptor and returns operation success.
|
/// Closes a device file descriptor and returns operation success.
|
||||||
ResultCode Close(u32 fd);
|
ResultCode Close(u32 fd);
|
||||||
|
|
||||||
void SignalEvent(const u32 event_id);
|
void SignalSyncpt(const u32 syncpoint_id, const u32 value);
|
||||||
|
|
||||||
Kernel::SharedPtr<Kernel::ReadableEvent> GetEvent(const u32 event_id);
|
Kernel::SharedPtr<Kernel::ReadableEvent> GetEvent(const u32 event_id);
|
||||||
|
|
||||||
|
@ -70,13 +70,13 @@ 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_mutex.lock();
|
sync_mutex.lock();
|
||||||
if (!events[syncpoint_id].empty()) {
|
if (!syncpt_interrupts[syncpoint_id].empty()) {
|
||||||
u32 value = syncpoints[syncpoint_id].load();
|
u32 value = syncpoints[syncpoint_id].load();
|
||||||
auto it = events[syncpoint_id].begin();
|
auto it = syncpt_interrupts[syncpoint_id].begin();
|
||||||
while (it != events[syncpoint_id].end()) {
|
while (it != syncpt_interrupts[syncpoint_id].end()) {
|
||||||
if (value >= it->value) {
|
if (value >= *it) {
|
||||||
TriggerCpuInterrupt(it->event_id);
|
TriggerCpuInterrupt(syncpoint_id, *it);
|
||||||
it = events[syncpoint_id].erase(it);
|
it = syncpt_interrupts[syncpoint_id].erase(it);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
it++;
|
it++;
|
||||||
@ -89,19 +89,19 @@ u32 GPU::GetSyncpointValue(const u32 syncpoint_id) const {
|
|||||||
return syncpoints[syncpoint_id].load();
|
return syncpoints[syncpoint_id].load();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU::RegisterEvent(const u32 event_id, const u32 syncpoint_id, const u32 value) {
|
void GPU::RegisterSyncptInterrupt(const u32 syncpoint_id, const u32 value) {
|
||||||
for (auto& ev : events[syncpoint_id]) {
|
for (u32 in_value : syncpt_interrupts[syncpoint_id]) {
|
||||||
if (ev.event_id == event_id && ev.value == value)
|
if (in_value == value)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
events[syncpoint_id].emplace_back(event_id, value);
|
syncpt_interrupts[syncpoint_id].emplace_back(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPU::CancelEvent(const u32 event_id, const u32 syncpoint_id, const u32 value) {
|
void GPU::CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value) {
|
||||||
auto it = events[syncpoint_id].begin();
|
auto it = syncpt_interrupts[syncpoint_id].begin();
|
||||||
while (it != events[syncpoint_id].end()) {
|
while (it != syncpt_interrupts[syncpoint_id].end()) {
|
||||||
if (value == it->value) {
|
if (value == *it) {
|
||||||
it = events[syncpoint_id].erase(it);
|
it = syncpt_interrupts[syncpoint_id].erase(it);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
it++;
|
it++;
|
||||||
|
@ -172,9 +172,9 @@ public:
|
|||||||
|
|
||||||
u32 GetSyncpointValue(const u32 syncpoint_id) const;
|
u32 GetSyncpointValue(const u32 syncpoint_id) const;
|
||||||
|
|
||||||
void RegisterEvent(const u32 event_id, const u32 syncpoint_id, const u32 value);
|
void RegisterSyncptInterrupt(const u32 syncpoint_id, const u32 value);
|
||||||
|
|
||||||
void CancelEvent(const u32 event_id, const u32 syncpoint_id, const u32 value);
|
void CancelSyncptInterrupt(const u32 syncpoint_id, const u32 value);
|
||||||
|
|
||||||
void Guard(bool guard_set) {
|
void Guard(bool guard_set) {
|
||||||
if (guard_set) {
|
if (guard_set) {
|
||||||
@ -253,7 +253,7 @@ public:
|
|||||||
virtual void FlushAndInvalidateRegion(CacheAddr addr, u64 size) = 0;
|
virtual void FlushAndInvalidateRegion(CacheAddr addr, u64 size) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void TriggerCpuInterrupt(const u32 event_id) const = 0;
|
virtual void TriggerCpuInterrupt(const u32 syncpoint_id, const u32 value) const = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ProcessBindMethod(const MethodCall& method_call);
|
void ProcessBindMethod(const MethodCall& method_call);
|
||||||
@ -293,13 +293,7 @@ private:
|
|||||||
|
|
||||||
std::array<std::atomic<u32>, Service::Nvidia::MaxSyncPoints> syncpoints{};
|
std::array<std::atomic<u32>, Service::Nvidia::MaxSyncPoints> syncpoints{};
|
||||||
|
|
||||||
struct Event {
|
std::array<std::list<u32>, Service::Nvidia::MaxSyncPoints> syncpt_interrupts;
|
||||||
Event(const u32 event_id, const u32 value) : event_id(event_id), value(value) {}
|
|
||||||
u32 event_id;
|
|
||||||
u32 value;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::array<std::list<Event>, Service::Nvidia::MaxSyncPoints> events;
|
|
||||||
|
|
||||||
std::mutex sync_mutex;
|
std::mutex sync_mutex;
|
||||||
|
|
||||||
|
@ -40,9 +40,9 @@ void GPUAsynch::FlushAndInvalidateRegion(CacheAddr addr, u64 size) {
|
|||||||
gpu_thread.FlushAndInvalidateRegion(addr, size);
|
gpu_thread.FlushAndInvalidateRegion(addr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUAsynch::TriggerCpuInterrupt(const u32 event_id) const {
|
void GPUAsynch::TriggerCpuInterrupt(const u32 syncpoint_id, const u32 value) const {
|
||||||
auto& interrupt_manager = system.InterruptManager();
|
auto& interrupt_manager = system.InterruptManager();
|
||||||
interrupt_manager.InterruptGPU(event_id);
|
interrupt_manager.GPUInterruptSyncpt(syncpoint_id, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VideoCommon
|
} // namespace VideoCommon
|
||||||
|
@ -28,7 +28,7 @@ public:
|
|||||||
void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override;
|
void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void TriggerCpuInterrupt(const u32 event_id) const override;
|
void TriggerCpuInterrupt(const u32 syncpoint_id, const u32 value) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GPUThread::ThreadManager gpu_thread;
|
GPUThread::ThreadManager gpu_thread;
|
||||||
|
@ -27,7 +27,7 @@ public:
|
|||||||
void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override;
|
void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void TriggerCpuInterrupt(const u32 event_id) const override {}
|
void TriggerCpuInterrupt(const u32 syncpoint_id, const u32 value) const override {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace VideoCommon
|
} // namespace VideoCommon
|
||||||
|
Loading…
Reference in New Issue
Block a user