[v2] drm/amd/pp: enable power limit increase in OD mode

Submitted by Deucher, Alexander on Oct. 18, 2018, 7:45 p.m.

Details

Message ID BN6PR12MB180923088C40BA77658DC6E1F7F80@BN6PR12MB1809.namprd12.prod.outlook.com
State New
Headers show
Series "drm/amd/pp: enable power limit increase in OD mode" ( rev: 3 ) in AMD X.Org drivers

Browsing this patch as part of:
"drm/amd/pp: enable power limit increase in OD mode" rev 3 in AMD X.Org drivers
<< prev patch [1/1] next patch >>

Commit Message

Deucher, Alexander Oct. 18, 2018, 7:45 p.m.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index e8964ca..586f1ff 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -963,6 +963,7 @@  static int pp_dpm_switch_power_profile(void *handle,
 static int pp_set_power_limit(void *handle, uint32_t limit)
 {
         struct pp_hwmgr *hwmgr = handle;
+       uint32_t max_power_limit;

         if (!hwmgr || !hwmgr->pm_en)
                 return -EINVAL;
@@ -975,7 +976,13 @@  static int pp_set_power_limit(void *handle, uint32_t limit)
         if (limit == 0)
                 limit = hwmgr->default_power_limit;

-       if (limit > hwmgr->default_power_limit)
+       max_power_limit = hwmgr->default_power_limit;
+       if (hwmgr->od_enabled) {
+               max_power_limit *= (100 + hwmgr->platform_descriptor.TDPODLimit);
+               max_power_limit /= 100;
+       }
+
+       if (limit > max_power_limit)
                 return -EINVAL;

         mutex_lock(&hwmgr->smu_lock);
@@ -994,8 +1001,13 @@  static int pp_get_power_limit(void *handle, uint32_t *limit, bool default_limit)

         mutex_lock(&hwmgr->smu_lock);

-       if (default_limit)
+       if (default_limit) {
                 *limit = hwmgr->default_power_limit;
+               if (hwmgr->od_enabled) {
+                       *limit *= (100 + hwmgr->platform_descriptor.TDPODLimit);
+                       *limit /= 100;
+               }
+       }
         else
                 *limit = hwmgr->power_limit;