[PATCH 2/2] drm/amdgpu/navi10: add thermal sensor support for navi10

Alex Deucher alexdeucher at gmail.com
Mon Jul 8 14:49:40 UTC 2019


Ping on this series.

Alex

On Wed, Jul 3, 2019 at 10:58 PM Alex Deucher <alexdeucher at gmail.com> wrote:
>
> This was dropped when the code was refactored.  Re-add it
> for navi10.
>
> Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
> ---
>  drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 42 ++++++++++++++++++++++
>  1 file changed, 42 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> index 5794f7cef1c8..34fbc4be224c 100644
> --- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> +++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
> @@ -900,6 +900,42 @@ static int navi10_get_current_activity_percent(struct smu_context *smu,
>         return 0;
>  }
>
> +static int navi10_thermal_get_temperature(struct smu_context *smu,
> +                                         enum amd_pp_sensors sensor,
> +                                         uint32_t *value)
> +{
> +       int ret = 0;
> +       SmuMetrics_t metrics;
> +
> +       if (!value)
> +               return -EINVAL;
> +
> +       ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, (void *)&metrics,
> +                              false);
> +       if (ret)
> +               return ret;
> +
> +       switch (sensor) {
> +       case AMDGPU_PP_SENSOR_HOTSPOT_TEMP:
> +               *value = metrics.TemperatureHotspot *
> +                       SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
> +               break;
> +       case AMDGPU_PP_SENSOR_EDGE_TEMP:
> +               *value = metrics.TemperatureEdge *
> +                       SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
> +               break;
> +       case AMDGPU_PP_SENSOR_MEM_TEMP:
> +               *value = metrics.TemperatureMem *
> +                       SMU_TEMPERATURE_UNITS_PER_CENTIGRADES;
> +               break;
> +       default:
> +               pr_err("Invalid sensor for retrieving temp\n");
> +               return -EINVAL;
> +       }
> +
> +       return 0;
> +}
> +
>  static bool navi10_is_dpm_running(struct smu_context *smu)
>  {
>         int ret = 0;
> @@ -1280,6 +1316,12 @@ static int navi10_read_sensor(struct smu_context *smu,
>                 ret = navi10_get_gpu_power(smu, (uint32_t *)data);
>                 *size = 4;
>                 break;
> +       case AMDGPU_PP_SENSOR_HOTSPOT_TEMP:
> +       case AMDGPU_PP_SENSOR_EDGE_TEMP:
> +       case AMDGPU_PP_SENSOR_MEM_TEMP:
> +               ret = navi10_thermal_get_temperature(smu, sensor, (uint32_t *)data);
> +               *size = 4;
> +               break;
>         default:
>                 return -EINVAL;
>         }
> --
> 2.20.1
>


More information about the amd-gfx mailing list