All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/pm: update smartshift powerboost calc for smu12
@ 2022-05-11 10:57 Sathishkumar S
  2022-05-11 12:00 ` Lazar, Lijo
  0 siblings, 1 reply; 2+ messages in thread
From: Sathishkumar S @ 2022-05-11 10:57 UTC (permalink / raw)
  To: amd-gfx; +Cc: Alexander Deucher, Sathishkumar S, Lazar Lijo

smartshift apu and dgpu power boost are reported as percentage with
respect to their power limits. This value[0-100] reflects the boost
for the respective device.

Signed-off-by: Sathishkumar S <sathishkumar.sundararaju@amd.com>
---
 .../gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c   | 60 ++++++++++++++-----
 1 file changed, 44 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c
index fd6c44ece168..012e3bd99cc2 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c
@@ -1119,6 +1119,39 @@ static int renoir_get_power_profile_mode(struct smu_context *smu,
 	return size;
 }
 
+static void renoir_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_power = metrics->ApuPower;
+	apu_limit = metrics->StapmOriginalLimit;
+	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;
+	if (metrics->StapmCurrentLimit > metrics->StapmOriginalLimit)
+		dgpu_limit = metrics->StapmCurrentLimit - metrics->StapmOriginalLimit;
+	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 renoir_get_smu_metrics_data(struct smu_context *smu,
 				       MetricsMember_t member,
 				       uint32_t *value)
@@ -1127,6 +1160,9 @@ static int renoir_get_smu_metrics_data(struct smu_context *smu,
 
 	SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;
 	int ret = 0;
+	uint32_t apu_percent = 0;
+	uint32_t dgpu_percent = 0;
+
 
 	ret = smu_cmn_get_metrics_table(smu,
 					NULL,
@@ -1171,26 +1207,18 @@ static int renoir_get_smu_metrics_data(struct smu_context *smu,
 		*value = metrics->Voltage[1];
 		break;
 	case METRICS_SS_APU_SHARE:
-		/* return the percentage of APU power with respect to APU's power limit.
-		 * percentage is reported, this isn't boost value. Smartshift power
-		 * boost/shift is only when the percentage is more than 100.
+		/* return the percentage of APU power boost
+		 * with respect to APU's power limit.
 		 */
-		if (metrics->StapmOriginalLimit > 0)
-			*value =  (metrics->ApuPower * 100) / metrics->StapmOriginalLimit;
-		else
-			*value = 0;
+		renoir_get_ss_power_percent(metrics, &apu_percent, &dgpu_percent);
+		*value = apu_percent;
 		break;
 	case METRICS_SS_DGPU_SHARE:
-		/* return the percentage of dGPU power with respect to dGPU's power limit.
-		 * percentage is reported, this isn't boost value. Smartshift power
-		 * boost/shift is only when the percentage is more than 100.
+		/* return the percentage of dGPU power boost
+		 * with respect to dGPU's power limit.
 		 */
-		if ((metrics->dGpuPower > 0) &&
-		    (metrics->StapmCurrentLimit > metrics->StapmOriginalLimit))
-			*value = (metrics->dGpuPower * 100) /
-				  (metrics->StapmCurrentLimit - metrics->StapmOriginalLimit);
-		else
-			*value = 0;
+		renoir_get_ss_power_percent(metrics, &apu_percent, &dgpu_percent);
+		*value = dgpu_percent;
 		break;
 	default:
 		*value = UINT_MAX;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/amd/pm: update smartshift powerboost calc for smu12
  2022-05-11 10:57 [PATCH] drm/amd/pm: update smartshift powerboost calc for smu12 Sathishkumar S
@ 2022-05-11 12:00 ` Lazar, Lijo
  0 siblings, 0 replies; 2+ messages in thread
From: Lazar, Lijo @ 2022-05-11 12:00 UTC (permalink / raw)
  To: Sathishkumar S, amd-gfx; +Cc: Alexander Deucher



On 5/11/2022 4:27 PM, Sathishkumar S wrote:
> smartshift apu and dgpu power boost are reported as percentage with
> respect to their power limits. This value[0-100] reflects the boost
> for the respective device.
> 
> Signed-off-by: Sathishkumar S <sathishkumar.sundararaju@amd.com>

Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>

Thanks,
Lijo

> ---
>   .../gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c   | 60 ++++++++++++++-----
>   1 file changed, 44 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c
> index fd6c44ece168..012e3bd99cc2 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu12/renoir_ppt.c
> @@ -1119,6 +1119,39 @@ static int renoir_get_power_profile_mode(struct smu_context *smu,
>   	return size;
>   }
>   
> +static void renoir_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_power = metrics->ApuPower;
> +	apu_limit = metrics->StapmOriginalLimit;
> +	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;
> +	if (metrics->StapmCurrentLimit > metrics->StapmOriginalLimit)
> +		dgpu_limit = metrics->StapmCurrentLimit - metrics->StapmOriginalLimit;
> +	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 renoir_get_smu_metrics_data(struct smu_context *smu,
>   				       MetricsMember_t member,
>   				       uint32_t *value)
> @@ -1127,6 +1160,9 @@ static int renoir_get_smu_metrics_data(struct smu_context *smu,
>   
>   	SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;
>   	int ret = 0;
> +	uint32_t apu_percent = 0;
> +	uint32_t dgpu_percent = 0;
> +
>   
>   	ret = smu_cmn_get_metrics_table(smu,
>   					NULL,
> @@ -1171,26 +1207,18 @@ static int renoir_get_smu_metrics_data(struct smu_context *smu,
>   		*value = metrics->Voltage[1];
>   		break;
>   	case METRICS_SS_APU_SHARE:
> -		/* return the percentage of APU power with respect to APU's power limit.
> -		 * percentage is reported, this isn't boost value. Smartshift power
> -		 * boost/shift is only when the percentage is more than 100.
> +		/* return the percentage of APU power boost
> +		 * with respect to APU's power limit.
>   		 */
> -		if (metrics->StapmOriginalLimit > 0)
> -			*value =  (metrics->ApuPower * 100) / metrics->StapmOriginalLimit;
> -		else
> -			*value = 0;
> +		renoir_get_ss_power_percent(metrics, &apu_percent, &dgpu_percent);
> +		*value = apu_percent;
>   		break;
>   	case METRICS_SS_DGPU_SHARE:
> -		/* return the percentage of dGPU power with respect to dGPU's power limit.
> -		 * percentage is reported, this isn't boost value. Smartshift power
> -		 * boost/shift is only when the percentage is more than 100.
> +		/* return the percentage of dGPU power boost
> +		 * with respect to dGPU's power limit.
>   		 */
> -		if ((metrics->dGpuPower > 0) &&
> -		    (metrics->StapmCurrentLimit > metrics->StapmOriginalLimit))
> -			*value = (metrics->dGpuPower * 100) /
> -				  (metrics->StapmCurrentLimit - metrics->StapmOriginalLimit);
> -		else
> -			*value = 0;
> +		renoir_get_ss_power_percent(metrics, &apu_percent, &dgpu_percent);
> +		*value = dgpu_percent;
>   		break;
>   	default:
>   		*value = UINT_MAX;
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-05-11 12:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11 10:57 [PATCH] drm/amd/pm: update smartshift powerboost calc for smu12 Sathishkumar S
2022-05-11 12:00 ` Lazar, Lijo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.