SWDEV-417124 - Implement Power Management
Signed-off-by: Maisam Arif <maisarif@amd.com> Change-Id: Ib0d37038e49cec61d5415076a46a5666d95dcea2
This commit is contained in:
کامیت شده توسط
Galantsev, Dmitrii
والد
a6af1769b9
کامیت
e4fac177c1
@@ -1439,6 +1439,24 @@ amdsmi_get_gpu_activity(amdsmi_processor_handle processor_handle, amdsmi_engine_
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t amdsmi_is_gpu_power_management_enabled(amdsmi_processor_handle processor_handle, bool *enabled) {
|
||||
if (enabled == nullptr) {
|
||||
return AMDSMI_STATUS_INVAL;
|
||||
}
|
||||
*enabled = false;
|
||||
|
||||
amd::smi::AMDSmiGPUDevice * gpu_device = nullptr;
|
||||
amdsmi_status_t status;
|
||||
|
||||
status = get_gpu_device_from_handle(processor_handle, &gpu_device);
|
||||
if (status != AMDSMI_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
status = smi_amdgpu_is_gpu_power_management_enabled(gpu_device, enabled);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
amdsmi_status_t
|
||||
amdsmi_get_clock_info(amdsmi_processor_handle processor_handle, amdsmi_clk_type_t clk_type, amdsmi_clk_info_t *info) {
|
||||
AMDSMI_CHECK_INIT();
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -36,10 +35,10 @@
|
||||
#include <random>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <sys/ioctl.h>
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "amd_smi/impl/amd_smi_utils.h"
|
||||
@@ -499,3 +498,35 @@ amdsmi_status_t smi_amdgpu_get_market_name_from_dev_id(uint32_t device_id, char
|
||||
}
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
amdsmi_status_t smi_amdgpu_is_gpu_power_management_enabled(amd::smi::AMDSmiGPUDevice *device,
|
||||
bool *enabled) {
|
||||
if (!device->check_if_drm_is_supported()) {
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
if (enabled == nullptr) {
|
||||
return AMDSMI_STATUS_API_FAILED;
|
||||
}
|
||||
|
||||
SMIGPUDEVICE_MUTEX(device->get_mutex())
|
||||
std::string fullpath = "/sys/class/drm/" + device->get_gpu_path() + std::string("/device/pp_features");
|
||||
std::ifstream fs(fullpath.c_str());
|
||||
|
||||
if (fs.fail()) {
|
||||
return AMDSMI_STATUS_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
// ANY line must end with "enabled" and have space before it
|
||||
const std::regex regex(R"(.*\senabled$)");
|
||||
std::string line;
|
||||
while (std::getline(fs, line)) {
|
||||
// match the whole line against regex, not just substrings
|
||||
if (std::regex_match(line, regex)) {
|
||||
*enabled = true;
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
*enabled = false;
|
||||
return AMDSMI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
مرجع در شماره جدید
Block a user