From 6c1b95ea41785bfebe4c1e56cbe6c472b150e5b1 Mon Sep 17 00:00:00 2001 From: Matthew Poremba Date: Fri, 21 Apr 2023 14:07:01 -0500 Subject: [PATCH] dev-amdgpu: Default MMIO reads when previously written If an MMIO was previously written and the driver reads it, we should return the value that was previously read. This overwrites the MMIO trace value which is the last resort fallback for finding an MMIO value. This is needed to initialize newer GPU devices in gem5. Change-Id: Ida2435290b706288e88518b5d920691cdb6dcc09 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/70039 Maintainer: Matt Sinclair Reviewed-by: Matt Sinclair Tested-by: kokoro --- src/dev/amdgpu/amdgpu_device.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/dev/amdgpu/amdgpu_device.cc b/src/dev/amdgpu/amdgpu_device.cc index 3605882b74..7e6304afa1 100644 --- a/src/dev/amdgpu/amdgpu_device.cc +++ b/src/dev/amdgpu/amdgpu_device.cc @@ -248,6 +248,13 @@ AMDGPUDevice::readMMIO(PacketPtr pkt, Addr offset) DPRINTF(AMDGPUDevice, "Read MMIO %#lx\n", offset); mmioReader.readFromTrace(pkt, MMIO_BAR, offset); + if (regs.find(pkt->getAddr()) != regs.end()) { + uint64_t value = regs[pkt->getAddr()]; + DPRINTF(AMDGPUDevice, "Reading what kernel wrote before: %#x\n", + value); + pkt->setUintX(value, ByteOrder::little); + } + switch (aperture) { case NBIO_BASE: switch (aperture_offset) {