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:
@@ -466,7 +466,17 @@ AMDGPUDevice::writeDoorbell(PacketPtr pkt, Addr offset)
|
||||
panic("Write to unkown queue type!");
|
||||
}
|
||||
} else {
|
||||
warn("Unknown doorbell offset: %lx\n", offset);
|
||||
warn("Unknown doorbell offset: %lx. Saving to pending doorbells.\n",
|
||||
offset);
|
||||
|
||||
// We have to ACK the PCI packet immediately, so create a copy of the
|
||||
// packet here to send again.
|
||||
RequestPtr pending_req(pkt->req);
|
||||
PacketPtr pending_pkt = Packet::createWrite(pending_req);
|
||||
uint8_t *pending_data = new uint8_t[pkt->getSize()];
|
||||
pending_pkt->dataDynamic(pending_data);
|
||||
|
||||
pendingDoorbellPkts.emplace(offset, pending_pkt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -589,6 +599,17 @@ AMDGPUDevice::write(PacketPtr pkt)
|
||||
return pioDelay;
|
||||
}
|
||||
|
||||
void
|
||||
AMDGPUDevice::processPendingDoorbells(uint32_t offset)
|
||||
{
|
||||
if (pendingDoorbellPkts.count(offset)) {
|
||||
DPRINTF(AMDGPUDevice, "Sending pending doorbell %x\n", offset);
|
||||
writeDoorbell(pendingDoorbellPkts[offset], offset);
|
||||
delete pendingDoorbellPkts[offset];
|
||||
pendingDoorbellPkts.erase(offset);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
AMDGPUDevice::haveRegVal(uint32_t addr)
|
||||
{
|
||||
@@ -812,6 +833,14 @@ AMDGPUDevice::deallocateAllQueues()
|
||||
for (auto& it : sdmaEngs) {
|
||||
it.second->deallocateRLCQueues();
|
||||
}
|
||||
|
||||
// "All" queues implicitly refers to all user queues. User queues begin at
|
||||
// doorbell address 0x4000, so unmap any queue at or above that address.
|
||||
for (auto [offset, vmid] : doorbellVMIDMap) {
|
||||
if (offset >= 0x4000) {
|
||||
doorbells.erase(offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user