Commit 2c272452 authored by Kevin Wang's avatar Kevin Wang Committed by Alex Deucher

drm/amd/powerplay: implement sensor of get_gpu_power for smu11

add sensor interface of get gpu power for debugfs and hwmon.
Signed-off-by: default avatarKevin Wang <Kevin1.Wang@amd.com>
Reviewed-by: default avatarHuang Rui <ray.huang@amd.com>
Reviewed-by: default avatarEvan Quan <evan.quan@amd.com>
Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 2f613c70
...@@ -1032,6 +1032,23 @@ static int smu_v11_0_thermal_get_temperature(struct smu_context *smu, uint32_t * ...@@ -1032,6 +1032,23 @@ static int smu_v11_0_thermal_get_temperature(struct smu_context *smu, uint32_t *
return 0; return 0;
} }
static int smu_v11_0_get_gpu_power(struct smu_context *smu, uint32_t *value)
{
int ret = 0;
SmuMetrics_t metrics;
if (!value)
return -EINVAL;
ret = smu_update_table(smu, TABLE_SMU_METRICS, (void *)&metrics, false);
if (ret)
return ret;
*value = metrics.CurrSocketPower << 8;
return 0;
}
static int smu_v11_0_read_sensor(struct smu_context *smu, static int smu_v11_0_read_sensor(struct smu_context *smu,
enum amd_pp_sensors sensor, enum amd_pp_sensors sensor,
void *data, uint32_t *size) void *data, uint32_t *size)
...@@ -1055,6 +1072,10 @@ static int smu_v11_0_read_sensor(struct smu_context *smu, ...@@ -1055,6 +1072,10 @@ static int smu_v11_0_read_sensor(struct smu_context *smu,
ret = smu_v11_0_thermal_get_temperature(smu, (uint32_t *)data); ret = smu_v11_0_thermal_get_temperature(smu, (uint32_t *)data);
*size = 4; *size = 4;
break; break;
case AMDGPU_PP_SENSOR_GPU_POWER:
ret = smu_v11_0_get_gpu_power(smu, (uint32_t *)data);
*size = 4;
break;
default: default:
ret = -EINVAL; ret = -EINVAL;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment