drm/amd/powerplay: expose Vega20 realtime memory utilization
authorEvan Quan <evan.quan@amd.com>
Fri, 19 Apr 2019 05:54:46 +0000 (13:54 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 24 May 2019 17:20:48 +0000 (12:20 -0500)
Enable realtime memory utilization report on Vega20.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/include/kgd_pp_interface.h
drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c

index 30788d510576ba9e27ff06c357aecf7114d8ea14..9f661bf96ed0344b20c47d30fb874e2c229ff289 100644 (file)
@@ -109,6 +109,7 @@ enum amd_pp_sensors {
        AMDGPU_PP_SENSOR_UVD_DCLK,
        AMDGPU_PP_SENSOR_VCE_ECCLK,
        AMDGPU_PP_SENSOR_GPU_LOAD,
+       AMDGPU_PP_SENSOR_MEM_LOAD,
        AMDGPU_PP_SENSOR_GFX_MCLK,
        AMDGPU_PP_SENSOR_GPU_TEMP,
        AMDGPU_PP_SENSOR_EDGE_TEMP = AMDGPU_PP_SENSOR_GPU_TEMP,
index 91e26f8b3758493cebfe7c48dff164c9a857357a..eb7002401587dff8ce45ac248908e1be3ff514c5 100644 (file)
@@ -2094,6 +2094,7 @@ static int vega20_get_current_clk_freq(struct pp_hwmgr *hwmgr,
 }
 
 static int vega20_get_current_activity_percent(struct pp_hwmgr *hwmgr,
+               int idx,
                uint32_t *activity_percent)
 {
        int ret = 0;
@@ -2103,7 +2104,17 @@ static int vega20_get_current_activity_percent(struct pp_hwmgr *hwmgr,
        if (ret)
                return ret;
 
-       *activity_percent = metrics_table.AverageGfxActivity;
+       switch (idx) {
+       case AMDGPU_PP_SENSOR_GPU_LOAD:
+               *activity_percent = metrics_table.AverageGfxActivity;
+               break;
+       case AMDGPU_PP_SENSOR_MEM_LOAD:
+               *activity_percent = metrics_table.AverageUclkActivity;
+               break;
+       default:
+               pr_err("Invalid index for retrieving clock activity\n");
+               return -EINVAL;
+       }
 
        return ret;
 }
@@ -2134,7 +2145,8 @@ static int vega20_read_sensor(struct pp_hwmgr *hwmgr, int idx,
                        *size = 4;
                break;
        case AMDGPU_PP_SENSOR_GPU_LOAD:
-               ret = vega20_get_current_activity_percent(hwmgr, (uint32_t *)value);
+       case AMDGPU_PP_SENSOR_MEM_LOAD:
+               ret = vega20_get_current_activity_percent(hwmgr, idx, (uint32_t *)value);
                if (!ret)
                        *size = 4;
                break;