drm/powerplay: Fix Vega20 Average Power value v4

Submitted by Wang, Kevin(Yang) on Aug. 22, 2019, 2:04 p.m.

Details

Message ID MN2PR12MB3296EBE6F789A24DFEC8664CA2A50@MN2PR12MB3296.namprd12.prod.outlook.com
State New
Headers show
Series "drm/powerplay: Fix Vega20 Average Power value" ( rev: 5 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Wang, Kevin(Yang) Aug. 22, 2019, 2:04 p.m.
Reviewed-by: Kevin Wang <kevin1.wang@amd.com>

Best Regards,
Kevin

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
index 0516c294b377..9f50a12f5c03 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega20_hwmgr.c
@@ -2101,7 +2101,10 @@  static int vega20_get_gpu_power(struct pp_hwmgr *hwmgr,
         if (ret)
                 return ret;

-       *query = metrics_table.CurrSocketPower << 8;
+       if (hwmgr->smu_version < 0x282e00)
+               *query = metrics_table.CurrSocketPower << 8;
+       else
+               *query = metrics_table.AverageSocketPower << 8;

         return ret;
 }
diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
index e14363182691..0fac824490d7 100644
--- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
@@ -2917,6 +2917,7 @@  static int vega20_get_fan_speed_percent(struct smu_context *smu,

 static int vega20_get_gpu_power(struct smu_context *smu, uint32_t *value)
 {
+       uint32_t smu_version;
         int ret = 0;
         SmuMetrics_t metrics;

@@ -2927,7 +2928,14 @@  static int vega20_get_gpu_power(struct smu_context *smu, uint32_t *value)
         if (ret)
                 return ret;

-       *value = metrics.CurrSocketPower << 8;
+       ret = smu_get_smc_version(smu, NULL, &smu_version);
+       if (ret)
+               return ret;
+
+       if (smu_version < 0x282e00)
+               *value = metrics.CurrSocketPower << 8;
+       else
+               *value = metrics.AverageSocketPower << 8;

         return 0;
 }