dev-amdgpu: Better handling for queue remapping

The amdgpu driver can, at *any* time, tell the device to unmap a queue
to force the queue descriptor to be written back to main memory in the
form of a memory queue descriptor (MQD). It will then immediately remap
the queue and continue writing the doorbell to the queue. It is possible
that the doorbell write occurs after the queue is unmapped but before it
is remapped. In this situation, we need to check the updated value of
the doorbell for the queue and write that to the queue after it is
mapped.

To handle this, a pending doorbell packet map is created to hold a
packet to replay when the queue is mapped. Because PCI in gem5
implements only the atomic protocol port, we cannot use the original
packet as it must respond in the same Tick. This patch fixes issues with
the doorbell maps not being cleared on unmapping to ensure the doorbell
is not found in writeDoorbell and places in the pending doorbell map.
This includes fixing the doorbell offset value in the doorbell to VMID
map which was is now multiplied by four as it is a dword address.

This was tested using tensorflow 2.0's MNIST example which was seeing
this issue consistently. With this patch it now makes progress and does
issue pending doorbell writes.

Change-Id: Ic6b401d3fe7fc46b7bcbf19a769cdea6814e7d1e
This commit is contained in:
Matthew Poremba
2023-10-13 14:59:56 -05:00
parent d05433b3f6
commit 37da1c45f3
3 changed files with 41 additions and 2 deletions

View File

@@ -90,6 +90,7 @@ class AMDGPUDevice : public PciDevice
using GPURegMap = std::unordered_map<uint32_t, uint64_t>;
GPURegMap regs;
std::unordered_map<uint32_t, QueueType> doorbells;
std::unordered_map<uint32_t, PacketPtr> pendingDoorbellPkts;
/**
* VGA ROM methods
@@ -187,6 +188,7 @@ class AMDGPUDevice : public PciDevice
* Set handles to GPU blocks.
*/
void setDoorbellType(uint32_t offset, QueueType qt);
void processPendingDoorbells(uint32_t offset);
void setSDMAEngine(Addr offset, SDMAEngine *eng);
/**