[AMD Official Use Only - Internal Distribution Only] Series is reviewed-by: Evan Quan <evan.quan@xxxxxxx> -----Original Message----- From: amd-gfx <amd-gfx-bounces@xxxxxxxxxxxxxxxxxxxxx> On Behalf Of Alex Deucher Sent: Wednesday, December 2, 2020 2:43 AM To: amd-gfx@xxxxxxxxxxxxxxxxxxxxx Cc: Deucher, Alexander <Alexander.Deucher@xxxxxxx> Subject: [PATCH 3/3] drm/amdgpu/swsmu/sienna_cichlid: simplify sensor handling Just query the metrics table directly rather than going through an extra level of functions. Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx> --- .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 98 +++++-------------- 1 file changed, 24 insertions(+), 74 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c index 21c5ea3a4a63..db0f2a476c23 100644 --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c @@ -1119,44 +1119,6 @@ static int sienna_cichlid_display_config_changed(struct smu_context *smu) return ret; } -static int sienna_cichlid_get_gpu_power(struct smu_context *smu, uint32_t *value) -{ -if (!value) -return -EINVAL; - -return sienna_cichlid_get_smu_metrics_data(smu, - METRICS_AVERAGE_SOCKETPOWER, - value); -} - -static int sienna_cichlid_get_current_activity_percent(struct smu_context *smu, - enum amd_pp_sensors sensor, - uint32_t *value) -{ -int ret = 0; - -if (!value) -return -EINVAL; - -switch (sensor) { -case AMDGPU_PP_SENSOR_GPU_LOAD: -ret = sienna_cichlid_get_smu_metrics_data(smu, - METRICS_AVERAGE_GFXACTIVITY, - value); -break; -case AMDGPU_PP_SENSOR_MEM_LOAD: -ret = sienna_cichlid_get_smu_metrics_data(smu, - METRICS_AVERAGE_MEMACTIVITY, - value); -break; -default: -dev_err(smu->adev->dev, "Invalid sensor for retrieving clock activity\n"); -return -EINVAL; -} - -return ret; -} - static bool sienna_cichlid_is_dpm_running(struct smu_context *smu) { int ret = 0; @@ -1468,39 +1430,6 @@ static int sienna_cichlid_set_watermarks_table(struct smu_context *smu, return 0; } -static int sienna_cichlid_thermal_get_temperature(struct smu_context *smu, - enum amd_pp_sensors sensor, - uint32_t *value) -{ -int ret = 0; - -if (!value) -return -EINVAL; - -switch (sensor) { -case AMDGPU_PP_SENSOR_HOTSPOT_TEMP: -ret = sienna_cichlid_get_smu_metrics_data(smu, - METRICS_TEMPERATURE_HOTSPOT, - value); -break; -case AMDGPU_PP_SENSOR_EDGE_TEMP: -ret = sienna_cichlid_get_smu_metrics_data(smu, - METRICS_TEMPERATURE_EDGE, - value); -break; -case AMDGPU_PP_SENSOR_MEM_TEMP: -ret = sienna_cichlid_get_smu_metrics_data(smu, - METRICS_TEMPERATURE_MEM, - value); -break; -default: -dev_err(smu->adev->dev, "Invalid sensor for retrieving temp\n"); -return -EINVAL; -} - -return ret; -} - static int sienna_cichlid_read_sensor(struct smu_context *smu, enum amd_pp_sensors sensor, void *data, uint32_t *size) @@ -1519,18 +1448,39 @@ static int sienna_cichlid_read_sensor(struct smu_context *smu, *size = 4; break; case AMDGPU_PP_SENSOR_MEM_LOAD: +ret = sienna_cichlid_get_smu_metrics_data(smu, + METRICS_AVERAGE_MEMACTIVITY, + (uint32_t *)data); +*size = 4; +break; case AMDGPU_PP_SENSOR_GPU_LOAD: -ret = sienna_cichlid_get_current_activity_percent(smu, sensor, (uint32_t *)data); +ret = sienna_cichlid_get_smu_metrics_data(smu, + METRICS_AVERAGE_GFXACTIVITY, + (uint32_t *)data); *size = 4; break; case AMDGPU_PP_SENSOR_GPU_POWER: -ret = sienna_cichlid_get_gpu_power(smu, (uint32_t *)data); +ret = sienna_cichlid_get_smu_metrics_data(smu, + METRICS_AVERAGE_SOCKETPOWER, + (uint32_t *)data); *size = 4; break; case AMDGPU_PP_SENSOR_HOTSPOT_TEMP: +ret = sienna_cichlid_get_smu_metrics_data(smu, + METRICS_TEMPERATURE_HOTSPOT, + (uint32_t *)data); +*size = 4; +break; case AMDGPU_PP_SENSOR_EDGE_TEMP: +ret = sienna_cichlid_get_smu_metrics_data(smu, + METRICS_TEMPERATURE_EDGE, + (uint32_t *)data); +*size = 4; +break; case AMDGPU_PP_SENSOR_MEM_TEMP: -ret = sienna_cichlid_thermal_get_temperature(smu, sensor, (uint32_t *)data); +ret = sienna_cichlid_get_smu_metrics_data(smu, + METRICS_TEMPERATURE_MEM, + (uint32_t *)data); *size = 4; break; case AMDGPU_PP_SENSOR_GFX_MCLK: -- 2.25.4 _______________________________________________ amd-gfx mailing list amd-gfx@xxxxxxxxxxxxxxxxxxxxx https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7Cevan.quan%40amd.com%7Ce93414ccd35e4357db7908d89629003d%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637424450123752767%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=QU9nHZZgdnnkBHOCENfXMjGKBXgmr%2BaDv6QiKG95PdA%3D&reserved=0 _______________________________________________ amd-gfx mailing list amd-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/amd-gfx