[PATCH v3 3/8] drm/amd/pm: Add arcturus throttler translation

Lazar, Lijo lijo.lazar at amd.com
Wed Jun 2 04:55:17 UTC 2021



On 6/1/2021 11:42 PM, Graham Sider wrote:
> Perform dependent to independent throttle status translation
> for arcturus. Makes use of lookup table arcturus_throttler_map.
> 
> Signed-off-by: Graham Sider <Graham.Sider at amd.com>
> ---
>   .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 45 ++++++++++++++++---
>   1 file changed, 40 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
> index 1735a96dd307..c0bfd5634fca 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
> @@ -211,6 +211,26 @@ static const struct cmn2asic_mapping arcturus_workload_map[PP_SMC_POWER_PROFILE_
>   	WORKLOAD_MAP(PP_SMC_POWER_PROFILE_CUSTOM,		WORKLOAD_PPLIB_CUSTOM_BIT),
>   };
>   
> +static const uint8_t arcturus_throttler_map[] = {
> +	[THROTTLER_TEMP_EDGE_BIT]	= (SMU_THROTTLER_TEMP_EDGE_BIT),
> +	[THROTTLER_TEMP_HOTSPOT_BIT]	= (SMU_THROTTLER_TEMP_HOTSPOT_BIT),
> +	[THROTTLER_TEMP_MEM_BIT]	= (SMU_THROTTLER_TEMP_MEM_BIT),
> +	[THROTTLER_TEMP_VR_GFX_BIT]	= (SMU_THROTTLER_TEMP_VR_GFX_BIT),
> +	[THROTTLER_TEMP_VR_MEM_BIT]	= (SMU_THROTTLER_TEMP_VR_MEM_BIT),
> +	[THROTTLER_TEMP_VR_SOC_BIT]	= (SMU_THROTTLER_TEMP_VR_SOC_BIT),
> +	[THROTTLER_TDC_GFX_BIT]		= (SMU_THROTTLER_TDC_GFX_BIT),
> +	[THROTTLER_TDC_SOC_BIT]		= (SMU_THROTTLER_TDC_SOC_BIT),
> +	[THROTTLER_PPT0_BIT]		= (SMU_THROTTLER_PPT0_BIT),
> +	[THROTTLER_PPT1_BIT]		= (SMU_THROTTLER_PPT1_BIT),
> +	[THROTTLER_PPT2_BIT]		= (SMU_THROTTLER_PPT2_BIT),
> +	[THROTTLER_PPT3_BIT]		= (SMU_THROTTLER_PPT3_BIT),
> +	[THROTTLER_PPM_BIT]		= (SMU_THROTTLER_PPM_BIT),
> +	[THROTTLER_FIT_BIT]		= (SMU_THROTTLER_FIT_BIT),
> +	[THROTTLER_APCC_BIT]		= (SMU_THROTTLER_APCC_BIT),
> +	[THROTTLER_VRHOT0_BIT]		= (SMU_THROTTLER_VRHOT0_BIT),
> +	[THROTTLER_VRHOT1_BIT]		= (SMU_THROTTLER_VRHOT1_BIT),
> +};
> +
>   static int arcturus_tables_init(struct smu_context *smu)
>   {
>   	struct smu_table_context *smu_table = &smu->smu_table;
> @@ -237,7 +257,7 @@ static int arcturus_tables_init(struct smu_context *smu)
>   		return -ENOMEM;
>   	smu_table->metrics_time = 0;
>   
> -	smu_table->gpu_metrics_table_size = sizeof(struct gpu_metrics_v1_1);
> +	smu_table->gpu_metrics_table_size = sizeof(struct gpu_metrics_v1_3);
>   	smu_table->gpu_metrics_table = kzalloc(smu_table->gpu_metrics_table_size, GFP_KERNEL);
>   	if (!smu_table->gpu_metrics_table) {
>   		kfree(smu_table->metrics_table);
> @@ -540,6 +560,19 @@ static int arcturus_freqs_in_same_level(int32_t frequency1,
>   	return (abs(frequency1 - frequency2) <= EPSILON);
>   }
>   
> +static uint64_t arcturus_get_indep_throttler_status(
> +					const unsigned long dep_status)
> +{
> +	uint64_t indep_status = 0;
> +	uint8_t dep_bit = 0;
> +
> +	for_each_set_bit(dep_bit, &dep_status, 32)
> +		indep_status |= smu_u64_throttler_bit(dep_status,
> +			arcturus_throttler_map[dep_bit], dep_bit);
No extra shifts as in smu_u64, this only needs  |= 1ULL << map[dep_bit]. 
Also this logic may be made common (smu_cmn) if the map is passed.

Thanks,
Lijo

> +	return indep_status;
> +}
> +
>   static int arcturus_get_smu_metrics_data(struct smu_context *smu,
>   					 MetricsMember_t member,
>   					 uint32_t *value)
> @@ -2275,8 +2308,8 @@ static ssize_t arcturus_get_gpu_metrics(struct smu_context *smu,
>   					void **table)
>   {
>   	struct smu_table_context *smu_table = &smu->smu_table;
> -	struct gpu_metrics_v1_1 *gpu_metrics =
> -		(struct gpu_metrics_v1_1 *)smu_table->gpu_metrics_table;
> +	struct gpu_metrics_v1_3 *gpu_metrics =
> +		(struct gpu_metrics_v1_3 *)smu_table->gpu_metrics_table;
>   	SmuMetrics_t metrics;
>   	int ret = 0;
>   
> @@ -2286,7 +2319,7 @@ static ssize_t arcturus_get_gpu_metrics(struct smu_context *smu,
>   	if (ret)
>   		return ret;
>   
> -	smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 1);
> +	smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 3);
>   
>   	gpu_metrics->temperature_edge = metrics.TemperatureEdge;
>   	gpu_metrics->temperature_hotspot = metrics.TemperatureHotspot;
> @@ -2315,6 +2348,8 @@ static ssize_t arcturus_get_gpu_metrics(struct smu_context *smu,
>   	gpu_metrics->current_dclk0 = metrics.CurrClock[PPCLK_DCLK];
>   
>   	gpu_metrics->throttle_status = metrics.ThrottlerStatus;
> +	gpu_metrics->indep_throttle_status =
> +			arcturus_get_indep_throttler_status(metrics.ThrottlerStatus);
>   
>   	gpu_metrics->current_fan_speed = metrics.CurrFanSpeed;
>   
> @@ -2327,7 +2362,7 @@ static ssize_t arcturus_get_gpu_metrics(struct smu_context *smu,
>   
>   	*table = (void *)gpu_metrics;
>   
> -	return sizeof(struct gpu_metrics_v1_1);
> +	return sizeof(struct gpu_metrics_v1_3);
>   }
>   
>   static const struct pptable_funcs arcturus_ppt_funcs = {
> 


More information about the amd-gfx mailing list