From 280a458d0c5a7b20393f09cda892d1a0d9faa698 Mon Sep 17 00:00:00 2001 From: Sean Keely Date: Fri, 20 Aug 2021 00:56:04 -0500 Subject: [PATCH] Workaround gfx90a SDMA0 quirk. Because of sharing ports with other engines, the hardware design team has advised that SDMA0 on gfx90a should only be used for host-to-device data transfers. The recommendation is to use SDMA1 for any device-to-device or device-to-host data transfers. A driver change will ensure that, for each gfx90a device, only the first PCIe SDMA queue a process requests will possibly be from SDMA0. This patch ensures that the first PCIe queue requested (which may be from SDMA0) is always set up for host-to-device. Change-Id: I6793ca95596dedaed9d5be1dbd9469ceef2a5c33 --- .../hsa-runtime/core/runtime/amd_gpu_agent.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp index 6dc93a4403..cb6c56d88c 100644 --- a/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp +++ b/runtime/hsa-runtime/core/runtime/amd_gpu_agent.cpp @@ -599,7 +599,7 @@ void GpuAgent::InitDma() { queues_[QueueUtility].reset(queue_lambda); // Decide which engine to use for blits. - auto blit_lambda = [this](bool use_xgmi, lazy_ptr& queue) { + auto blit_lambda = [this](bool use_xgmi, lazy_ptr& queue, bool isHostToDev) { Flag::SDMA_OVERRIDE sdma_override = core::Runtime::runtime_singleton_->flag().enable_sdma(); // User SDMA queues are unstable on gfx8 and unsupported on gfx1013. @@ -608,6 +608,12 @@ void GpuAgent::InitDma() { if (sdma_override != Flag::SDMA_DEFAULT) use_sdma = (sdma_override == Flag::SDMA_ENABLE); if (use_sdma && (HSA_PROFILE_BASE == profile_)) { + // On gfx90a ensure that HostToDevice queue is created first and so is placed on SDMA0. + if ((!use_xgmi) && (!isHostToDev) && (isa_->GetMajorVersion() == 9) && + (isa_->GetMinorVersion() == 0) && (isa_->GetStepping() == 10)) { + *blits_[BlitHostToDev]; + } + auto ret = CreateBlitSdma(use_xgmi); if (ret != nullptr) return ret; } @@ -643,13 +649,14 @@ void GpuAgent::InitDma() { return ret; }); blits_[BlitHostToDev].reset( - [blit_lambda, this]() { return blit_lambda(false, queues_[QueueBlitOnly]); }); + [blit_lambda, this]() { return blit_lambda(false, queues_[QueueBlitOnly], true); }); blits_[BlitDevToHost].reset( - [blit_lambda, this]() { return blit_lambda(false, queues_[QueueUtility]); }); + [blit_lambda, this]() { return blit_lambda(false, queues_[QueueUtility], false); }); // XGMI engines. for (uint32_t idx = DefaultBlitCount; idx < blit_cnt_; idx++) { - blits_[idx].reset([blit_lambda, this]() { return blit_lambda(true, queues_[QueueUtility]); }); + blits_[idx].reset( + [blit_lambda, this]() { return blit_lambda(true, queues_[QueueUtility], false); }); } // GWS queues.