All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/pm: set min,max to 0 if there is no get_dpm_ultimate_freq function
@ 2022-01-24 13:52 ` trix
  0 siblings, 0 replies; 4+ messages in thread
From: trix @ 2022-01-24 13:52 UTC (permalink / raw)
  To: evan.quan, alexander.deucher, christian.koenig, Xinhui.Pan,
	airlied, daniel, nathan, ndesaulniers, lijo.lazar, darren.powell,
	guchun.chen, Arunpravin.PaneerSelvam, andrey.grodzovsky
  Cc: amd-gfx, dri-devel, linux-kernel, llvm, Tom Rix

From: Tom Rix <trix@redhat.com>

clang static analysis reports this represenative problem
amdgpu_smu.c:144:18: warning: The left operand of '*' is a garbage value
        return clk_freq * 100;
               ~~~~~~~~ ^

If there is no get_dpm_ultimate_freq function,
smu_get_dpm_freq_range returns success without setting the
output min,max parameters.  Because this is an extern function,
set the min,max to 0 when there is no get_dpm_ultimate_freq.

Fixes: e5ef784b1e17 ("drm/amd/powerplay: revise calling chain on retrieving frequency range")
Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index 5ace30434e603..35fbe51f52eaa 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -121,11 +121,17 @@ int smu_get_dpm_freq_range(struct smu_context *smu,
 	if (!min && !max)
 		return -EINVAL;
 
-	if (smu->ppt_funcs->get_dpm_ultimate_freq)
+	if (smu->ppt_funcs->get_dpm_ultimate_freq) {
 		ret = smu->ppt_funcs->get_dpm_ultimate_freq(smu,
 							    clk_type,
 							    min,
 							    max);
+	} else {
+		if (min)
+			*min = 0;
+		if (max)
+			*max = 0;
+	}
 
 	return ret;
 }
-- 
2.26.3


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

* [PATCH] drm/amd/pm: set min, max to 0 if there is no get_dpm_ultimate_freq function
@ 2022-01-24 13:52 ` trix
  0 siblings, 0 replies; 4+ messages in thread
From: trix @ 2022-01-24 13:52 UTC (permalink / raw)
  To: evan.quan, alexander.deucher, christian.koenig, Xinhui.Pan,
	airlied, daniel, nathan, ndesaulniers, lijo.lazar, darren.powell,
	guchun.chen, Arunpravin.PaneerSelvam, andrey.grodzovsky
  Cc: Tom Rix, llvm, dri-devel, amd-gfx, linux-kernel

From: Tom Rix <trix@redhat.com>

clang static analysis reports this represenative problem
amdgpu_smu.c:144:18: warning: The left operand of '*' is a garbage value
        return clk_freq * 100;
               ~~~~~~~~ ^

If there is no get_dpm_ultimate_freq function,
smu_get_dpm_freq_range returns success without setting the
output min,max parameters.  Because this is an extern function,
set the min,max to 0 when there is no get_dpm_ultimate_freq.

Fixes: e5ef784b1e17 ("drm/amd/powerplay: revise calling chain on retrieving frequency range")
Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index 5ace30434e603..35fbe51f52eaa 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -121,11 +121,17 @@ int smu_get_dpm_freq_range(struct smu_context *smu,
 	if (!min && !max)
 		return -EINVAL;
 
-	if (smu->ppt_funcs->get_dpm_ultimate_freq)
+	if (smu->ppt_funcs->get_dpm_ultimate_freq) {
 		ret = smu->ppt_funcs->get_dpm_ultimate_freq(smu,
 							    clk_type,
 							    min,
 							    max);
+	} else {
+		if (min)
+			*min = 0;
+		if (max)
+			*max = 0;
+	}
 
 	return ret;
 }
-- 
2.26.3


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

* Re: [PATCH] drm/amd/pm: set min,max to 0 if there is no get_dpm_ultimate_freq function
  2022-01-24 13:52 ` [PATCH] drm/amd/pm: set min, max " trix
@ 2022-01-24 14:22   ` Lazar, Lijo
  -1 siblings, 0 replies; 4+ messages in thread
