From 0a8096b34ae025ce6cff57690157c6e16f9be71f Mon Sep 17 00:00:00 2001 From: Ruili Ji Date: Thu, 8 Jun 2023 15:05:19 +0800 Subject: [PATCH] kfdtest: Update COMPUTE_PGM_RSRC1 for software trap If asics don't need software traps within GFX11 domain, test with COMPUTE_PGM_RSRC1.PRIV = 1 will make system hang. Change-Id: I00cf8eb6d6b07856885c77bd343ca3c41cc3cad5 Signed-off-by: Ruili Ji Signed-off-by: Aaron Liu [ROCm/ROCR-Runtime commit: 9bf1cbe4ed7d3b58d9513de130dd08b56e0e312d] --- .../tests/kfdtest/src/Dispatch.cpp | 7 ++++++- .../tests/kfdtest/src/Dispatch.hpp | 1 + .../kfdtest/src/KFDBaseComponentTest.cpp | 19 +++++++++++++++++++ .../kfdtest/src/KFDBaseComponentTest.hpp | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/projects/rocr-runtime/tests/kfdtest/src/Dispatch.cpp b/projects/rocr-runtime/tests/kfdtest/src/Dispatch.cpp index ce3a8f4626..6209d8cb59 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/Dispatch.cpp +++ b/projects/rocr-runtime/tests/kfdtest/src/Dispatch.cpp @@ -45,6 +45,7 @@ Dispatch::Dispatch(const HsaMemoryBuffer& isaBuf, const bool eventAutoReset) hsaKmtCreateEvent(&eventDesc, !eventAutoReset, false, &m_pEop); m_FamilyId = g_baseTest->GetFamilyIdFromNodeId(isaBuf.Node()); + m_NeedCwsrWA = g_baseTest->NeedCwsrWA(isaBuf.Node()); } Dispatch::~Dispatch() { @@ -138,7 +139,11 @@ void Dispatch::BuildIb() { pgmRsrc2 |= (1 << COMPUTE_PGM_RSRC2__EXCP_EN_MSB__SHIFT) & COMPUTE_PGM_RSRC2__EXCP_EN_MSB_MASK; - const bool priv = (m_FamilyId == FAMILY_GFX11); + /* + * For some special asics in the list of DEGFX11_12113 + * COMPUTE_PGM_RSRC needs priv=1 to prevent hardware traps + */ + const bool priv = m_NeedCwsrWA; const unsigned int COMPUTE_PGM_RSRC[] = { // PGM_RSRC1 = { VGPRS: 16 SGPRS: 16 PRIORITY: m_SpiPriority FLOAT_MODE: c0 // PRIV: 0 (1 for GFX11) DX10_CLAMP: 0 DEBUG_MODE: 0 IEEE_MODE: 0 BULKY: 0 CDBG_USER: 0 } diff --git a/projects/rocr-runtime/tests/kfdtest/src/Dispatch.hpp b/projects/rocr-runtime/tests/kfdtest/src/Dispatch.hpp index ce8ffba21b..b43becf01b 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/Dispatch.hpp +++ b/projects/rocr-runtime/tests/kfdtest/src/Dispatch.hpp @@ -71,6 +71,7 @@ class Dispatch { HSAuint64 m_scratch_base; unsigned int m_SpiPriority; unsigned int m_FamilyId; + bool m_NeedCwsrWA; }; #endif // __KFD_DISPATCH__H__ diff --git a/projects/rocr-runtime/tests/kfdtest/src/KFDBaseComponentTest.cpp b/projects/rocr-runtime/tests/kfdtest/src/KFDBaseComponentTest.cpp index 2c0625972e..c257add6a4 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/KFDBaseComponentTest.cpp +++ b/projects/rocr-runtime/tests/kfdtest/src/KFDBaseComponentTest.cpp @@ -164,6 +164,25 @@ unsigned int KFDBaseComponentTest::GetFamilyIdFromNodeId(unsigned int nodeId) return FamilyIdFromNode(m_NodeInfo.GetNodeProperties(nodeId)); } +/* + * Some asics need CWSR workround for DEGFX11_12113 + */ +bool KFDBaseComponentTest::NeedCwsrWA(unsigned int nodeId) +{ + bool needCwsrWA = false; + const HsaNodeProperties *props = m_NodeInfo.GetNodeProperties(nodeId); + + needCwsrWA = props->EngineId.ui32.Major == 11 && + props->EngineId.ui32.Minor == 0 && + (props->EngineId.ui32.Stepping == 0 || + props->EngineId.ui32.Stepping == 1 || + props->EngineId.ui32.Stepping == 2 || + props->EngineId.ui32.Stepping == 5 || + (props->EngineId.ui32.Stepping == 3 && props->NumArrays > 1)); + + return needCwsrWA; +} + bool KFDBaseComponentTest::NeedNonPagedWptr(unsigned int nodeId) { return GetFamilyIdFromNodeId(nodeId) >= FAMILY_GFX11; diff --git a/projects/rocr-runtime/tests/kfdtest/src/KFDBaseComponentTest.hpp b/projects/rocr-runtime/tests/kfdtest/src/KFDBaseComponentTest.hpp index 22d5bcd12d..7fddd23844 100644 --- a/projects/rocr-runtime/tests/kfdtest/src/KFDBaseComponentTest.hpp +++ b/projects/rocr-runtime/tests/kfdtest/src/KFDBaseComponentTest.hpp @@ -58,6 +58,7 @@ class KFDBaseComponentTest : public testing::Test { // @return DRM Render Node if successful or -1 on failure int FindDRMRenderNode(int gpuNode); unsigned int GetFamilyIdFromNodeId(unsigned int nodeId); + bool NeedCwsrWA(unsigned int nodeId); bool NeedNonPagedWptr(unsigned int nodeId); unsigned int GetFamilyIdFromDefaultNode(){ return m_FamilyId; }