Skip to contentSkip to conversation

amdgpu clang warning fixes on next-20190703

PATCH Applied Nathan Chancellor 6 participants 20 messages Jul 4, 2019 – Jul 25, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover amdgpu clang warning fixes on next-20190703

Hi all,

I don't do threaded patches very often so if I have messed something up, please forgive me :)

This series fixes all of the clang warnings that I saw added in next-20190703. The full list is visible in the gist linked below and each full individual warning can be seen in the GitHub link in each patch.

https://gist.github.com/5411af08b96c99b14e60c60800e99a47

All of the warnings are fixed in what I believe is the optimal way but the enum conversion warnings were the trickiest; please review carefully as the code paths for some of them have changed (especially in patch 3 and 6).

Thank you!
Nathan

#1 lore raw

PATCH 1/7 drm/amdgpu/mes10.1: Fix header guard

clang warns:

In file included from drivers/gpu/drm/amd/amdgpu/nv.c:53:
drivers/gpu/drm/amd/amdgpu/../amdgpu/mes_v10_1.h:24:9: warning:
'__MES_V10_1_H__' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]

 #ifndef __MES_V10_1_H__
         ^~~~~~~~~~~~~~~
 drivers/gpu/drm/amd/amdgpu/../amdgpu/mes_v10_1.h:25:9: note:
 '__MES_v10_1_H__' is defined here; did you mean '__MES_V10_1_H__'?
 #define __MES_v10_1_H__
         ^~~~~~~~~~~~~~~
         __MES_V10_1_H__

1 warning generated.

Capitalize the V.

Fixes 886f82aa7a1d ("drm/amdgpu/mes10.1: add ip block mes10.1 (v2)")
---
 drivers/gpu/drm/amd/amdgpu/mes_v10_1.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/mes_v10_1.h +1 -1
index 17b9b53fa892..9afd6ddb01e9 100644
@@ -22,7 +22,7 @@
  */
 
 #ifndef __MES_V10_1_H__
-#define __MES_v10_1_H__
+#define __MES_V10_1_H__
 
 extern const struct amdgpu_ip_block_version mes_v10_1_ip_block;
 
Signature · 1 line
2.22.0
Acked-by on v1 1/7
#2 lore raw

Re: [PATCH 1/7] drm/amdgpu/mes10.1: Fix header guard

Quoted 14 lines · Nathan Chancellor

clang warns:

In file included from drivers/gpu/drm/amd/amdgpu/nv.c:53:
drivers/gpu/drm/amd/amdgpu/../amdgpu/mes_v10_1.h:24:9: warning:
'__MES_V10_1_H__' is used as a header guard here, followed by #define of a different macro [-Wheader-guard]

 #ifndef __MES_V10_1_H__
         ^~~~~~~~~~~~~~~
 drivers/gpu/drm/amd/amdgpu/../amdgpu/mes_v10_1.h:25:9: note:
 '__MES_v10_1_H__' is defined here; did you mean '__MES_V10_1_H__'?
 #define __MES_v10_1_H__
         ^~~~~~~~~~~~~~~
         __MES_V10_1_H__
Quoted 7 lines

1 warning generated.

Capitalize the V.

Fixes 886f82aa7a1d ("drm/amdgpu/mes10.1: add ip block mes10.1 (v2)")

I ran into the same one now, and saw your version before sending an identical patch.

#3 lore raw

PATCH 2/7 drm/amd/powerplay: Use memset to initialize metrics structs

In reply to Nathan Chancellor

clang warns:

drivers/gpu/drm/amd/amdgpu/../powerplay/navi10_ppt.c:601:33: warning:
suggest braces around initialization of subobject [-Wmissing-braces]

        static SmuMetrics_t metrics = {0};
                                       ^
                                       {}
drivers/gpu/drm/amd/amdgpu/../powerplay/navi10_ppt.c:905:26: warning:
suggest braces around initialization of subobject [-Wmissing-braces]
        SmuMetrics_t metrics = {0};
                                ^
                                {}

2 warnings generated.

One way to fix these warnings is to add additional braces like clang suggests; however, there has been a bit of push back from some maintainers[1][2], who just prefer memset as it is unambiguous, doesn't depend on a particular compiler version[3], and properly initializes all subobjects. Do that here so there are no more warnings.

[1]: https://lore.kernel.org/lkml/[email protected]/
[2]: https://lore.kernel.org/lkml/[email protected]/
[3]: https://lore.kernel.org/lkml/[email protected]/

Fixes 98e1a543c7b1 ("drm/amd/powerplay: add function get current clock freq interface for navi10")
Fixes ab43c4bf1cc8 ("drm/amd/powerplay: fix fan speed show error (for hwmon pwm)")
---
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/navi10_ppt.c +6 -2
index e00397f84b2f..f5d2ada05bc6 100644
@@ -598,12 +598,14 @@ static int navi10_get_current_clk_freq_by_table(struct smu_context *smu,
 				       enum smu_clk_type clk_type,
 				       uint32_t *value)
 {
-	static SmuMetrics_t metrics = {0};
+	static SmuMetrics_t metrics;
 	int ret = 0, clk_id = 0;
 
 	if (!value)
 		return -EINVAL;
 
+	memset(&metrics, 0, sizeof(metrics));
+
 	ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, (void *)&metrics, false);
 	if (ret)
 		return ret;
