From 08644a76707ac8ee14f9ff0d52af7c3e324209f0 Mon Sep 17 00:00:00 2001 From: Matthew Poremba Date: Tue, 16 May 2023 19:46:50 -0500 Subject: [PATCH] dev-amdgpu: Fix nbio psp ring assert The size of the packet changes between ROCm 4.x and ROCm 5.x. Change how the address is set based on the incoming packet size so that both versions continue to work for now. Change-Id: I91694e4760198fd9129e60140df4e863666be2e2 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/70677 Tested-by: kokoro Reviewed-by: Matt Sinclair Maintainer: Matt Sinclair --- src/dev/amdgpu/amdgpu_nbio.cc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/dev/amdgpu/amdgpu_nbio.cc b/src/dev/amdgpu/amdgpu_nbio.cc index 8064fd2a0e..69e4373e64 100644 --- a/src/dev/amdgpu/amdgpu_nbio.cc +++ b/src/dev/amdgpu/amdgpu_nbio.cc @@ -162,9 +162,23 @@ void AMDGPUNbio::writeFrame(PacketPtr pkt, Addr offset) { if (offset == psp_ring_listen_addr) { - assert(pkt->getSize() == 8); - psp_ring_dev_addr = pkt->getLE() - - gpuDevice->getVM().getSysAddrRangeLow(); + DPRINTF(AMDGPUDevice, "Saw psp_ring_listen_addr with size %ld value " + "%ld\n", pkt->getSize(), pkt->getUintX(ByteOrder::little)); + + /* + * In ROCm versions 4.x this packet is a 4 byte value. In ROCm 5.x + * the packet is 8 bytes and mapped as a system address which needs + * to be subtracted out to get the framebuffer address. + */ + if (pkt->getSize() == 4) { + psp_ring_dev_addr = pkt->getLE(); + } else if (pkt->getSize() == 8) { + psp_ring_dev_addr = pkt->getUintX(ByteOrder::little) + - gpuDevice->getVM().getSysAddrRangeLow(); + } else { + panic("Invalid write size to psp_ring_listen_addr\n"); + } + DPRINTF(AMDGPUDevice, "Setting PSP ring device address to %#lx\n", psp_ring_dev_addr); }