From: Lazar, Lijo @ 2022-01-24 14:22 UTC (permalink / raw)
  To: trix, evan.quan, alexander.deucher, christian.koenig, Xinhui.Pan,
	airlied, daniel, nathan, ndesaulniers, darren.powell,
	guchun.chen, Arunpravin.PaneerSelvam, andrey.grodzovsky
  Cc: amd-gfx, dri-devel, linux-kernel, llvm



On 1/24/2022 7:22 PM, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
> 
> clang static analysis reports this represenative problem
> amdgpu_smu.c:144:18: warning: The left operand of '*' is a garbage value
>          return clk_freq * 100;
>                 ~~~~~~~~ ^
> 
> If there is no get_dpm_ultimate_freq function,
> smu_get_dpm_freq_range returns success without setting the
> output min,max parameters.  Because this is an extern function,
> set the min,max to 0 when there is no get_dpm_ultimate_freq.
> 
> Fixes: e5ef784b1e17 ("drm/amd/powerplay: revise calling chain on retrieving frequency range")
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
>   drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> index 5ace30434e603..35fbe51f52eaa 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> @@ -121,11 +121,17 @@ int smu_get_dpm_freq_range(struct smu_context *smu,
>   	if (!min && !max)
>   		return -EINVAL;
>   
> -	if (smu->ppt_funcs->get_dpm_ultimate_freq)
> +	if (smu->ppt_funcs->get_dpm_ultimate_freq) {
>   		ret = smu->ppt_funcs->get_dpm_ultimate_freq(smu,
>   							    clk_type,
>   							    min,
>   							    max);
> +	} else {

return -ENOTSUPP; would be more appropriate.

Thanks,
Lijo

> +		if (min)
> +			*min = 0;
> +		if (max)
> +			*max = 0;
> +	}
>   
>   	return ret;
>   }
> 

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

* Re: [PATCH] drm/amd/pm: set min,max to 0 if there is no get_dpm_ultimate_freq function
@ 2022-01-24 14:22   ` Lazar, Lijo
  0 siblings, 0 replies; 4+ messages in thread
From: Lazar, Lijo @ 2022-01-24 14:22 UTC (permalink / raw)
  To: trix, evan.quan, alexander.deucher, christian.koenig, Xinhui.Pan,
	airlied, daniel, nathan, ndesaulniers, darren.powell,
	guchun.chen, Arunpravin.PaneerSelvam, andrey.grodzovsky
  Cc: llvm, dri-devel, amd-gfx, linux-kernel



On 1/24/2022 7:22 PM, trix@redhat.com wrote:
> From: Tom Rix <trix@redhat.com>
> 
> clang static analysis reports this represenative problem
> amdgpu_smu.c:144:18: warning: The left operand of '*' is a garbage value
>          return clk_freq * 100;
>                 ~~~~~~~~ ^
> 
> If there is no get_dpm_ultimate_freq function,
> smu_get_dpm_freq_range returns success without setting the
> output min,max parameters.  Because this is an extern function,
> set the min,max to 0 when there is no get_dpm_ultimate_freq.
> 
> Fixes: e5ef784b1e17 ("drm/amd/powerplay: revise calling chain on retrieving frequency range")
> Signed-off-by: Tom Rix <trix@redhat.com>
> ---
>   drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> index 5ace30434e603..35fbe51f52eaa 100644
> --- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
> @@ -121,11 +121,17 @@ int smu_get_dpm_freq_range(struct smu_context *smu,
>   	if (!min && !max)
>   		return -EINVAL;
>   
> -	if (smu->ppt_funcs->get_dpm_ultimate_freq)
> +	if (smu->ppt_funcs->get_dpm_ultimate_freq) {
>   		ret = smu->ppt_funcs->get_dpm_ultimate_freq(smu,
>   							    clk_type,
>   							    min,
>   							    max);
> +	} else {

return -ENOTSUPP; would be more appropriate.

Thanks,
Lijo

> +		if (min)
> +			*min = 0;
> +		if (max)
> +			*max = 0;
> +	}
>   
>   	return ret;
>   }
> 

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

end of thread, other threads:[~2022-01-24 14:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24 13:52 [PATCH] drm/amd/pm: set min,max to 0 if there is no get_dpm_ultimate_freq function trix
2022-01-24 13:52 ` [PATCH] drm/amd/pm: set min, max " trix
2022-01-24 14:22 ` [PATCH] drm/amd/pm: set min,max " Lazar, Lijo
2022-01-24 14:22   ` 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.