Use the same mutex as rocm-smi

Share the same mutex as rocm-smi implementation. Handle the crash
when a user is not in render group.

Change-Id: I486b26569f9b523b41bbdaf95d51f4a730978cfd
Cette révision appartient à :
Bill(Shuzhou) Liu
2024-01-11 08:35:04 -06:00
révisé par Shuzhou Liu
Parent d74be3120e
révision 5a6b5d2a0a
3 fichiers modifiés avec 11 ajouts et 9 suppressions
+2 -6
Voir le fichier
@@ -43,6 +43,7 @@
#include <functional>
#include "amd_smi/impl/amd_smi_gpu_device.h"
#include "rocm_smi/rocm_smi_utils.h"
namespace amd {
@@ -80,11 +81,6 @@ amdsmi_status_t AMDSmiGPUDevice::get_drm_data() {
ret = drm_.get_bdf_by_index(gpu_id_, &bdf);
if (ret != AMDSMI_STATUS_SUCCESS) return AMDSMI_STATUS_NOT_SUPPORTED;
mutex_ = shared_mutex_init(path.c_str(), 0777);
if (mutex_.ptr == nullptr) {
printf("Failed to create shared mem. mutex.");
return AMDSMI_STATUS_INIT_ERROR;
}
bdf_ = bdf, path_ = path, fd_ = fd;
vendor_id_ = drm_.get_vendor_id();
@@ -92,7 +88,7 @@ amdsmi_status_t AMDSmiGPUDevice::get_drm_data() {
}
pthread_mutex_t* AMDSmiGPUDevice::get_mutex() {
return mutex_.ptr;
return amd::smi::GetMutex(gpu_id_);
}
amdsmi_status_t AMDSmiGPUDevice::amdgpu_query_info(unsigned info_id,