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

Submitted by Greathouse, Joseph on Oct. 10, 2018, 11:25 p.m.

Details

Message ID 1539213914-3487-1-git-send-email-Joseph.Greathouse@amd.com
State New
Headers show
Series "drm/amd/pp: enable power limit increase in OD mode" ( rev: 1 ) in AMD X.Org drivers

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

Commit Message

Greathouse, Joseph Oct. 10, 2018, 11:25 p.m.
OverDrive mode allows users to increase the maximum SCLK and MCLK
frequencies beyond the default on the GPU. However, this may not
results in large performance gains if the GPU then runs into its TDP
power limit. This patch adds the capability to increase the power
limit of a GPU above its default maximum.

This is only allowed when overdrive is enabled in the ppfeaturemask,
since this is an overdrive feature. The TDPODLimit value from the
VBIOS describes how how much higher the TDP should be allowed to go
over its default, in percentage.

Signed-off-by: Joseph Greathouse <Joseph.Greathouse@amd.com>
---
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

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 75b56ae..5b0b6b6 100644
--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
+++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
@@ -958,6 +958,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 = hwmgr->default_power_limit;
 
 	if (!hwmgr || !hwmgr->pm_en)
 		return -EINVAL;
@@ -970,7 +971,12 @@  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)
+	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);
@@ -989,8 +995,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;
 

Comments

On Wed, Oct 10, 2018 at 7:25 PM Greathouse, Joseph
<Joseph.Greathouse@amd.com> wrote:
>
> OverDrive mode allows users to increase the maximum SCLK and MCLK
> frequencies beyond the default on the GPU. However, this may not
> results in large performance gains if the GPU then runs into its TDP
> power limit. This patch adds the capability to increase the power
> limit of a GPU above its default maximum.
>
> This is only allowed when overdrive is enabled in the ppfeaturemask,
> since this is an overdrive feature. The TDPODLimit value from the
> VBIOS describes how how much higher the TDP should be allowed to go
> over its default, in percentage.
>
> Signed-off-by: Joseph Greathouse <Joseph.Greathouse@amd.com>

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
> index 75b56ae..5b0b6b6 100644
> --- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
> +++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
> @@ -958,6 +958,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 = hwmgr->default_power_limit;
>
>         if (!hwmgr || !hwmgr->pm_en)
>                 return -EINVAL;
> @@ -970,7 +971,12 @@ 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)
> +       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);
> @@ -989,8 +995,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;
>
> --
> 2.7.4
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx