Skip to content

Commit

Permalink
Make some gpu registers atomic to ensure thread-safety in pfifo::worker
Browse files Browse the repository at this point in the history
  • Loading branch information
ergo720 committed Aug 4, 2024
1 parent c3e972e commit 308471d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/hw/video/gpu/pcrtc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include <cstdint>
#include <atomic>
#include "nv2a_defs.hpp"

#define NV_PCRTC 0x00600000
Expand Down Expand Up @@ -41,8 +42,8 @@ class pcrtc {
friend class pmc;
machine *const m_machine;
struct {
uint32_t int_status;
uint32_t int_enabled;
std::atomic_uint32_t int_status; // accessed from pfifo::worker with pmc::update_irq()
std::atomic_uint32_t int_enabled; // accessed from pfifo::worker with pmc::update_irq()
uint32_t fb_addr;
uint32_t unknown[1];
};
Expand Down
3 changes: 2 additions & 1 deletion src/hw/video/gpu/pfb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include <cstdint>
#include <atomic>
#include "nv2a_defs.hpp"

#define NV_PFB 0x00100000
Expand Down Expand Up @@ -41,6 +42,6 @@ class pfb {
struct {
uint32_t cfg0, cfg1;
uint32_t nvm;
uint32_t cstatus;
std::atomic_uint32_t cstatus; // accessed from pfifo::worker with nv2a::get_dma_obj()
};
};
5 changes: 3 additions & 2 deletions src/hw/video/gpu/pmc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include <cstdint>
#include <atomic>
#include "nv2a_defs.hpp"

#define NV_PMC 0x00000000
Expand Down Expand Up @@ -83,8 +84,8 @@ class pmc {
machine *const m_machine;
struct {
uint32_t endianness;
uint32_t int_status;
uint32_t int_enabled;
std::atomic_uint32_t int_status; // accessed from pfifo::worker with pmc::update_irq()
std::atomic_uint32_t int_enabled; // accessed from pfifo::worker with pmc::update_irq()
uint32_t engine_enabled;
};
};
5 changes: 3 additions & 2 deletions src/hw/video/gpu/ptimer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include <cstdint>
#include <atomic>
#include "nv2a_defs.hpp"

#define NV_PTIMER 0x00009000
Expand Down Expand Up @@ -64,8 +65,8 @@ class ptimer {
// Counter value when it was stopped
uint64_t counter_when_stopped;
struct {
uint32_t int_status;
uint32_t int_enabled;
std::atomic_uint32_t int_status; // accessed from pfifo::worker with pmc::update_irq()
std::atomic_uint32_t int_enabled; // accessed from pfifo::worker with pmc::update_irq()
uint32_t multiplier, divider;
uint32_t alarm;
};
Expand Down

0 comments on commit 308471d

Please sign in to comment.