libhsakmt: add runtime enable and disable calls

Add hsaKmtRuntimeEnable and disable.

Signed-off-by: Jonathan Kim <jonathan.kim@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Change-Id: I083f9293948e975546a1b3c1334cb41499b9ab1f
Tento commit je obsažen v:
Jonathan Kim
2021-05-25 11:13:48 -04:00
odevzdal Jonathan Kim
rodič 31ac82617c
revize 1ce548829b
3 změnil soubory, kde provedl 77 přidání a 0 odebrání
+11
Zobrazit soubor
@@ -633,6 +633,17 @@ hsaKmtDbgAddressWatch(
HsaEvent* WatchEvent[] //IN, optional
);
HSAKMT_STATUS
HSAKMTAPI
hsaKmtRuntimeEnable(
void* rDebug, // IN
bool setupTtmp
);
HSAKMT_STATUS
HSAKMTAPI
hsaKmtRuntimeDisable(void);
/**
Get the major and minor version of the kernel debugger support.
*/
+64
Zobrazit soubor
@@ -25,6 +25,7 @@
#include "libhsakmt.h"
#include "linux/kfd_ioctl.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -294,3 +295,66 @@ hsaKmtGetKernelDebugTrapVersionInfo(
*Minor = args.data2;
return HSAKMT_STATUS_SUCCESS;
}
#define HSA_RUNTIME_ENABLE_MIN_MAJOR 9
#define HSA_RUNTIME_ENABLE_MIN_MINOR 0
HSAKMT_STATUS HSAKMTAPI hsaKmtRuntimeEnable(void *rDebug,
bool setupTtmp)
{
struct kfd_ioctl_dbg_trap_args args = {0};
HSAuint32 kMajor, kMinor;
HSAKMT_STATUS result;
result = hsaKmtGetKernelDebugTrapVersionInfo(&kMajor, &kMinor);
if (result)
return HSAKMT_STATUS_NOT_SUPPORTED;
if (kMajor != HSA_RUNTIME_ENABLE_MIN_MAJOR ||
(int)kMinor < HSA_RUNTIME_ENABLE_MIN_MINOR)
return HSAKMT_STATUS_NOT_SUPPORTED;
memset(&args, 0x00, sizeof(args));
args.op = KFD_IOC_DBG_TRAP_RUNTIME_ENABLE;
args.pid = getpid();
args.data1 = 1; //enable
args.data2 = setupTtmp;
args.ptr = (HSAuint64)rDebug;
long err = kmtIoctl(kfd_fd, AMDKFD_IOC_DBG_TRAP, &args);
if (err) {
if (err == EBUSY)
return HSAKMT_STATUS_UNAVAILABLE;
else
return HSAKMT_STATUS_ERROR;
}
return HSAKMT_STATUS_SUCCESS;
}
HSAKMT_STATUS HSAKMTAPI hsaKmtRuntimeDisable(void)
{
struct kfd_ioctl_dbg_trap_args args = {0};
HSAuint32 kMajor, kMinor;
HSAKMT_STATUS result;
result = hsaKmtGetKernelDebugTrapVersionInfo(&kMajor, &kMinor);
if (result)
return HSAKMT_STATUS_NOT_SUPPORTED;
if (kMajor != HSA_RUNTIME_ENABLE_MIN_MAJOR ||
(int)kMinor < HSA_RUNTIME_ENABLE_MIN_MINOR)
return HSAKMT_STATUS_NOT_SUPPORTED;
memset(&args, 0x00, sizeof(args));
args.op = KFD_IOC_DBG_TRAP_RUNTIME_ENABLE;
args.pid = getpid();
args.data1 = 0; //disable
if (kmtIoctl(kfd_fd, AMDKFD_IOC_DBG_TRAP, &args))
return HSAKMT_STATUS_ERROR;
return HSAKMT_STATUS_SUCCESS;
}
+2
Zobrazit soubor
@@ -59,6 +59,8 @@ hsaKmtSetMemoryUserData;
hsaKmtGetQueueInfo;
hsaKmtAllocQueueGWS;
hsaKmtGetKernelDebugTrapVersionInfo;
hsaKmtRuntimeEnable;
hsaKmtRuntimeDisable;
hsaKmtSPMAcquire;
hsaKmtSPMRelease;
hsaKmtSPMSetDestBuffer;