From 7f307277e71e695dae11e600182a3f5bb53b95b4 Mon Sep 17 00:00:00 2001 From: Lancelot Six Date: Thu, 5 Sep 2024 18:35:28 +0000 Subject: [PATCH] libhsakmt: Check for KFD 1.13 for debug ioctl interface Core dump support relies on debugger related KFD ioctl which have been introduced in version 1.13 of the interface. However, the code checks for KFD_IOCTL_MINOR_VERSION (currently 17), making it impossible to produce core dumps when using some drivers that should support it. Update the CHECK_KFD_MINOR_VERSION calls in the debugger related ioctl wrappers and look for KFD 1.13 or above. Change-Id: I10a7fd03bf8f678b6318d7c25d6a7ded804dac67 --- src/debug.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/debug.c b/src/debug.c index 67c32c8..7967432 100644 --- a/src/debug.c +++ b/src/debug.c @@ -417,13 +417,16 @@ static HSAKMT_STATUS dbg_trap_suspend_queues(uint32_t *queue_ids, return HSAKMT_STATUS_SUCCESS; } +/* Debugger support has been in KFD ABI 1.13. */ +#define KFD_MINOR_MIN_DEBUG 13 + HSAKMT_STATUS HSAKMTAPI hsaKmtDbgEnable(void **runtime_info, HSAuint32 *data_size) { struct kfd_ioctl_dbg_trap_args args = {0}; CHECK_KFD_OPEN(); - CHECK_KFD_MINOR_VERSION(KFD_IOCTL_MINOR_VERSION); + CHECK_KFD_MINOR_VERSION(KFD_MINOR_MIN_DEBUG); *data_size = sizeof(struct kfd_runtime_info); args.enable.rinfo_size = *data_size; args.enable.dbg_fd = kfd_fd; @@ -446,7 +449,7 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtDbgDisable(void) struct kfd_ioctl_dbg_trap_args args = {0}; CHECK_KFD_OPEN(); - CHECK_KFD_MINOR_VERSION(KFD_IOCTL_MINOR_VERSION); + CHECK_KFD_MINOR_VERSION(KFD_MINOR_MIN_DEBUG); args.enable.dbg_fd = kfd_fd; args.op = KFD_IOC_DBG_TRAP_DISABLE; args.pid = getpid(); @@ -464,7 +467,7 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtDbgGetDeviceData(void **data, HSAKMT_STATUS ret = HSAKMT_STATUS_NO_MEMORY; CHECK_KFD_OPEN(); - CHECK_KFD_MINOR_VERSION(KFD_IOCTL_MINOR_VERSION); + CHECK_KFD_MINOR_VERSION(KFD_MINOR_MIN_DEBUG); *n_entries = UINT32_MAX; *entry_size = sizeof(struct kfd_dbg_device_info_entry); *data = malloc(*entry_size * *n_entries); @@ -485,7 +488,7 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtDbgGetQueueData(void **data, uint32_t *queue_ids = NULL; CHECK_KFD_OPEN(); - CHECK_KFD_MINOR_VERSION(KFD_IOCTL_MINOR_VERSION); + CHECK_KFD_MINOR_VERSION(KFD_MINOR_MIN_DEBUG); *entry_size = sizeof(struct kfd_queue_snapshot_entry); *n_entries = 0; if (dbg_trap_get_queue_data(NULL, n_entries, *entry_size, NULL))