From dbbd189b331b236fa560d25a2133e02ce57bde16 Mon Sep 17 00:00:00 2001 From: Philip Cox Date: Mon, 7 Oct 2019 11:25:24 -0400 Subject: [PATCH] Add functions to get the kfd debugger version info To support adding new features to the kfd debugger, and not break functionality, we need to be able to check the kfd debugger support version info from the kernel. Change-Id: Icd88e4edab8430c35eaed588e62d892c1b5c62ec Signed-off-by: Philip Cox --- include/hsakmt.h | 30 ++++++++++++++++++++++++++++ src/debug.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++- src/libhsakmt.ver | 2 ++ 3 files changed, 81 insertions(+), 1 deletion(-) diff --git a/include/hsakmt.h b/include/hsakmt.h index 49d255a868..d5af173b30 100644 --- a/include/hsakmt.h +++ b/include/hsakmt.h @@ -917,6 +917,36 @@ hsaKmtSetWaveLaunchMode( HSA_DBG_WAVE_LAUNCH_MODE WaveLaunchMode //IN ); +/** + * Get the major and minor version of the kernel debugger support. + * + * Returns: + * - HSAKMT_STATUS_SUCCESS if successful. + * + * - HSAKMT_STATUS_INVALID_HANDLE if NodeId is invalid. + * + * - HSAKMT_STATUS_NOT_SUPPORTED if debug trap not supported for NodeId. +*/ +HSAKMT_STATUS +HSAKMTAPI +hsaKmtGetKernelDebugTrapVersionInfo( + HSAuint32 *Major, //Out + HSAuint32 *Minor //Out + ); + +/** + * Get the major and minor version of the thunk debugger support. +*/ +void +HSAKMTAPI +hsaKmtGetThunkDebugTrapVersionInfo( + HSAuint32 *Major, //Out + HSAuint32 *Minor //Out + ); + + + + /** Set a debug memory access watch point. A memory access of the kind specified by WatchMode to an matching address will cause the trap diff --git a/src/debug.c b/src/debug.c index f111d7ff75..6d2f7b8773 100644 --- a/src/debug.c +++ b/src/debug.c @@ -286,7 +286,8 @@ static HSAKMT_STATUS debug_trap(HSAuint32 NodeId, CHECK_KFD_OPEN(); if (op == KFD_IOC_DBG_TRAP_NODE_SUSPEND || - op == KFD_IOC_DBG_TRAP_NODE_RESUME) { + op == KFD_IOC_DBG_TRAP_NODE_RESUME || + op == KFD_IOC_DBG_TRAP_GET_VERSION) { if (NodeId != INVALID_NODEID) return HSAKMT_STATUS_INVALID_HANDLE; @@ -596,3 +597,50 @@ hsaKmtQueryDebugEvent( return result; } +/** + * Get the major and minor version of the kernel debugger support. + * + * Returns: + * - HSAKMT_STATUS_SUCCESS if successful. + * + * - HSAKMT_STATUS_INVALID_HANDLE if NodeId is invalid. + * + * - HSAKMT_STATUS_NOT_SUPPORTED if debug trap not supported for NodeId. +*/ +HSAKMT_STATUS +HSAKMTAPI +hsaKmtGetKernelDebugTrapVersionInfo( + HSAuint32 *Major, //Out + HSAuint32 *Minor //Out +) +{ + HSAKMT_STATUS result; + struct kfd_ioctl_dbg_trap_args argout = {0}; + + result = debug_trap(INVALID_NODEID, + KFD_IOC_DBG_TRAP_GET_VERSION, + 0, + 0, + 0, + INVALID_PID, + 0, + &argout); + + *Major = argout.data1; + *Minor = argout.data2; + return result; +} + +/** + * Get the major and minor version of the Thunk debugger support. +*/ +void +HSAKMTAPI +hsaKmtGetThunkDebugTrapVersionInfo( + HSAuint32 *Major, //Out + HSAuint32 *Minor //Out +) +{ + *Major = KFD_IOCTL_DBG_MAJOR_VERSION; + *Minor = KFD_IOCTL_DBG_MINOR_VERSION; +} diff --git a/src/libhsakmt.ver b/src/libhsakmt.ver index 482a7aeaf8..3f2e787ac5 100644 --- a/src/libhsakmt.ver +++ b/src/libhsakmt.ver @@ -67,6 +67,8 @@ hsaKmtSetWaveLaunchMode; hsaKmtQueueSuspend; hsaKmtQueueResume; hsaKmtAllocQueueGWS; +hsaKmtGetKernelDebugTrapVersionInfo; +hsaKmtGetThunkDebugTrapVersionInfo; local: *; };