Skip to content

Commit

Permalink
libhsakmt: Check for KFD 1.13 for debug ioctl interface
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lancesix authored and dayatsin-amd committed Sep 5, 2024
1 parent 05f0d05 commit 7f30727
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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))
Expand Down

0 comments on commit 7f30727

Please sign in to comment.