Change API to get the driver date
Support the driver date from libdrm.
Change-Id: I88e694732b538220e11fdb4029712bb5a6f44380
[ROCm/amdsmi commit: 55bf9cbe13]
This commit is contained in:
@@ -1444,11 +1444,11 @@ amdsmi_get_power_info(amdsmi_processor_handle processor_handle, amdsmi_power_inf
|
||||
return status;
|
||||
}
|
||||
|
||||
amdsmi_status_t
|
||||
amdsmi_get_gpu_driver_version(amdsmi_processor_handle processor_handle, int *length, char *version) {
|
||||
amdsmi_status_t amdsmi_get_gpu_driver_info(amdsmi_processor_handle processor_handle,
|
||||
amdsmi_driver_info_t *info) {
|
||||
AMDSMI_CHECK_INIT();
|
||||
|
||||
if (length == nullptr || version == nullptr) {
|
||||
if (info == nullptr) {
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
}
|
||||
amdsmi_status_t status = AMDSMI_STATUS_SUCCESS;
|
||||
@@ -1457,11 +1457,17 @@ amdsmi_get_gpu_driver_version(amdsmi_processor_handle processor_handle, int *len
|
||||
if (r != AMDSMI_STATUS_SUCCESS)
|
||||
return r;
|
||||
|
||||
status = smi_amdgpu_get_driver_version(gpu_device, length, version);
|
||||
|
||||
int length = AMDSMI_MAX_STRING_LENGTH;
|
||||
status = smi_amdgpu_get_driver_version(gpu_device,
|
||||
&length, info->driver_version);
|
||||
std::string driver_date;
|
||||
status = gpu_device->amdgpu_query_driver_date(driver_date);
|
||||
if (status != AMDSMI_STATUS_SUCCESS) return r;
|
||||
strncpy(info->driver_date, driver_date.c_str(), AMDSMI_MAX_STRING_LENGTH-1);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
amdsmi_status_t
|
||||
amdsmi_get_gpu_device_uuid(amdsmi_processor_handle processor_handle, unsigned int *uuid_length, char *uuid) {
|
||||
AMDSMI_CHECK_INIT();
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <xf86drm.h>
|
||||
#include <string.h>
|
||||
#include <memory>
|
||||
#include <regex>
|
||||
@@ -99,22 +98,19 @@ amdsmi_status_t AMDSmiDrm::init() {
|
||||
return status;
|
||||
}
|
||||
|
||||
using drmGetVersionType = drmVersionPtr (*)(int); // drmGetVersion
|
||||
using drmFreeVersionType = void (*)(drmVersionPtr); // drmFreeVersion
|
||||
using drmGetDeviceType = int(*)(int, drmDevicePtr*); // drmGetDevice
|
||||
using drmFreeDeviceType = void(*)(drmDevicePtr*); // drmFreeDevice
|
||||
|
||||
drmGetVersionType drm_get_version = nullptr;
|
||||
drmFreeVersionType drm_free_version = nullptr;
|
||||
|
||||
drmGetDeviceType drm_get_device = nullptr;
|
||||
drmFreeDeviceType drm_free_device = nullptr;
|
||||
drm_get_version_ = nullptr;
|
||||
drm_free_version_ = nullptr;
|
||||
|
||||
status = lib_loader_.load_symbol(&drm_get_version, "drmGetVersion");
|
||||
status = lib_loader_.load_symbol(&drm_get_version_, "drmGetVersion");
|
||||
if (status != AMDSMI_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
status = lib_loader_.load_symbol(&drm_free_version, "drmFreeVersion");
|
||||
status = lib_loader_.load_symbol(&drm_free_version_, "drmFreeVersion");
|
||||
if (status != AMDSMI_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
@@ -155,7 +151,7 @@ amdsmi_status_t AMDSmiDrm::init() {
|
||||
amdsmi_bdf_t bdf;
|
||||
if (fd >= 0) {
|
||||
auto version = drm_version_ptr(
|
||||
drm_get_version(fd), drm_free_version);
|
||||
drm_get_version_(fd), drm_free_version_);
|
||||
if (strcmp("amdgpu", version->name)) { // only amdgpu
|
||||
close(fd);
|
||||
fd = -1;
|
||||
@@ -201,6 +197,18 @@ amdsmi_status_t AMDSmiDrm::cleanup() {
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t AMDSmiDrm::amdgpu_query_driver_date(int fd, std::string& driver_date) {
|
||||
// RAII handler
|
||||
using drm_version_ptr = std::unique_ptr<drmVersion,
|
||||
decltype(&drmFreeVersion)>;
|
||||
std::lock_guard<std::mutex> guard(drm_mutex_);
|
||||
auto version = drm_version_ptr(
|
||||
drm_get_version_(fd), drm_free_version_);
|
||||
if (version == nullptr) return AMDSMI_STATUS_DRM_ERROR;
|
||||
driver_date = version->date;
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t AMDSmiDrm::amdgpu_query_info(int fd, unsigned info_id,
|
||||
unsigned size, void *value) {
|
||||
if (drm_cmd_write_ == nullptr) return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
|
||||
@@ -105,6 +105,15 @@ amdsmi_status_t AMDSmiGPUDevice::amdgpu_query_info(unsigned info_id,
|
||||
return drm_.amdgpu_query_info(fd, info_id, size, value);
|
||||
}
|
||||
|
||||
amdsmi_status_t AMDSmiGPUDevice::amdgpu_query_driver_date(std::string& date) const {
|
||||
amdsmi_status_t ret;
|
||||
uint32_t fd = 0;
|
||||
ret = drm_.get_drm_fd_by_index(gpu_id_, &fd);
|
||||
if (ret != AMDSMI_STATUS_SUCCESS) return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
|
||||
return drm_.amdgpu_query_driver_date(fd, date);
|
||||
}
|
||||
|
||||
amdsmi_status_t AMDSmiGPUDevice::amdgpu_query_hw_ip(unsigned info_id,
|
||||
unsigned hw_ip_type, unsigned size, void *value) const {
|
||||
amdsmi_status_t ret;
|
||||
|
||||
Reference in New Issue
Block a user