]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/amd/powerplay: implement sensor of get_gpu_power for smu11
authorKevin Wang <Kevin1.Wang@amd.com>
Wed, 16 Jan 2019 05:27:52 +0000 (13:27 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 19 Mar 2019 20:03:58 +0000 (15:03 -0500)
add sensor interface of get gpu power for debugfs and hwmon.

Signed-off-by: Kevin Wang <Kevin1.Wang@amd.com>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Evan Quan <evan.quan@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/powerplay/smu_v11_0.c

index d84593abbb5e7c934f8b3ac0c9f932e3d4255b7f..e27ae9c63ff878d9b9ee61b49f3e6015e11ee8cb 100644 (file)
@@ -1032,6 +1032,23 @@ static int smu_v11_0_thermal_get_temperature(struct smu_context *smu, uint32_t *
        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,
                                 enum amd_pp_sensors sensor,
                                 void *data, uint32_t *size)
@@ -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);
                *size = 4;
                break;
+       case AMDGPU_PP_SENSOR_GPU_POWER:
+               ret = smu_v11_0_get_gpu_power(smu, (uint32_t *)data);
+               *size = 4;
+               break;
        default:
                ret = -EINVAL;
                break;