From d98c729ff9c09895e6bef26b0926d6114ad03d26 Mon Sep 17 00:00:00 2001 From: jie1zhan Date: Thu, 1 Sep 2022 17:06:23 +0800 Subject: [PATCH] libhsakmt: Add check for the runntime debuuger Avoiding the segfault, runtime debugger enable is not supported if the firmware of gpu doesn't support debug exceptions. Signed-off-by: jie1zhan Change-Id: Ifad57a6e78cb1c92b1f8927355ece8c64e89c51b --- src/debug.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/debug.c b/src/debug.c index b2021218ca..0b73c6ce8f 100644 --- a/src/debug.c +++ b/src/debug.c @@ -302,6 +302,25 @@ hsaKmtGetKernelDebugTrapVersionInfo( static HSAKMT_STATUS checkRuntimeDebugSupport(void) { HSAuint32 kMajor, kMinor; + HsaNodeProperties node = {0}; + HsaSystemProperties props = {0}; + + memset(&node, 0x00, sizeof(node)); + memset(&props, 0x00, sizeof(props)); + if (hsaKmtAcquireSystemProperties(&props)) + return HSAKMT_STATUS_ERROR; + + //the firmware of gpu node doesn't support the debugger, disable it. + for (uint32_t i = 0; i < props.NumNodes; i++) { + if (hsaKmtGetNodeProperties(i, &node)) + return HSAKMT_STATUS_ERROR; + + //ignore cpu node + if (node.NumCPUCores) + continue; + if (!node.Capability.ui32.DebugSupportedFirmware) + return HSAKMT_STATUS_NOT_SUPPORTED; + } if (hsaKmtGetKernelDebugTrapVersionInfo(&kMajor, &kMinor)) return HSAKMT_STATUS_NOT_SUPPORTED;