Add exclusive trace access
Signed-off-by: Alexey Skidanov <Alexey.Skidanov@amd.com>
[ROCm/ROCR-Runtime commit: 0ecaa96523]
This commit is contained in:
committed by
Oded Gabbay
parent
f16b449d51
commit
cdfe250500
@@ -27,6 +27,7 @@
|
||||
#include "libhsakmt.h"
|
||||
#include "pmc_table.h"
|
||||
#include "linux/kfd_ioctl.h"
|
||||
#include <unistd.h>
|
||||
|
||||
#define BITS_PER_BYTE CHAR_BIT
|
||||
|
||||
@@ -43,6 +44,8 @@ struct perf_trace {
|
||||
enum perf_trace_state state;
|
||||
};
|
||||
|
||||
extern int amd_hsa_thunk_lock_fd;
|
||||
|
||||
static HsaCounterProperties *counter_props[MAX_NODES] = {NULL};
|
||||
|
||||
static int blockid2uuid(enum perf_block_id block_id, HSA_UUID *uuid)
|
||||
@@ -248,7 +251,15 @@ hsaKmtPmcAcquireTraceAccess(
|
||||
if (trace->magic4cc != HSA_PERF_MAGIC4CC)
|
||||
return HSAKMT_STATUS_INVALID_HANDLE;
|
||||
|
||||
return HSAKMT_STATUS_SUCCESS;
|
||||
if (amd_hsa_thunk_lock_fd > 0) {
|
||||
if (lockf( amd_hsa_thunk_lock_fd, F_TLOCK, 0 ) != 0)
|
||||
return HSAKMT_STATUS_ERROR;
|
||||
else
|
||||
return HSAKMT_STATUS_SUCCESS;
|
||||
}
|
||||
else {
|
||||
return HSAKMT_STATUS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -274,7 +285,16 @@ hsaKmtPmcReleaseTraceAccess(
|
||||
if (trace->magic4cc != HSA_PERF_MAGIC4CC)
|
||||
return HSAKMT_STATUS_INVALID_HANDLE;
|
||||
|
||||
return HSAKMT_STATUS_SUCCESS;
|
||||
if (amd_hsa_thunk_lock_fd > 0) {
|
||||
if (lockf( amd_hsa_thunk_lock_fd, F_ULOCK, 0 ) != 0)
|
||||
return HSAKMT_STATUS_ERROR;
|
||||
else
|
||||
return HSAKMT_STATUS_SUCCESS;
|
||||
}
|
||||
else {
|
||||
return HSAKMT_STATUS_ERROR;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user