Skip to content

Commit 79e25cd

Browse files
committed
drm/amdgpu/swm14: Update power limit logic
Take into account the limits from the vbios. Ported from the SMU13 code. Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4352 Reviewed-by: Jesse Zhang <Jesse.Zhang@amd.com> Reviewed-by: Kenneth Feng <kenneth.feng@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit 203cc7f) Cc: stable@vger.kernel.org
1 parent 0aa8664 commit 79e25cd

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,9 +1697,11 @@ static int smu_v14_0_2_get_power_limit(struct smu_context *smu,
16971697
uint32_t *min_power_limit)
16981698
{
16991699
struct smu_table_context *table_context = &smu->smu_table;
1700+
struct smu_14_0_2_powerplay_table *powerplay_table =
1701+
table_context->power_play_table;
17001702
PPTable_t *pptable = table_context->driver_pptable;
17011703
CustomSkuTable_t *skutable = &pptable->CustomSkuTable;
1702-
uint32_t power_limit;
1704+
uint32_t power_limit, od_percent_upper = 0, od_percent_lower = 0;
17031705
uint32_t msg_limit = pptable->SkuTable.MsgLimits.Power[PPT_THROTTLER_PPT0][POWER_SOURCE_AC];
17041706

17051707
if (smu_v14_0_get_current_power_limit(smu, &power_limit))
@@ -1712,11 +1714,29 @@ static int smu_v14_0_2_get_power_limit(struct smu_context *smu,
17121714
if (default_power_limit)
17131715
*default_power_limit = power_limit;
17141716

1715-
if (max_power_limit)
1716-
*max_power_limit = msg_limit;
1717+
if (powerplay_table) {
1718+
if (smu->od_enabled &&
1719+
smu_v14_0_2_is_od_feature_supported(smu, PP_OD_FEATURE_PPT_BIT)) {
1720+
od_percent_upper = pptable->SkuTable.OverDriveLimitsBasicMax.Ppt;
1721+
od_percent_lower = pptable->SkuTable.OverDriveLimitsBasicMin.Ppt;
1722+
} else if (smu_v14_0_2_is_od_feature_supported(smu, PP_OD_FEATURE_PPT_BIT)) {
1723+
od_percent_upper = 0;
1724+
od_percent_lower = pptable->SkuTable.OverDriveLimitsBasicMin.Ppt;
1725+
}
1726+
}
1727+
1728+
dev_dbg(smu->adev->dev, "od percent upper:%d, od percent lower:%d (default power: %d)\n",
1729+
od_percent_upper, od_percent_lower, power_limit);
1730+
1731+
if (max_power_limit) {
1732+
*max_power_limit = msg_limit * (100 + od_percent_upper);
1733+
*max_power_limit /= 100;
1734+
}
17171735

1718-
if (min_power_limit)
1719-
*min_power_limit = 0;
1736+
if (min_power_limit) {
1737+
*min_power_limit = power_limit * (100 + od_percent_lower);
1738+
*min_power_limit /= 100;
1739+
}
17201740

17211741
return 0;
17221742
}

0 commit comments

Comments
 (0)