SWDEV-492272 [AMDSMI] Build/Compiler warnings messages

Fix compiler warnings

Signed-off-by: Joe Narlo <Joseph.Narlo@amd.com>
Change-Id: I10657b8f3ef18a9b45311e8f6509958297a57823


[ROCm/amdsmi commit: d0a7332d32]
This commit is contained in:
Joe Narlo
2024-11-19 08:13:18 -06:00
committed by Gabriel Pham
parent d71dac9766
commit 68497c68e9
31 changed files with 164 additions and 225 deletions
+21 -20
View File
@@ -1020,8 +1020,9 @@ amdsmi_get_gpu_asic_info(amdsmi_processor_handle processor_handle, amdsmi_asic_i
// If vendor name is empty and the vendor id is 0x1002, set vendor name to AMD vendor string
if ((info->vendor_name != NULL && info->vendor_name[0] == '\0') && info->vendor_id == 0x1002) {
memset(info->vendor_name, 0, 38);
strncpy(info->vendor_name, "Advanced Micro Devices Inc. [AMD/ATI]", 37);
std::string amd_name = "Advanced Micro Devices Inc. [AMD/ATI]";
memset(info->vendor_name, 0, amd_name.size()+1);
strncpy(info->vendor_name, amd_name.c_str(), amd_name.size()+1);
}
// default to 0xffff as not supported
@@ -1506,7 +1507,6 @@ amdsmi_get_gpu_accelerator_partition_profile(amdsmi_processor_handle processor_h
// TODO(amdsmi_team): add resources here ^
auto tmp_partition_id = uint32_t(0);
auto tmp_xcd_count = uint16_t(0);
amdsmi_status_t status = AMDSMI_STATUS_NOT_SUPPORTED;
status = rsmi_wrapper(rsmi_dev_partition_id_get, processor_handle, &tmp_partition_id);
@@ -2196,7 +2196,7 @@ amdsmi_get_clock_info(amdsmi_processor_handle processor_handle, amdsmi_clk_type_
}
info->max_clk = max_freq;
info->min_clk = min_freq;
info->clk_deep_sleep = sleep_state_freq;
info->clk_deep_sleep = static_cast<uint8_t>(sleep_state_freq);
switch (clk_type) {
case AMDSMI_CLK_TYPE_GFX:
@@ -2493,7 +2493,6 @@ amdsmi_get_gpu_device_uuid(amdsmi_processor_handle processor_handle, unsigned in
amdsmi_status_t status = AMDSMI_STATUS_SUCCESS;
SMIGPUDEVICE_MUTEX(gpu_device->get_mutex())
size_t len = AMDSMI_GPU_UUID_SIZE;
amdsmi_asic_info_t asic_info = {};
const uint8_t fcn = 0xff;
@@ -2556,7 +2555,7 @@ amdsmi_status_t amdsmi_get_pcie_info(amdsmi_processor_handle processor_handle, a
}
// pcie speed in sysfs returns in GT/s
info->pcie_static.max_pcie_speed = pcie_speed * 1000;
info->pcie_static.max_pcie_speed = static_cast<uint32_t>(pcie_speed * 1000);
switch (info->pcie_static.max_pcie_speed) {
case 2500:
@@ -2722,8 +2721,6 @@ amdsmi_get_link_topology_nearest(amdsmi_processor_handle processor_handle,
auto status(amdsmi_status_t::AMDSMI_STATUS_SUCCESS);
constexpr auto kKFD_CRAT_INTRA_SOCKET_WEIGHT = uint32_t(13);
constexpr auto kKFD_CRAT_XGMI_WEIGHT = uint32_t(15);
/*
* Note: This will need to be eventually consolidated within a unique link type.
@@ -2766,7 +2763,6 @@ amdsmi_get_link_topology_nearest(amdsmi_processor_handle processor_handle,
uint64_t link_weight;
};
using LinkTopogyOrderPair_t = std::pair<uint64_t, uint64_t>;
/*
* Note: The link topology table is sorted by the number of hops and link weight.
*/
@@ -2822,7 +2818,6 @@ amdsmi_get_link_topology_nearest(amdsmi_processor_handle processor_handle,
// Link type matches what we are searching for?
auto io_link_type = translated_link_type(link_type);
auto io_link_type_bck(io_link_type);
auto num_hops = uint64_t(0);
if (auto api_status = amdsmi_topo_get_link_type(processor_handle, device_list[device_idx], &num_hops, &io_link_type);
(api_status != amdsmi_status_t::AMDSMI_STATUS_SUCCESS) || (translated_io_link_type(io_link_type) != link_type)) {
@@ -2853,7 +2848,7 @@ amdsmi_get_link_topology_nearest(amdsmi_processor_handle processor_handle,
* Note: The link topology table is sorted by the number of hops and link weight.
*/
topology_nearest_info->processor_list[AMDSMI_MAX_DEVICES] = {nullptr};
topology_nearest_info->count = link_topology_order.size();
topology_nearest_info->count = static_cast<uint32_t>(link_topology_order.size());
auto topology_nearest_counter = uint32_t(0);
while (!link_topology_order.empty()) {
auto link_info = link_topology_order.top();
@@ -3959,13 +3954,15 @@ amdsmi_status_t amdsmi_get_cpu_handles(uint32_t *cpu_count,
}
// Get the cpu count
*cpu_count = cpu_handles.size();
if (processor_handles == nullptr)
*cpu_count = static_cast<uint32_t>(cpu_handles.size());
if (processor_handles == nullptr) {
return AMDSMI_STATUS_SUCCESS;
}
// Copy the cpu socket handles
for (uint32_t i = 0; i < *cpu_count; i++)
for (uint32_t i = 0; i < *cpu_count; i++) {
processor_handles[i] = reinterpret_cast<amdsmi_processor_handle>(cpu_handles[i]);
}
return status;
}
@@ -4008,28 +4005,32 @@ amdsmi_status_t amdsmi_get_cpucore_handles(uint32_t *cores_count,
// Get the coress for each socket
status = amdsmi_get_processor_handles_by_type(sockets[index], processor_type,
&plist[0], &cores_per_soc);
if (status != AMDSMI_STATUS_SUCCESS)
if (status != AMDSMI_STATUS_SUCCESS) {
return status;
}
core_handles.insert(core_handles.end(), plist.begin(), plist.end());
}
// Get the cores count
*cores_count = core_handles.size();
if (processor_handles == nullptr)
*cores_count = static_cast<uint32_t>(core_handles.size());
if (processor_handles == nullptr) {
return AMDSMI_STATUS_SUCCESS;
}
// Copy the core handles
for (uint32_t i = 0; i < *cores_count; i++)
for (uint32_t i = 0; i < *cores_count; i++) {
processor_handles[i] = reinterpret_cast<amdsmi_processor_handle>(core_handles[i]);
}
return status;
}
amdsmi_status_t amdsmi_get_esmi_err_msg(amdsmi_status_t status, const char **status_string)
{
for (auto& iter : amd::smi::esmi_status_map) {
if (iter.first == status) {
for (const auto& iter : amd::smi::esmi_status_map) {
const amdsmi_status_t _status = status;
if (static_cast<int>(iter.first) == static_cast<int>(_status)) {
*status_string = esmi_get_err_msg(static_cast<esmi_status_t>(iter.first));
return iter.second;
}
+5 -2
View File
@@ -41,6 +41,8 @@ namespace smi {
std::string AMDSmiDrm::find_file_in_folder(const std::string& folder,
const std::string& regex) {
std::string file_name;
// TODO: The closedir function has some non-standard attributes that are being ignored here
// which is causing a warning to be thrown
using dir_ptr = std::unique_ptr<DIR, decltype(&closedir)>;
struct dirent *dir = nullptr;
@@ -64,7 +66,6 @@ amdsmi_status_t AMDSmiDrm::init() {
// using drm_device_ptr = std::unique_ptr(drmDevicePtr,
// decltype(&drmFreeDevice));
struct dirent *dir = nullptr;
int fd = -1;
@@ -162,7 +163,7 @@ amdsmi_status_t AMDSmiDrm::init() {
<< "bdf_rocm | Received bdf: "
<< "\nWhole BDF: " << amd::smi::print_unsigned_hex_and_int(bdf_rocm)
<< "\nDomain = "
<< amd::smi::print_unsigned_hex_and_int((bdf_rocm & 0xFFFFFFFF00000000) >> 32)
<< amd::smi::print_unsigned_hex_and_int((bdf_rocm & static_cast<uint64_t>(0xFFFFFFFF00000000)) >> 32)
<< "; \nBus# = " << amd::smi::print_unsigned_hex_and_int((bdf_rocm & 0xFF00) >> 8)
<< "; \nDevice# = "<< amd::smi::print_unsigned_hex_and_int((bdf_rocm & 0xF8) >> 3)
<< "; \nFunction# = " << amd::smi::print_unsigned_hex_and_int((bdf_rocm & 0x7));
@@ -170,6 +171,8 @@ amdsmi_status_t AMDSmiDrm::init() {
bdf.function_number = ((bdf_rocm & 0x7));
bdf.device_number = ((bdf_rocm & 0xF8) >> 3);
bdf.bus_number = ((bdf_rocm & 0xFF00) >> 8);
// TODO: This is throwing a compiler warning since bdf.domain_number is part of a struct
// and is 48 bits long and throws a conversion warning
bdf.domain_number = ((bdf_rocm & 0xFFFFFFFF00000000) >> 32);
ss << __PRETTY_FUNCTION__ << " | " << "Received bdf: Domain = " << bdf.domain_number
<< "; Bus# = " << bdf.bus_number << "; Device# = "<< bdf.device_number
@@ -229,11 +229,15 @@ amdsmi_status_t AMDSmiSystem::get_gpu_socket_id(uint32_t index,
*/
uint64_t domain = (bdfid >> 32) & 0xffffffff;
/* May need later
// may need to identify with partition_id in the future as well... TBD
uint64_t partition_id = (bdfid >> 28) & 0xf;
*/
uint64_t bus = (bdfid >> 8) & 0xff;
uint64_t device_id = (bdfid >> 3) & 0x1f;
/* May need later
uint64_t function = bdfid & 0x7;
*/
// The BD part of the BDF is used as the socket id as it
// represents a physical device.
+2 -1
View File
@@ -527,7 +527,7 @@ amdsmi_status_t smi_amdgpu_get_driver_version(amd::smi::AMDSmiGPUDevice* device,
fclose(fp);
if (length) {
*length = version[len-1] == '\n' ? len - 1 : len;
*length = version[len-1] == '\n' ? static_cast<int>(len - 1) : static_cast<int>(len);
}
version[len-1] = version[len-1] == '\n' ? '\0' : version[len-1];
}
@@ -647,6 +647,7 @@ std::string smi_amdgpu_split_string(std::string str, char delim) {
tokens.push_back(token);
return token; // return 1st match
}
return "";
}
// wrapper to return string expression of a rsmi_status_t return
+12 -12
View File
@@ -22,6 +22,7 @@
#include <sys/types.h>
#include <dirent.h>
#include <inttypes.h>
#include <unistd.h>
#include <memory>
#include <vector>
@@ -75,11 +76,11 @@ amdsmi_status_t gpuvsmi_get_pids(const amdsmi_bdf_t &bdf, std::vector<long int>
struct dirent *dir;
/* 0000:00:00.0 */
snprintf(bdf_str, 13, "%04x:%02x:%02x.%d",
bdf.domain_number & 0xffff,
bdf.bus_number & 0xff,
bdf.device_number & 0x1f,
bdf.function_number & 0x7);
snprintf(bdf_str, 13, "%04" PRIx32 ":%02" PRIx32 ":%02" PRIx32 ".%" PRIu32,
static_cast<uint32_t>(bdf.domain_number & 0xffff),
static_cast<uint32_t>(bdf.bus_number & 0xff),
static_cast<uint32_t>(bdf.device_number & 0x1f),
static_cast<uint32_t>(bdf.function_number & 0x7));
d = opendir("/proc");
if (!d)
@@ -124,12 +125,11 @@ amdsmi_status_t gpuvsmi_get_pid_info(const amdsmi_bdf_t &bdf, long int pid,
struct dirent *dir;
/* 0000:00:00.0 */
snprintf(bdf_str, 13, "%04x:%02x:%02x.%d",
bdf.domain_number & 0xffff,
bdf.bus_number & 0xff,
bdf.device_number & 0x1f,
bdf.function_number & 0x7);
snprintf(bdf_str, 13, "%04" PRIx32 ":%02" PRIx32 ":%02" PRIx32 ".%" PRIu32,
static_cast<uint32_t>(bdf.domain_number & 0xffff),
static_cast<uint32_t>(bdf.bus_number & 0xff),
static_cast<uint32_t>(bdf.device_number & 0x1f),
static_cast<uint32_t>(bdf.function_number & 0x7));
std::string path = "/proc/" + std::to_string(pid) + "/fdinfo/";
std::string name_path = "/proc/" + std::to_string(pid) + "/comm";
@@ -158,7 +158,7 @@ amdsmi_status_t gpuvsmi_get_pid_info(const amdsmi_bdf_t &bdf, long int pid,
char fd_bdf_str[13];
/* Only check against fdinfo files that contain a bdf */
if (sscanf(bdfline.c_str(), "drm-pdev: %s", &fd_bdf_str) != 1)
if (sscanf(bdfline.c_str(), "drm-pdev: %s", &fd_bdf_str[0]) != 1)
continue;
/* Populate amdsmi_proc_info_t struct only if the bdf in