@@ -902,12 +904,14 @@ static bool navi10_is_dpm_running(struct smu_context *smu)
 
 static int navi10_get_fan_speed(struct smu_context *smu, uint16_t *value)
 {
-	SmuMetrics_t metrics = {0};
+	SmuMetrics_t metrics;
 	int ret = 0;
 
 	if (!value)
 		return -EINVAL;
 
+	memset(&metrics, 0, sizeof(metrics));
+
 	ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS,
 			       (void *)&metrics, false);
 	if (ret)
Signature · 1 line
2.22.0
#4 lore raw

PATCH 3/7 drm/amd/powerplay: Use proper enums in smu_adjust_power_state_dynamic

In reply to Nathan Chancellor

clang warns:

drivers/gpu/drm/amd/amdgpu/../powerplay/amdgpu_smu.c:1374:30: warning:
implicit conversion from enumeration type 'enum pp_clock_type' to different enumeration type 'enum smu_clk_type' [-Wenum-conversion]

                        smu_force_clk_levels(smu, PP_SCLK, 1 << sclk_mask);
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../powerplay/amdgpu_smu.c:1375:30: warning:
implicit conversion from enumeration type 'enum pp_clock_type' to
different enumeration type 'enum smu_clk_type' [-Wenum-conversion]
                        smu_force_clk_levels(smu, PP_MCLK, 1 << mclk_mask);
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

This appears to be a copy and paste fail from when this was a call to vega20_force_clk_levels.

Fixes bc0fcffd36ba ("drm/amd/powerplay: Unify smu handle task function (v2)")
---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +2 -2
index 31152d495f69..e897469f7431 100644
@@ -1371,8 +1371,8 @@ int smu_adjust_power_state_dynamic(struct smu_context *smu,
 							 &soc_mask);
 			if (ret)
 				return ret;
-			smu_force_clk_levels(smu, PP_SCLK, 1 << sclk_mask);
-			smu_force_clk_levels(smu, PP_MCLK, 1 << mclk_mask);
+			smu_force_clk_levels(smu, SMU_SCLK, 1 << sclk_mask);
+			smu_force_clk_levels(smu, SMU_MCLK, 1 << mclk_mask);
 			break;
 
 		case AMD_DPM_FORCED_LEVEL_MANUAL:
Signature · 1 line
2.22.0
#5 lore raw

PATCH 4/7 drm/amd/powerplay: Zero initialize freq in smu_v11_0_get_current_clk_freq

In reply to Nathan Chancellor

clang warns (trimmed for brevity):

drivers/gpu/drm/amd/amdgpu/../powerplay/smu_v11_0.c:1098:10: warning:
variable 'freq' is used uninitialized whenever '?:' condition is false [-Wsometimes-uninitialized]

                ret =  smu_get_current_clk_freq_by_table(smu, clk_id, &freq);
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If get_current_clk_freq_by_table is ever NULL, freq will fail to be properly initialized. Zero initialize it to avoid using uninitialized stack values.

smu_get_current_clk_freq_by_table expands to a ternary operator conditional on smu->funcs->get_current_clk_freq_by_table being not NULL. When this is false, freq will be uninitialized. Zero initialize freq to avoid using random stack values if that ever happens.

