Skip to content

Commit

Permalink
Reset return status when handle or function are not loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Syllo committed Mar 26, 2022
1 parent faad31e commit 6761d89
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/extract_gpuinfo_amdgpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Copyright (C) 2012 Lauri Kasanen
* Copyright (C) 2018 Genesis Cloud Ltd.
* Copyright (C) 2022 YiFei Zhu <[email protected]>
* Copyright (C) 2022 Maxime Schmitt <[email protected]>
*
* This file is part of Nvtop and adapted from radeontop.
*
Expand Down Expand Up @@ -324,7 +325,7 @@ static const char *gpuinfo_amdgpu_last_error_string(void) {
return "unknown error\n";
}
} else {
return "An unanticipated error occurred while accessing NVIDIA GPU "
return "An unanticipated error occurred while accessing AMDGPU "
"information\n";
}
}
Expand Down Expand Up @@ -544,6 +545,8 @@ static void gpuinfo_amdgpu_refresh_dynamic_info(struct gpu_info *_gpu_info) {
last_libdrm_return_status = amdgpu_query_sensor_info(
gpu_info->amdgpu_device, AMDGPU_INFO_SENSOR_GFX_SCLK,
sizeof(out32), &out32);
else
last_libdrm_return_status = 1;
if (!last_libdrm_return_status) {
dynamic_info->gpu_clock_speed = out32;
SET_VALID(gpuinfo_curr_gpu_clock_speed_valid, dynamic_info->valid);
Expand All @@ -562,6 +565,8 @@ static void gpuinfo_amdgpu_refresh_dynamic_info(struct gpu_info *_gpu_info) {
last_libdrm_return_status = amdgpu_query_sensor_info(
gpu_info->amdgpu_device, AMDGPU_INFO_SENSOR_GFX_MCLK,
sizeof(out32), &out32);
else
last_libdrm_return_status = 1;
if (!last_libdrm_return_status) {
dynamic_info->mem_clock_speed = out32;
SET_VALID(gpuinfo_curr_mem_clock_speed_valid, dynamic_info->valid);
Expand All @@ -580,6 +585,8 @@ static void gpuinfo_amdgpu_refresh_dynamic_info(struct gpu_info *_gpu_info) {
last_libdrm_return_status = amdgpu_query_sensor_info(
gpu_info->amdgpu_device, AMDGPU_INFO_SENSOR_GPU_LOAD,
sizeof(out32), &out32);
else
last_libdrm_return_status = 1;
if (!last_libdrm_return_status) {
dynamic_info->gpu_util_rate = out32;
SET_VALID(gpuinfo_gpu_util_rate_valid, dynamic_info->valid);
Expand All @@ -592,6 +599,8 @@ static void gpuinfo_amdgpu_refresh_dynamic_info(struct gpu_info *_gpu_info) {
last_libdrm_return_status = amdgpu_query_info(
gpu_info->amdgpu_device, AMDGPU_INFO_MEMORY,
sizeof(memory_info), &memory_info);
else
last_libdrm_return_status = 1;
if (!last_libdrm_return_status) {
// TODO: Determine if we want to include GTT (GPU accessible system memory)
dynamic_info->total_memory = memory_info.vram.total_heap_size;
Expand All @@ -616,6 +625,8 @@ static void gpuinfo_amdgpu_refresh_dynamic_info(struct gpu_info *_gpu_info) {
last_libdrm_return_status = amdgpu_query_sensor_info(
gpu_info->amdgpu_device, AMDGPU_INFO_SENSOR_GPU_TEMP,
sizeof(out32), &out32);
else
last_libdrm_return_status = 1;
if (!last_libdrm_return_status) {
dynamic_info->gpu_temp = out32 / 1000;
SET_VALID(gpuinfo_gpu_temp_valid, dynamic_info->valid);
Expand All @@ -630,6 +641,8 @@ static void gpuinfo_amdgpu_refresh_dynamic_info(struct gpu_info *_gpu_info) {
last_libdrm_return_status = amdgpu_query_sensor_info(
gpu_info->amdgpu_device, AMDGPU_INFO_SENSOR_GPU_AVG_POWER,
sizeof(out32), &out32);
else
last_libdrm_return_status = 1;
if (!last_libdrm_return_status) {
dynamic_info->power_draw = out32;
SET_VALID(gpuinfo_power_draw_valid, dynamic_info->valid);
Expand Down

0 comments on commit 6761d89

Please sign in to comment.