Add exclusive trace access

Signed-off-by: Alexey Skidanov <Alexey.Skidanov@amd.com>


[ROCm/ROCR-Runtime commit: 0ecaa96523]
Цей коміт міститься в:
Alexey Skidanov
2014-12-08 17:05:56 +02:00
зафіксовано Oded Gabbay
джерело f16b449d51
коміт cdfe250500
2 змінених файлів з 35 додано та 2 видалено
+13
Переглянути файл
@@ -33,6 +33,8 @@
#include "fmm.h"
static const char kfd_device_name[] = "/dev/kfd";
static const char tmp_file[] = "/var/lock/.amd_hsa_thunk_lock";
int amd_hsa_thunk_lock_fd = 0;
HSAKMT_STATUS
HSAKMTAPI
@@ -59,6 +61,11 @@ hsaKmtOpenKFD(void)
{
result = HSAKMT_STATUS_KERNEL_IO_CHANNEL_NOT_OPENED;
}
amd_hsa_thunk_lock_fd = open(tmp_file,
O_CREAT | //create the file if it's not present.
O_RDWR, //only need write access for the internal locking semantics.
S_IRUSR | S_IWUSR); //permissions on the file, 600 here.
}
else
{
@@ -84,6 +91,12 @@ hsaKmtCloseKFD(void)
if (--kfd_open_count == 0)
{
close(kfd_fd);
if (amd_hsa_thunk_lock_fd > 0) {
close(amd_hsa_thunk_lock_fd);
unlink(tmp_file);
}
}
result = HSAKMT_STATUS_SUCCESS;