Commit cdf4c8ec authored by Sathishkumar S's avatar Sathishkumar S Committed by Alex Deucher

drm/amd/pm: update smartshift powerboost calc for smu13

smartshift apu and dgpu power boost are reported as percentage
with respect to their power limits. adjust the units of power before
calculating the percentage of boost.
Signed-off-by: default avatarSathishkumar S <sathishkumar.sundararaju@amd.com>
Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 138292f1
...@@ -276,6 +276,42 @@ static int yellow_carp_mode2_reset(struct smu_context *smu) ...@@ -276,6 +276,42 @@ static int yellow_carp_mode2_reset(struct smu_context *smu)
return yellow_carp_mode_reset(smu, SMU_RESET_MODE_2); return yellow_carp_mode_reset(smu, SMU_RESET_MODE_2);
} }
static void yellow_carp_get_ss_power_percent(SmuMetrics_t *metrics,
uint32_t *apu_percent, uint32_t *dgpu_percent)
{
uint32_t apu_boost = 0;
uint32_t dgpu_boost = 0;
uint16_t apu_limit = 0;
uint16_t dgpu_limit = 0;
uint16_t apu_power = 0;
uint16_t dgpu_power = 0;
/* APU and dGPU power values are reported in milli Watts
* and STAPM power limits are in Watts */
apu_power = metrics->ApuPower/1000;
apu_limit = metrics->StapmOpnLimit;
if (apu_power > apu_limit && apu_limit != 0)
apu_boost = ((apu_power - apu_limit) * 100) / apu_limit;
apu_boost = (apu_boost > 100) ? 100 : apu_boost;
dgpu_power = metrics->dGpuPower/1000;
if (metrics->StapmCurrentLimit > metrics->StapmOpnLimit)
dgpu_limit = metrics->StapmCurrentLimit - metrics->StapmOpnLimit;
if (dgpu_power > dgpu_limit && dgpu_limit != 0)
dgpu_boost = ((dgpu_power - dgpu_limit) * 100) / dgpu_limit;
dgpu_boost = (dgpu_boost > 100) ? 100 : dgpu_boost;
if (dgpu_boost >= apu_boost)
apu_boost = 0;
else
dgpu_boost = 0;
*apu_percent = apu_boost;
*dgpu_percent = dgpu_boost;
}
static int yellow_carp_get_smu_metrics_data(struct smu_context *smu, static int yellow_carp_get_smu_metrics_data(struct smu_context *smu,
MetricsMember_t member, MetricsMember_t member,
uint32_t *value) uint32_t *value)
...@@ -284,6 +320,8 @@ static int yellow_carp_get_smu_metrics_data(struct smu_context *smu, ...@@ -284,6 +320,8 @@ static int yellow_carp_get_smu_metrics_data(struct smu_context *smu,
SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table; SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;
int ret = 0; int ret = 0;
uint32_t apu_percent = 0;
uint32_t dgpu_percent = 0;
ret = smu_cmn_get_metrics_table(smu, NULL, false); ret = smu_cmn_get_metrics_table(smu, NULL, false);
if (ret) if (ret)
...@@ -332,26 +370,18 @@ static int yellow_carp_get_smu_metrics_data(struct smu_context *smu, ...@@ -332,26 +370,18 @@ static int yellow_carp_get_smu_metrics_data(struct smu_context *smu,
*value = metrics->Voltage[1]; *value = metrics->Voltage[1];
break; break;
case METRICS_SS_APU_SHARE: case METRICS_SS_APU_SHARE:
/* return the percentage of APU power with respect to APU's power limit. /* return the percentage of APU power boost
* percentage is reported, this isn't boost value. Smartshift power * with respect to APU's power limit.
* boost/shift is only when the percentage is more than 100.
*/ */
if (metrics->StapmOpnLimit > 0) yellow_carp_get_ss_power_percent(metrics, &apu_percent, &dgpu_percent);
*value = (metrics->ApuPower * 100) / metrics->StapmOpnLimit; *value = apu_percent;
else
*value = 0;
break; break;
case METRICS_SS_DGPU_SHARE: case METRICS_SS_DGPU_SHARE:
/* return the percentage of dGPU power with respect to dGPU's power limit. /* return the percentage of dGPU power boost
* percentage is reported, this isn't boost value. Smartshift power * with respect to dGPU's power limit.
* boost/shift is only when the percentage is more than 100.
*/ */
if ((metrics->dGpuPower > 0) && yellow_carp_get_ss_power_percent(metrics, &apu_percent, &dgpu_percent);
(metrics->StapmCurrentLimit > metrics->StapmOpnLimit)) *value = dgpu_percent;
*value = (metrics->dGpuPower * 100) /
(metrics->StapmCurrentLimit - metrics->StapmOpnLimit);
else
*value = 0;
break; break;
default: default:
*value = UINT_MAX; *value = UINT_MAX;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment