From 3959b5be1e70830dcc5b8b50c44692883c10c632 Mon Sep 17 00:00:00 2001 From: Shane Xiao Date: Wed, 14 Aug 2024 16:14:33 +0800 Subject: [PATCH] [SWDEV-479204] Fix the hipGraph AQL package fill issue This patch fixes this potential issue that filling AQL header before filling the AQL body. The hsa spec specifies "Packet processors may process AQL packets after the packet format field is updated, but before the doorbell is signaled." However, the hipGraph AQL package with valid header will be filled before fill the body, which may have the potential issue that CP receive invalid AQL body. Change-Id: I84af798c19ee2b8805ba19732b0eabdea2958a96 --- rocclr/device/rocm/rocvirtual.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rocclr/device/rocm/rocvirtual.cpp b/rocclr/device/rocm/rocvirtual.cpp index ca10e50857..d1eb6d6000 100644 --- a/rocclr/device/rocm/rocvirtual.cpp +++ b/rocclr/device/rocm/rocvirtual.cpp @@ -999,7 +999,16 @@ inline bool VirtualGPU::dispatchAqlPacket( auto packet = reinterpret_cast(aqlpacket); ClPrint(amd::LOG_INFO, amd::LOG_KERN, "Graph shader name : %s", kernelName.c_str()); - dispatchGenericAqlPacket(packet, packet->header, packet->setup, false); + + // The Aqlpacket with valid header will trigger the issue that AQL fill + // the header before filling the body. However, the CP can handle the AQL package + // after seeing the valid AQL header with the AQL package's body is NULL. + // This patch fixes this potential issue that filling AQL header before + // filling the AQL body. + uint16_t packetHeader = packet->header; + packet->header = (HSA_PACKET_TYPE_INVALID << HSA_PACKET_HEADER_TYPE); + dispatchGenericAqlPacket(packet, packetHeader, packet->setup, false); + packet->header = packetHeader; profilingEnd(*vcmd);