Fixes e36182490dec ("drm/amd/powerplay: fix dpm freq unit error (10KHz -> Mhz)")
---
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -1
index 632a20587c8b..a6f8cd6df7f1 100644
@@ -1088,7 +1088,7 @@ static int smu_v11_0_get_current_clk_freq(struct smu_context *smu,
 					  uint32_t *value)
 {
 	int ret = 0;
-	uint32_t freq;
+	uint32_t freq = 0;
 
 	if (clk_id >= SMU_CLK_COUNT || !value)
 		return -EINVAL;
Signature · 1 line
2.22.0
#6 lore raw

PATCH 5/7 drm/amd/display: Use proper enum conversion functions

In reply to Nathan Chancellor

clang warns:

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_pp_smu.c:336:8:
warning: implicit conversion from enumeration type 'enum smu_clk_type' to different enumeration type 'enum amd_pp_clock_type' [-Wenum-conversion]

                                        dc_to_smu_clock_type(clk_type),
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_pp_smu.c:421:14:
warning: implicit conversion from enumeration type 'enum amd_pp_clock_type' to different enumeration type 'enum smu_clk_type' [-Wenum-conversion]

                                        dc_to_pp_clock_type(clk_type),
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There are functions to properly convert between all of these types, use them so there are no longer any warnings.

Fixes a43913ea50a5 ("drm/amd/powerplay: add function get_clock_by_type_with_latency for navi10")
Fixes e5e4e22391c2 ("drm/amd/powerplay: add interface to get clock by type with latency for display (v2)")
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +2 -2
index eac09bfe3be2..0f76cfff9d9b 100644
@@ -333,7 +333,7 @@ bool dm_pp_get_clock_levels_by_type(
 		}
 	} else if (adev->smu.funcs && adev->smu.funcs->get_clock_by_type) {
 		if (smu_get_clock_by_type(&adev->smu,
-					  dc_to_smu_clock_type(clk_type),
+					  dc_to_pp_clock_type(clk_type),
 					  &pp_clks)) {
 			get_default_clock_levels(clk_type, dc_clks);
 			return true;
@@ -418,7 +418,7 @@ bool dm_pp_get_clock_levels_by_type_with_latency(
 			return false;
 	} else if (adev->smu.ppt_funcs && adev->smu.ppt_funcs->get_clock_by_type_with_latency) {
 		if (smu_get_clock_by_type_with_latency(&adev->smu,
-						       dc_to_pp_clock_type(clk_type),
+						       dc_to_smu_clock_type(clk_type),
 						       &pp_clks))
 			return false;
 	}
Signature · 1 line
2.22.0
#7 lore raw

Re: [PATCH 5/7] drm/amd/display: Use proper enum conversion functions

Quoted 13 lines · Nathan Chancellor

clang warns:

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_pp_smu.c:336:8:
warning: implicit conversion from enumeration type 'enum smu_clk_type' to different enumeration type 'enum amd_pp_clock_type' [-Wenum-conversion]

                                        dc_to_smu_clock_type(clk_type),
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_pp_smu.c:421:14:
warning: implicit conversion from enumeration type 'enum amd_pp_clock_type' to different enumeration type 'enum smu_clk_type' [-Wenum-conversion]

Quoted 5 lines
                                        dc_to_pp_clock_type(clk_type),
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There are functions to properly convert between all of these types, use them so there are no longer any warnings.

I had a different solution for this one as well. The difference is that your patch keeps the types and assumes that the functions do the right thing (i.e. the warning was correct), while my version assumes that the code works correctly, but the types are wrong (a false positive warning).

One of the two patches is correct, the other one is broken, but I have no idea which one.

Arnd

Quoted 1 line

From 61316b80c852d103bb61e1ce9904002414600125 Mon Sep 17 00:00:00 2001

From: Arnd Bergmann <[email protected]>
Date: Mon, 8 Jul 2019 17:44:05 +0200
Subject: [PATCH] drm/amd/powerplay: fix one more incorrect enum conversion

Similar to a previous patch, this one converts the type from a function argument of a different enum type:

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_pp_smu.c:336:8:
error: implicit conversion from enumeration type 'enum smu_clk_type' to different enumeration type 'enum amd_pp_clock_type' [-Werror,-Wenum-conversion]

                                          dc_to_smu_clock_type(clk_type),
                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../powerplay/inc/amdgpu_smu.h:868:77: note:
expanded from macro 'smu_get_clock_by_type'
        ((smu)->funcs->get_clock_by_type ?
(smu)->funcs->get_clock_by_type((smu), (type), (clocks)) : 0)
                                           ~
            ^~~~

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_pp_smu.c:421:14:
error: implicit conversion from enumeration type 'enum amd_pp_clock_type' to different enumeration type 'enum smu_clk_type' [-Werror,-Wenum-conversion]

dc_to_pp_clock_type(clk_type),

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/../powerplay/inc/amdgpu_smu.h:872:111:
note: expanded from macro 'smu_get_clock_by_type_with_latency'

Add another type cast.

Fixes e5e4e22391c2 ("drm/amd/powerplay: add interface to get clock by

type with latency for display (v2)")

(quoted diff) +0 -0

b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c index eac09bfe3be2..88e3f8456b1c 100644

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +1 -1
@@ -333,7 +333,7 @@ bool dm_pp_get_clock_levels_by_type(
                }
        } else if (adev->smu.funcs && adev->smu.funcs->get_clock_by_type) {
                if (smu_get_clock_by_type(&adev->smu,
-                                         dc_to_smu_clock_type(clk_type),
+                                         (enum

amd_pp_clock_type)dc_to_smu_clock_type(clk_type),

                                          &pp_clks)) {
                        get_default_clock_levels(clk_type, dc_clks);
                        return true;
@@ -418,7 +418,7 @@ bool dm_pp_get_clock_levels_by_type_with_latency(
                        return false;
        } else if (adev->smu.ppt_funcs &&
adev->smu.ppt_funcs->get_clock_by_type_with_latency) {
                if (smu_get_clock_by_type_with_latency(&adev->smu,

-
dc_to_pp_clock_type(clk_type),
+ (enum
smu_clk_type)dc_to_pp_clock_type(clk_type),

                                                       &pp_clks))
                        return false;
        }
#8 lore raw

Re: [PATCH 5/7] drm/amd/display: Use proper enum conversion functions

Quoted 26 lines · Arnd Bergmann
Quoted 13 lines · Nathan Chancellor

clang warns:

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_pp_smu.c:336:8:
warning: implicit conversion from enumeration type 'enum smu_clk_type' to different enumeration type 'enum amd_pp_clock_type' [-Wenum-conversion]

                                        dc_to_smu_clock_type(clk_type),
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_pp_smu.c:421:14:
warning: implicit conversion from enumeration type 'enum amd_pp_clock_type' to different enumeration type 'enum smu_clk_type' [-Wenum-conversion]

Quoted 5 lines
                                        dc_to_pp_clock_type(clk_type),
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There are functions to properly convert between all of these types, use them so there are no longer any warnings.

I had a different solution for this one as well. The difference is that your patch keeps the types and assumes that the functions do the right thing (i.e. the warning was correct), while my version assumes that the code works correctly, but the types are wrong (a false positive warning).

Quoted 4 lines

One of the two patches is correct, the other one is broken, but I have no idea which one.

Arnd

Indeed. I would personally argue that if using the correct conversion functions (which are here to specifically avoid this type of warning) causes issues, this code should probably not be using enumerated types at all since the entire point is to enforce semantic correctness, not just be a special way to represent small integer values, especially in the case where the CLK values are completely different numerical values in various enumerated types. I think enumerated type casts are ugly and defeat the purpose of them but that's obviously just my opinion :)

Hopefully we can get some clarity on this soon.

Cheers,
Nathan

#9 lore raw

Re: [PATCH 5/7] drm/amd/display: Use proper enum conversion functions

In reply to Nathan Chancellor
Quoted 51 lines · Nathan Chancellor

clang warns:

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_pp_smu.c:336:8:
warning: implicit conversion from enumeration type 'enum smu_clk_type' to different enumeration type 'enum amd_pp_clock_type' [-Wenum-conversion]

                                        dc_to_smu_clock_type(clk_type),
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_pp_smu.c:421:14:
warning: implicit conversion from enumeration type 'enum amd_pp_clock_type' to different enumeration type 'enum smu_clk_type' [-Wenum-conversion]

                                        dc_to_pp_clock_type(clk_type),
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There are functions to properly convert between all of these types, use them so there are no longer any warnings.

Fixes a43913ea50a5 ("drm/amd/powerplay: add function get_clock_by_type_with_latency for navi10")
Fixes e5e4e22391c2 ("drm/amd/powerplay: add interface to get clock by type with latency for display (v2)")
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +2 -2
index eac09bfe3be2..0f76cfff9d9b 100644
@@ -333,7 +333,7 @@ bool dm_pp_get_clock_levels_by_type(
 		}
 	} else if (adev->smu.funcs && adev->smu.funcs->get_clock_by_type) {
 		if (smu_get_clock_by_type(&adev->smu,
-					  dc_to_smu_clock_type(clk_type),
+					  dc_to_pp_clock_type(clk_type),
 					  &pp_clks)) {
 			get_default_clock_levels(clk_type, dc_clks);
 			return true;
@@ -418,7 +418,7 @@ bool dm_pp_get_clock_levels_by_type_with_latency(
 			return false;
 	} else if (adev->smu.ppt_funcs && adev->smu.ppt_funcs->get_clock_by_type_with_latency) {
 		if (smu_get_clock_by_type_with_latency(&adev->smu,
-						       dc_to_pp_clock_type(clk_type),
+						       dc_to_smu_clock_type(clk_type),
 						       &pp_clks))
 			return false;
 	}
Signature · 1 line
2.22.0

Gentle ping for review, this is the last remaining warning that I see from amdgpu on next-20190718.

Cheers,
Nathan

maintainer Reviewed-by
#10 lore raw

Re: [PATCH 5/7] drm/amd/display: Use proper enum conversion functions

Quoted 27 lines · Nathan Chancellor
Quoted 26 lines · Nathan Chancellor

clang warns:

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_pp_smu.c:336:8:
warning: implicit conversion from enumeration type 'enum smu_clk_type' to different enumeration type 'enum amd_pp_clock_type' [-Wenum-conversion]

                                        dc_to_smu_clock_type(clk_type),
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_pp_smu.c:421:14:
warning: implicit conversion from enumeration type 'enum amd_pp_clock_type' to different enumeration type 'enum smu_clk_type' [-Wenum-conversion]

                                        dc_to_pp_clock_type(clk_type),
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There are functions to properly convert between all of these types, use them so there are no longer any warnings.

Fixes a43913ea50a5 ("drm/amd/powerplay: add function get_clock_by_type_with_latency for navi10")
Fixes e5e4e22391c2 ("drm/amd/powerplay: add interface to get clock by type with latency for display (v2)")
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 10 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c bool dm_pp_get_clock_levels_by_type( · line 336

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +1 -1
index eac09bfe3be2..0f76cfff9d9b 100644
@@ -333,7 +333,7 @@ bool dm_pp_get_clock_levels_by_type(
 		}
 	} else if (adev->smu.funcs && adev->smu.funcs->get_clock_by_type) {
 		if (smu_get_clock_by_type(&adev->smu,
-					  dc_to_smu_clock_type(clk_type),
+					  dc_to_pp_clock_type(clk_type),

smu_funcs->get_clock_by_type doesn't seem to be hooked up anywhere, so this looks to be the most correct.

Although it makes more sense to use smu_clk_types here rather than amd_pp_clock_type - any reason why this isn't the case?

Quoted 9 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c bool dm_pp_get_clock_levels_by_type_with_latency( · line 421

Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +1 -1
 					  &pp_clks)) {
 			get_default_clock_levels(clk_type, dc_clks);
 			return true;
@@ -418,7 +418,7 @@ bool dm_pp_get_clock_levels_by_type_with_latency(
 			return false;
 	} else if (adev->smu.ppt_funcs && adev->smu.ppt_funcs->get_clock_by_type_with_latency) {
 		if (smu_get_clock_by_type_with_latency(&adev->smu,
-						       dc_to_pp_clock_type(clk_type),
+						       dc_to_smu_clock_type(clk_type),

This is slightly concerning. The functions are doing the right thing, but amd_pp_clock_type doesn't map 1-1 to smu_clk_type... In any case, this looks good to me.

Quoted 13 lines
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +0 -0
 						       &pp_clks))
 			return false;
 	}
Signature · 1 line
2.22.0

Gentle ping for review, this is the last remaining warning that I see from amdgpu on next-20190718.

Cheers,
Nathan

#11 lore raw

Re: [PATCH 5/7] drm/amd/display: Use proper enum conversion functions

Quoted 61 lines · Sun peng (Leo)
Quoted 27 lines · Nathan Chancellor
Quoted 26 lines · Nathan Chancellor

clang warns:

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_pp_smu.c:336:8:
warning: implicit conversion from enumeration type 'enum smu_clk_type' to different enumeration type 'enum amd_pp_clock_type' [-Wenum-conversion]

                                         dc_to_smu_clock_type(clk_type),
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_pp_smu.c:421:14:
warning: implicit conversion from enumeration type 'enum amd_pp_clock_type' to different enumeration type 'enum smu_clk_type' [-Wenum-conversion]

                                         dc_to_pp_clock_type(clk_type),
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There are functions to properly convert between all of these types, use them so there are no longer any warnings.

Fixes a43913ea50a5 ("drm/amd/powerplay: add function get_clock_by_type_with_latency for navi10")
Fixes e5e4e22391c2 ("drm/amd/powerplay: add interface to get clock by type with latency for display (v2)")
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 10 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c bool dm_pp_get_clock_levels_by_type( · line 336

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +1 -1
index eac09bfe3be2..0f76cfff9d9b 100644
@@ -333,7 +333,7 @@ bool dm_pp_get_clock_levels_by_type(
  		}
  	} else if (adev->smu.funcs && adev->smu.funcs->get_clock_by_type) {
  		if (smu_get_clock_by_type(&adev->smu,
-					  dc_to_smu_clock_type(clk_type),
+					  dc_to_pp_clock_type(clk_type),

smu_funcs->get_clock_by_type doesn't seem to be hooked up anywhere, so this looks to be the most correct.

Although it makes more sense to use smu_clk_types here rather than amd_pp_clock_type - any reason why this isn't the case?

Quoted 9 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c bool dm_pp_get_clock_levels_by_type_with_latency( · line 421

Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +1 -1
  					  &pp_clks)) {
  			get_default_clock_levels(clk_type, dc_clks);
  			return true;
@@ -418,7 +418,7 @@ bool dm_pp_get_clock_levels_by_type_with_latency(
  			return false;
  	} else if (adev->smu.ppt_funcs && adev->smu.ppt_funcs->get_clock_by_type_with_latency) {
  		if (smu_get_clock_by_type_with_latency(&adev->smu,
-						       dc_to_pp_clock_type(clk_type),
+						       dc_to_smu_clock_type(clk_type),

This is slightly concerning. The functions are doing the right thing, but amd_pp_clock_type doesn't map 1-1 to smu_clk_type... In any case, this looks good to me.

Quoted 1 line

Looks mostly like the table just needs to be sized properly:

	static int dc_clk_type_map[] = {
->
	static int dc_clk_type_map[DM_PP_CLOCK_TYPE_NUM_TYPES] = {

where DM_PP_CLOCK_TYPE_NUM_TYPES would be added to enum dm_pp_clock_type.

Or it could just use a switch table instead, like the other function does.

Nicholas Kazlauskas

Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +0 -0
  						       &pp_clks))
  			return false;
  	}
Signature · 1 line
2.22.0

Gentle ping for review, this is the last remaining warning that I see from amdgpu on next-20190718.

Quoted 8 lines
Quoted 3 lines

Cheers,
Nathan

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#12 lore raw

Re: [PATCH 5/7] drm/amd/display: Use proper enum conversion functions

Quoted 70 lines · Nicholas
Quoted 61 lines · Sun peng (Leo)
Quoted 27 lines · Nathan Chancellor
Quoted 26 lines · Nathan Chancellor

clang warns:

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_pp_smu.c:336:8:
warning: implicit conversion from enumeration type 'enum smu_clk_type' to different enumeration type 'enum amd_pp_clock_type' [-Wenum-conversion]

                                         dc_to_smu_clock_type(clk_type),
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_pp_smu.c:421:14:
warning: implicit conversion from enumeration type 'enum amd_pp_clock_type' to different enumeration type 'enum smu_clk_type' [-Wenum-conversion]

                                         dc_to_pp_clock_type(clk_type),
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

There are functions to properly convert between all of these types, use them so there are no longer any warnings.

Fixes a43913ea50a5 ("drm/amd/powerplay: add function get_clock_by_type_with_latency for navi10")
Fixes e5e4e22391c2 ("drm/amd/powerplay: add interface to get clock by type with latency for display (v2)")
---
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 10 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c bool dm_pp_get_clock_levels_by_type( · line 336

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +1 -1
index eac09bfe3be2..0f76cfff9d9b 100644
@@ -333,7 +333,7 @@ bool dm_pp_get_clock_levels_by_type(
  		}
  	} else if (adev->smu.funcs && adev->smu.funcs->get_clock_by_type) {
  		if (smu_get_clock_by_type(&adev->smu,
-					  dc_to_smu_clock_type(clk_type),
+					  dc_to_pp_clock_type(clk_type),

smu_funcs->get_clock_by_type doesn't seem to be hooked up anywhere, so this looks to be the most correct.

Although it makes more sense to use smu_clk_types here rather than amd_pp_clock_type - any reason why this isn't the case?

Quoted 9 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c bool dm_pp_get_clock_levels_by_type_with_latency( · line 421

Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +1 -1
  					  &pp_clks)) {
  			get_default_clock_levels(clk_type, dc_clks);
  			return true;
@@ -418,7 +418,7 @@ bool dm_pp_get_clock_levels_by_type_with_latency(
  			return false;
  	} else if (adev->smu.ppt_funcs && adev->smu.ppt_funcs->get_clock_by_type_with_latency) {
  		if (smu_get_clock_by_type_with_latency(&adev->smu,
-						       dc_to_pp_clock_type(clk_type),
+						       dc_to_smu_clock_type(clk_type),

This is slightly concerning. The functions are doing the right thing, but amd_pp_clock_type doesn't map 1-1 to smu_clk_type... In any case, this looks good to me.

Quoted 1 line

Looks mostly like the table just needs to be sized properly:

	static int dc_clk_type_map[] = {
->
	static int dc_clk_type_map[DM_PP_CLOCK_TYPE_NUM_TYPES] = {
Quoted 5 lines

where DM_PP_CLOCK_TYPE_NUM_TYPES would be added to enum dm_pp_clock_type.

Or it could just use a switch table instead, like the other function does.

Nicholas Kazlauskas

Good catch, I'll spin up something quick.

Leo

Quoted 22 lines
Quoted 21 lines
Quoted 10 lines
Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +0 -0
  						       &pp_clks))
  			return false;
  	}
Signature · 1 line
2.22.0
Quoted 6 lines

Gentle ping for review, this is the last remaining warning that I see from amdgpu on next-20190718.

Cheers,
Nathan

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#13 lore raw

PATCH 6/7 drm/amd/powerplay: Use proper enums in vega20_print_clk_levels

In reply to Nathan Chancellor

clang warns:

drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:995:39: warning:
implicit conversion from enumeration type 'PPCLK_e' to different enumeration type 'enum smu_clk_type' [-Wenum-conversion]

                ret = smu_get_current_clk_freq(smu, PPCLK_SOCCLK, &now);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:1016:39: warning:
implicit conversion from enumeration type 'PPCLK_e' to different
enumeration type 'enum smu_clk_type' [-Wenum-conversion]
                ret = smu_get_current_clk_freq(smu, PPCLK_FCLK, &now);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:1031:39: warning:
implicit conversion from enumeration type 'PPCLK_e' to different
enumeration type 'enum smu_clk_type' [-Wenum-conversion]
                ret = smu_get_current_clk_freq(smu, PPCLK_DCEFCLK, &now);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~

The values are mapped one to one in vega20_get_smu_clk_index so just use the proper enums here.

Fixes 096761014227 ("drm/amd/powerplay: support sysfs to get socclk, fclk, dcefclk")
---
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +3 -3
index 0f14fe14ecd8..e62dd6919b24 100644
@@ -992,7 +992,7 @@ static int vega20_print_clk_levels(struct smu_context *smu,
 		break;
 
 	case SMU_SOCCLK:
-		ret = smu_get_current_clk_freq(smu, PPCLK_SOCCLK, &now);
+		ret = smu_get_current_clk_freq(smu, SMU_SOCCLK, &now);
 		if (ret) {
 			pr_err("Attempt to get current socclk Failed!");
 			return ret;
@@ -1013,7 +1013,7 @@ static int vega20_print_clk_levels(struct smu_context *smu,
 		break;
 
 	case SMU_FCLK:
-		ret = smu_get_current_clk_freq(smu, PPCLK_FCLK, &now);
+		ret = smu_get_current_clk_freq(smu, SMU_FCLK, &now);
 		if (ret) {
 			pr_err("Attempt to get current fclk Failed!");
 			return ret;
@@ -1028,7 +1028,7 @@ static int vega20_print_clk_levels(struct smu_context *smu,
 		break;
 
 	case SMU_DCEFCLK:
-		ret = smu_get_current_clk_freq(smu, PPCLK_DCEFCLK, &now);
+		ret = smu_get_current_clk_freq(smu, SMU_DCEFCLK, &now);
 		if (ret) {
 			pr_err("Attempt to get current dcefclk Failed!");
 			return ret;
Signature · 1 line
2.22.0
#14 lore raw

Re: [PATCH 6/7] drm/amd/powerplay: Use proper enums in vega20_print_clk_levels

Quoted 19 lines · Nathan Chancellor

clang warns:

drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:995:39: warning:
implicit conversion from enumeration type 'PPCLK_e' to different enumeration type 'enum smu_clk_type' [-Wenum-conversion]

                ret = smu_get_current_clk_freq(smu, PPCLK_SOCCLK, &now);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:1016:39: warning:
implicit conversion from enumeration type 'PPCLK_e' to different
enumeration type 'enum smu_clk_type' [-Wenum-conversion]
                ret = smu_get_current_clk_freq(smu, PPCLK_FCLK, &now);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:1031:39: warning:
implicit conversion from enumeration type 'PPCLK_e' to different
enumeration type 'enum smu_clk_type' [-Wenum-conversion]
                ret = smu_get_current_clk_freq(smu, PPCLK_DCEFCLK, &now);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
Quoted 7 lines

The values are mapped one to one in vega20_get_smu_clk_index so just use the proper enums here.

Fixes 096761014227 ("drm/amd/powerplay: support sysfs to get socclk, fclk, dcefclk")

---

Adding Kevin Wang for further review, as he sent a related patch in d36893362d22 ("drm/amd/powerplay: fix smu clock type change miss error")

I assume this one is still required as it triggers the same warning. Kevin, can you have a look?

Arnd

Quoted 26 lines
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +2 -2
index 0f14fe14ecd8..e62dd6919b24 100644
@@ -992,7 +992,7 @@ static int vega20_print_clk_levels(struct smu_context *smu,
                break;
 
        case SMU_SOCCLK:
-               ret = smu_get_current_clk_freq(smu, PPCLK_SOCCLK, &now);
+               ret = smu_get_current_clk_freq(smu, SMU_SOCCLK, &now);
                if (ret) {
                        pr_err("Attempt to get current socclk Failed!");
                        return ret;
@@ -1013,7 +1013,7 @@ static int vega20_print_clk_levels(struct smu_context *smu,
                break;
 
        case SMU_FCLK:
-               ret = smu_get_current_clk_freq(smu, PPCLK_FCLK, &now);
+               ret = smu_get_current_clk_freq(smu, SMU_FCLK, &now);
                if (ret) {
                        pr_err("Attempt to get current fclk Failed!");
                        return ret;

drivers/gpu/drm/amd/powerplay/vega20_ppt.c static int vega20_print_clk_levels(struct smu_context *smu, · line 1034

Quoted 8 lines
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +1 -1
@@ -1028,7 +1028,7 @@ static int vega20_print_clk_levels(struct smu_context *smu,
                break;
 
        case SMU_DCEFCLK:
-               ret = smu_get_current_clk_freq(smu, PPCLK_DCEFCLK, &now);
+               ret = smu_get_current_clk_freq(smu, SMU_DCEFCLK, &now);
                if (ret) {
                        pr_err("Attempt to get current dcefclk Failed!");
                        return ret;

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#15 lore raw

Re: [PATCH 6/7] drm/amd/powerplay: Use proper enums in vega20_print_clk_levels

Quoted 29 lines · Arnd Bergmann
Quoted 19 lines · Nathan Chancellor

clang warns:

drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:995:39: warning:
implicit conversion from enumeration type 'PPCLK_e' to different enumeration type 'enum smu_clk_type' [-Wenum-conversion]

                ret = smu_get_current_clk_freq(smu, PPCLK_SOCCLK, &now);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:1016:39: warning:
implicit conversion from enumeration type 'PPCLK_e' to different
enumeration type 'enum smu_clk_type' [-Wenum-conversion]
                ret = smu_get_current_clk_freq(smu, PPCLK_FCLK, &now);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:1031:39: warning:
implicit conversion from enumeration type 'PPCLK_e' to different
enumeration type 'enum smu_clk_type' [-Wenum-conversion]
                ret = smu_get_current_clk_freq(smu, PPCLK_DCEFCLK, &now);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
Quoted 7 lines

The values are mapped one to one in vega20_get_smu_clk_index so just use the proper enums here.

Fixes 096761014227 ("drm/amd/powerplay: support sysfs to get socclk, fclk, dcefclk")

---

Quoted 7 lines

Adding Kevin Wang for further review, as he sent a related patch in d36893362d22 ("drm/amd/powerplay: fix smu clock type change miss error")

I assume this one is still required as it triggers the same warning. Kevin, can you have a look?

Arnd

Indeed, this one and https://github.com/ClangBuiltLinux/linux/issues/586
are still outstanding.

https://patchwork.freedesktop.org/patch/315581/

Cheers,
Nathan

Quoted 35 lines
Quoted 35 lines
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +3 -3
index 0f14fe14ecd8..e62dd6919b24 100644
@@ -992,7 +992,7 @@ static int vega20_print_clk_levels(struct smu_context *smu,
                break;
 
        case SMU_SOCCLK:
-               ret = smu_get_current_clk_freq(smu, PPCLK_SOCCLK, &now);
+               ret = smu_get_current_clk_freq(smu, SMU_SOCCLK, &now);
                if (ret) {
                        pr_err("Attempt to get current socclk Failed!");
                        return ret;
@@ -1013,7 +1013,7 @@ static int vega20_print_clk_levels(struct smu_context *smu,
                break;
 
        case SMU_FCLK:
-               ret = smu_get_current_clk_freq(smu, PPCLK_FCLK, &now);
+               ret = smu_get_current_clk_freq(smu, SMU_FCLK, &now);
                if (ret) {
                        pr_err("Attempt to get current fclk Failed!");
                        return ret;
@@ -1028,7 +1028,7 @@ static int vega20_print_clk_levels(struct smu_context *smu,
                break;
 
        case SMU_DCEFCLK:
-               ret = smu_get_current_clk_freq(smu, PPCLK_DCEFCLK, &now);
+               ret = smu_get_current_clk_freq(smu, SMU_DCEFCLK, &now);
                if (ret) {
                        pr_err("Attempt to get current dcefclk Failed!");
                        return ret;
#16 lore raw

RE: [PATCH 6/7] drm/amd/powerplay: Use proper enums in vega20_print_clk_levels

Thanks! This is reviewed-by: Evan Quan <[email protected]>

Regards
Evan

Quoted 94 lines

-----Original Message-----
From: Nathan Chancellor <[email protected]>
Sent: Monday, July 15, 2019 11:40 PM
To: Arnd Bergmann <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Zhou, David(ChunMing) <[email protected]>; Wentland, Harry <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Rex Zhu <[email protected]>; Quan, Evan <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; amd-gfx list <[email protected]>; dri- devel <[email protected]>; Linux Kernel Mailing List <linux- [email protected]>; clang-built-linux <clang-built- [email protected]>; Wang, Kevin(Yang) <[email protected]>
Subject: Re: [PATCH 6/7] drm/amd/powerplay: Use proper enums in vega20_print_clk_levels

Quoted 6 lines · Arnd Bergmann
Quoted 4 lines · Nathan Chancellor

clang warns:

drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:995:39:

warning:

Quoted 6 lines
Quoted 6 lines

implicit conversion from enumeration type 'PPCLK_e' to different enumeration type 'enum smu_clk_type' [-Wenum-conversion]

                ret = smu_get_current_clk_freq(smu, PPCLK_SOCCLK, &now);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:1016:39:

warning:

Quoted 6 lines
Quoted 6 lines

implicit conversion from enumeration type 'PPCLK_e' to different enumeration type 'enum smu_clk_type' [-Wenum-conversion]

                ret = smu_get_current_clk_freq(smu, PPCLK_FCLK, &now);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:1031:39:

warning:

Quoted 15 lines
Quoted 6 lines

implicit conversion from enumeration type 'PPCLK_e' to different enumeration type 'enum smu_clk_type' [-Wenum-conversion]

                ret = smu_get_current_clk_freq(smu, PPCLK_DCEFCLK, &now);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~

Quoted 8 lines

The values are mapped one to one in vega20_get_smu_clk_index so just use the proper enums here.

Fixes 096761014227 ("drm/amd/powerplay: support sysfs to get

socclk, fclk, dcefclk")

---

Quoted 8 lines

Adding Kevin Wang for further review, as he sent a related patch in d36893362d22 ("drm/amd/powerplay: fix smu clock type change miss error")

I assume this one is still required as it triggers the same warning. Kevin, can you have a look?

Arnd

Indeed, this one and https://github.com/ClangBuiltLinux/linux/issues/586
are still outstanding.

https://patchwork.freedesktop.org/patch/315581/

Cheers,
Nathan

Quoted 10 lines

drivers/gpu/drm/amd/powerplay/vega20_ppt.c static int vega20_print_clk_levels(struct

Quoted 10 lines
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +0 -0
index 0f14fe14ecd8..e62dd6919b24 100644
@@ -992,7 +992,7 @@ static int vega20_print_clk_levels(struct

smu_context *smu,

Quoted 10 lines

drivers/gpu/drm/amd/powerplay/vega20_ppt.c static int vega20_print_clk_levels(struct

Quoted 10 lines
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +2 -1
                break;
 
        case SMU_SOCCLK:
-               ret = smu_get_current_clk_freq(smu, PPCLK_SOCCLK, &now);
+               ret = smu_get_current_clk_freq(smu, SMU_SOCCLK,
+ &now);
                if (ret) {
                        pr_err("Attempt to get current socclk Failed!");
                        return ret;
@@ -1013,7 +1013,7 @@ static int vega20_print_clk_levels(struct

smu_context *smu,

Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +0 -0
                break;
 
Quoted 17 lines
Quoted 7 lines

drivers/gpu/drm/amd/powerplay/vega20_ppt.c static int vega20_print_clk_levels(struct

Quoted 7 lines
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +1 -1
        case SMU_FCLK:
-               ret = smu_get_current_clk_freq(smu, PPCLK_FCLK, &now);
+               ret = smu_get_current_clk_freq(smu, SMU_FCLK, &now);
                if (ret) {
                        pr_err("Attempt to get current fclk Failed!");
                        return ret;
@@ -1028,7 +1028,7 @@ static int vega20_print_clk_levels(struct

smu_context *smu,

Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +2 -1
                break;
 
        case SMU_DCEFCLK:
-               ret = smu_get_current_clk_freq(smu, PPCLK_DCEFCLK, &now);
+               ret = smu_get_current_clk_freq(smu, SMU_DCEFCLK,
+ &now);
                if (ret) {
                        pr_err("Attempt to get current dcefclk Failed!");
                        return ret;

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#17 lore raw

PATCH 7/7 drm/amd/powerplay: Zero initialize current_rpm in vega20_get_fan_speed_percent

In reply to Nathan Chancellor

clang warns (trimmed for brevity):

drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c:3023:8: warning:
variable 'current_rpm' is used uninitialized whenever '?:' condition is false [-Wsometimes-uninitialized]

        ret = smu_get_current_rpm(smu, &current_rpm);
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

smu_get_current_rpm expands to a ternary operator conditional on smu->funcs->get_current_rpm being not NULL. When this is false, current_rpm will be uninitialized. Zero initialize current_rpm to avoid using random stack values if that ever happens.

Fixes ee0db82027ee ("drm/amd/powerplay: move PPTable_t uses into asic level")
---
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +1 -2
index e62dd6919b24..e37b39987587 100644
@@ -3016,8 +3016,7 @@ static int vega20_get_fan_speed_percent(struct smu_context *smu,
 					uint32_t *speed)
 {
 	int ret = 0;
-	uint32_t percent = 0;
-	uint32_t current_rpm;
+	uint32_t current_rpm = 0, percent = 0;
 	PPTable_t *pptable = smu->smu_table.driver_pptable;
 
 	ret = smu_get_current_rpm(smu, &current_rpm);
Signature · 1 line
2.22.0
Applied
#18 lore raw
In reply to Nathan Chancellor

Applied the series. thanks!

Alex

Quoted 18 lines · Nathan Chancellor

Hi all,

I don't do threaded patches very often so if I have messed something up, please forgive me :)

This series fixes all of the clang warnings that I saw added in next-20190703. The full list is visible in the gist linked below and each full individual warning can be seen in the GitHub link in each patch.

https://gist.github.com/5411af08b96c99b14e60c60800e99a47

All of the warnings are fixed in what I believe is the optimal way but the enum conversion warnings were the trickiest; please review carefully as the code paths for some of them have changed (especially in patch 3 and 6).

Quoted 6 lines

Thank you!
Nathan
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#19 lore raw
Quoted 3 lines · Alex Deucher

Applied the series. thanks!

Alex

Thank you :)

I don't see the enum conversion ones in your current tree. If they indeed caused issues, could you guys please look into fixing the warnings properly yourselves (maybe something like Arnd's patch?) or let me know how you would like them fixed (explicit casts, changing type to int, etc)?

https://patchwork.freedesktop.org/patch/316466/

Cheers,
Nathan