[PATCH v1 1/2] amdgpu/pm: Fix incorrect variable for size of clocks array

Lazar, Lijo lijo.lazar at amd.com
Mon May 9 04:47:56 UTC 2022



On 5/9/2022 9:28 AM, Darren Powell wrote:
> Size of pp_clock_levels_with_latency is PP_MAX_CLOCK_LEVELS, not MAX_NUM_CLOCKS.
> Both are currently defined as 16, modifying in case one value is modified in future
> Changed code in both arcturus and aldabaran.
> 
> Also removed unneeded var count, and used min_t function
> 
> Signed-off-by: Darren Powell <darren.powell at amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar at amd.com>

Thanks,
Lijo

> ---
>   drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c  | 9 +++++----
>   drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 9 +++++----
>   2 files changed, 10 insertions(+), 8 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 201563072189..bdd1e1a35a12 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
> @@ -573,12 +573,13 @@ static int arcturus_get_clk_table(struct smu_context *smu,
>   			struct pp_clock_levels_with_latency *clocks,
>   			struct smu_11_0_dpm_table *dpm_table)
>   {
> -	int i, count;
> +	uint32_t i;
>   
> -	count = (dpm_table->count > MAX_NUM_CLOCKS) ? MAX_NUM_CLOCKS : dpm_table->count;
> -	clocks->num_levels = count;
> +	clocks->num_levels = min_t(uint32_t,
> +				   dpm_table->count,
> +				   (uint32_t)PP_MAX_CLOCK_LEVELS);
>   
> -	for (i = 0; i < count; i++) {
> +	for (i = 0; i < clocks->num_levels; i++) {
>   		clocks->data[i].clocks_in_khz =
>   			dpm_table->dpm_levels[i].value * 1000;
>   		clocks->data[i].latency_in_us = 0;
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
> index 38af648cb857..6a4fca47ae53 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
> @@ -549,12 +549,13 @@ static int aldebaran_get_clk_table(struct smu_context *smu,
>   				   struct pp_clock_levels_with_latency *clocks,
>   				   struct smu_13_0_dpm_table *dpm_table)
>   {
> -	int i, count;
> +	uint32_t i;
>   
> -	count = (dpm_table->count > MAX_NUM_CLOCKS) ? MAX_NUM_CLOCKS : dpm_table->count;
> -	clocks->num_levels = count;
> +	clocks->num_levels = min_t(uint32_t,
> +				   dpm_table->count,
> +				   (uint32_t)PP_MAX_CLOCK_LEVELS);
>   
> -	for (i = 0; i < count; i++) {
> +	for (i = 0; i < clocks->num_levels; i++) {
>   		clocks->data[i].clocks_in_khz =
>   			dpm_table->dpm_levels[i].value * 1000;
>   		clocks->data[i].latency_in_us = 0;
> 
> base-commit: 8bb14fbec5ae45c31cbefe217db2418cc683612f
> 


More information about the amd-gfx mailing list