From c9ef3ec1a3221383326ad598b41018b32e255cde Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 3 Jan 2021 14:42:41 +1000 Subject: [PATCH] DMA: Clear state on shutdown Fix a rare crash where the GPU starting after a second boot accesses uninitalized DMA fields. --- src/core/dma.cpp | 8 +++++++- src/core/dma.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/dma.cpp b/src/core/dma.cpp index 9bf9c7dc3..a1bc1ee00 100644 --- a/src/core/dma.cpp +++ b/src/core/dma.cpp @@ -36,10 +36,17 @@ void DMA::Initialize() void DMA::Shutdown() { + ClearState(); m_unhalt_event.reset(); } void DMA::Reset() +{ + ClearState(); + m_unhalt_event->Deactivate(); +} + +void DMA::ClearState() { for (u32 i = 0; i < NUM_CHANNELS; i++) { @@ -54,7 +61,6 @@ void DMA::Reset() m_DICR.bits = 0; m_halt_ticks_remaining = 0; - m_unhalt_event->Deactivate(); } bool DMA::DoState(StateWrapper& sw) diff --git a/src/core/dma.h b/src/core/dma.h index b04b7dfc9..b4f76a774 100644 --- a/src/core/dma.h +++ b/src/core/dma.h @@ -60,6 +60,8 @@ private: Reserved = 3 }; + void ClearState(); + // is everything enabled for a channel to operate? bool CanTransferChannel(Channel channel) const; bool IsTransferHalted() const;