From 8f529e3c72a2e55f2befcbc00a9730905e194e48 Mon Sep 17 00:00:00 2001 From: Yair Shachar Date: Mon, 7 Dec 2015 21:09:44 +0200 Subject: [PATCH] Add support for per device debug register state tracking Change-Id: I8d51670f5de8d379ead898d484f668a8034f9878 Signed-off-by: Yair Shachar --- src/debug.c | 21 ++++++++++++++++----- src/fmm.c | 1 + 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/debug.c b/src/debug.c index eff9023d90..00cbbeea9d 100644 --- a/src/debug.c +++ b/src/debug.c @@ -28,6 +28,9 @@ #include #include +static bool is_device_debugged[MAX_NODES] = {false}; +int debug_get_reg_status(uint32_t node_id, bool* is_debugged); + HSAKMT_STATUS HSAKMTAPI hsaKmtDbgRegister( @@ -47,9 +50,10 @@ hsaKmtDbgRegister( args.gpu_id = gpu_id; long err = kmtIoctl(kfd_fd, AMDKFD_IOC_DBG_REGISTER, &args); - if (err == 0) + if (err == 0) { + is_device_debugged[NodeId] = true; result = HSAKMT_STATUS_SUCCESS; - else + } else result = HSAKMT_STATUS_ERROR; return (result); @@ -75,9 +79,10 @@ hsaKmtDbgUnregister( memset(&args, 0, sizeof(args)); args.gpu_id = gpu_id; long err = kmtIoctl(kfd_fd, AMDKFD_IOC_DBG_UNREGISTER, &args); - if (err == 0) + if (err == 0) { + is_device_debugged[NodeId] = false; result = HSAKMT_STATUS_SUCCESS; - else + } else result = HSAKMT_STATUS_ERROR; return (result); @@ -276,4 +281,10 @@ hsaKmtDbgAddressWatch( } /* =============================================================================== */ - +int debug_get_reg_status(uint32_t node_id, bool* is_debugged) +{ + if ( node_id >= MAX_NODES) + return -1; + else + return (is_device_debugged[node_id]); +} diff --git a/src/fmm.c b/src/fmm.c index aca71907af..af4840268d 100644 --- a/src/fmm.c +++ b/src/fmm.c @@ -131,6 +131,7 @@ static svm_t svm = { INIT_MANAGEBLE_APERTURE(0, 0) }; +extern int debug_get_reg_status(uint32_t node_id, bool* is_debugged); static HSAKMT_STATUS dgpu_mem_init(uint32_t node_id, void **base, void **limit); static int set_dgpu_aperture(uint32_t node_id, uint64_t base, uint64_t limit); static void __fmm_release(void *address,