linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] amdgpu clang warning fixes on next-20190703
@ 2019-07-04  5:52 Nathan Chancellor
  2019-07-04  5:52 ` [PATCH 1/7] drm/amdgpu/mes10.1: Fix header guard Nathan Chancellor
                   ` (7 more replies)
  0 siblings, 8 replies; 20+ messages in thread
From: Nathan Chancellor @ 2019-07-04  5:52 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David (ChunMing) Zhou,
	Harry Wentland, Leo Li, Rex Zhu, Evan Quan
  Cc: David Airlie, Daniel Vetter, amd-gfx, dri-devel, linux-kernel,
	clang-built-linux

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

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

* [PATCH 1/7] drm/amdgpu/mes10.1: Fix header guard
  2019-07-04  5:52 [PATCH 0/7] amdgpu clang warning fixes on next-20190703 Nathan Chancellor
@ 2019-07-04  5:52 ` Nathan Chancellor
  2019-07-08 20:24   ` Arnd Bergmann
  2019-07-04  5:52 ` [PATCH 2/7] drm/amd/powerplay: Use memset to initialize metrics structs Nathan Chancellor
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: Nathan Chancellor @ 2019-07-04  5:52 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David (ChunMing) Zhou,
	Harry Wentland, Leo Li, Rex Zhu, Evan Quan
  Cc: David Airlie, Daniel Vetter, amd-gfx, dri-devel, linux-kernel,
	clang-built-linux, 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__
 1 warning generated.

Capitalize the V.

Fixes: 886f82aa7a1d ("drm/amdgpu/mes10.1: add ip block mes10.1 (v2)")
Link: https://github.com/ClangBuiltLinux/linux/issues/582
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/gpu/drm/amd/amdgpu/mes_v10_1.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/mes_v10_1.h b/drivers/gpu/drm/amd/amdgpu/mes_v10_1.h
index 17b9b53fa892..9afd6ddb01e9 100644
--- a/drivers/gpu/drm/amd/amdgpu/mes_v10_1.h
+++ b/drivers/gpu/drm/amd/amdgpu/mes_v10_1.h
@@ -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;
 
-- 
2.22.0


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

* [PATCH 2/7] drm/amd/powerplay: Use memset to initialize metrics structs
  2019-07-04  5:52 [PATCH 0/7] amdgpu clang warning fixes on next-20190703 Nathan Chancellor
  2019-07-04  5:52 ` [PATCH 1/7] drm/amdgpu/mes10.1: Fix header guard Nathan Chancellor
@ 2019-07-04  5:52 ` Nathan Chancellor
  2019-07-04  5:52 ` [PATCH 3/7] drm/amd/powerplay: Use proper enums in smu_adjust_power_state_dynamic Nathan Chancellor
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 20+ messages in thread
From: Nathan Chancellor @ 2019-07-04  5:52 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David (ChunMing) Zhou,
	Harry Wentland, Leo Li, Rex Zhu, Evan Quan
  Cc: David Airlie, Daniel Vetter, amd-gfx, dri-devel, linux-kernel,
	clang-built-linux, 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/022e41c0-8465-dc7a-a45c-64187ecd9684@amd.com/
[2]: https://lore.kernel.org/lkml/20181128.215241.702406654469517539.davem@davemloft.net/
[3]: https://lore.kernel.org/lkml/20181116150432.2408a075@redhat.com/

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)")
Link: https://github.com/ClangBuiltLinux/linux/issues/583
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
index e00397f84b2f..f5d2ada05bc6 100644
--- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c
@@ -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)
-- 
2.22.0


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

* [PATCH 3/7] drm/amd/powerplay: Use proper enums in smu_adjust_power_state_dynamic
  2019-07-04  5:52 [PATCH 0/7] amdgpu clang warning fixes on next-20190703 Nathan Chancellor
  2019-07-04  5:52 ` [PATCH 1/7] drm/amdgpu/mes10.1: Fix header guard Nathan Chancellor
  2019-07-04  5:52 ` [PATCH 2/7] drm/amd/powerplay: Use memset to initialize metrics structs Nathan Chancellor
@ 2019-07-04  5:52 ` Nathan Chancellor
  2019-07-04  5:52 ` [PATCH 4/7] drm/amd/powerplay: Zero initialize freq in smu_v11_0_get_current_clk_freq Nathan Chancellor
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 20+ messages in thread
From: Nathan Chancellor @ 2019-07-04  5:52 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David (ChunMing) Zhou,
	Harry Wentland, Leo Li, Rex Zhu, Evan Quan
  Cc: David Airlie, Daniel Vetter, amd-gfx, dri-devel, linux-kernel,
	clang-built-linux, 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)")
Link: https://github.com/ClangBuiltLinux/linux/issues/584
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index 31152d495f69..e897469f7431 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -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:
-- 
2.22.0


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

* [PATCH 4/7] drm/amd/powerplay: Zero initialize freq in smu_v11_0_get_current_clk_freq
  2019-07-04  5:52 [PATCH 0/7] amdgpu clang warning fixes on next-20190703 Nathan Chancellor
                   ` (2 preceding siblings ...)
  2019-07-04  5:52 ` [PATCH 3/7] drm/amd/powerplay: Use proper enums in smu_adjust_power_state_dynamic Nathan Chancellor
@ 2019-07-04  5:52 ` Nathan Chancellor
  2019-07-04  5:52 ` [PATCH 5/7] drm/amd/display: Use proper enum conversion functions Nathan Chancellor
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 20+ messages in thread
From: Nathan Chancellor @ 2019-07-04  5:52 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David (ChunMing) Zhou,
	Harry Wentland, Leo Li, Rex Zhu, Evan Quan
  Cc: David Airlie, Daniel Vetter, amd-gfx, dri-devel, linux-kernel,
	clang-built-linux, 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)")
Link: https://github.com/ClangBuiltLinux/linux/issues/585
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
index 632a20587c8b..a6f8cd6df7f1 100644
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
@@ -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;
-- 
2.22.0


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

* [PATCH 5/7] drm/amd/display: Use proper enum conversion functions
  2019-07-04  5:52 [PATCH 0/7] amdgpu clang warning fixes on next-20190703 Nathan Chancellor
                   ` (3 preceding siblings ...)
  2019-07-04  5:52 ` [PATCH 4/7] drm/amd/powerplay: Zero initialize freq in smu_v11_0_get_current_clk_freq Nathan Chancellor
@ 2019-07-04  5:52 ` Nathan Chancellor
  2019-07-09 18:51   ` Arnd Bergmann
  2019-07-19  3:16   ` Nathan Chancellor
  2019-07-04  5:52 ` [PATCH 6/7] drm/amd/powerplay: Use proper enums in vega20_print_clk_levels Nathan Chancellor
                   ` (2 subsequent siblings)
  7 siblings, 2 replies; 20+ messages in thread
From: Nathan Chancellor @ 2019-07-04  5:52 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David (ChunMing) Zhou,
	Harry Wentland, Leo Li, Rex Zhu, Evan Quan
  Cc: David Airlie, Daniel Vetter, amd-gfx, dri-devel, linux-kernel,
	clang-built-linux, 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)")
Link: https://github.com/ClangBuiltLinux/linux/issues/586
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
index eac09bfe3be2..0f76cfff9d9b 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
@@ -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;
 	}
-- 
2.22.0


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

* [PATCH 6/7] drm/amd/powerplay: Use proper enums in vega20_print_clk_levels
  2019-07-04  5:52 [PATCH 0/7] amdgpu clang warning fixes on next-20190703 Nathan Chancellor
                   ` (4 preceding siblings ...)
  2019-07-04  5:52 ` [PATCH 5/7] drm/amd/display: Use proper enum conversion functions Nathan Chancellor
@ 2019-07-04  5:52 ` Nathan Chancellor
  2019-07-15  9:25   ` Arnd Bergmann
  2019-07-04  5:52 ` [PATCH 7/7] drm/amd/powerplay: Zero initialize current_rpm in vega20_get_fan_speed_percent Nathan Chancellor
  2019-07-08 15:55 ` [PATCH 0/7] amdgpu clang warning fixes on next-20190703 Alex Deucher
  7 siblings, 1 reply; 20+ messages in thread
From: Nathan Chancellor @ 2019-07-04  5:52 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David (ChunMing) Zhou,
	Harry Wentland, Leo Li, Rex Zhu, Evan Quan
  Cc: David Airlie, Daniel Vetter, amd-gfx, dri-devel, linux-kernel,
	clang-built-linux, 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")
Link: https://github.com/ClangBuiltLinux/linux/issues/587
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
index 0f14fe14ecd8..e62dd6919b24 100644
--- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
@@ -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;
-- 
2.22.0


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

* [PATCH 7/7] drm/amd/powerplay: Zero initialize current_rpm in vega20_get_fan_speed_percent
  2019-07-04  5:52 [PATCH 0/7] amdgpu clang warning fixes on next-20190703 Nathan Chancellor
                   ` (5 preceding siblings ...)
  2019-07-04  5:52 ` [PATCH 6/7] drm/amd/powerplay: Use proper enums in vega20_print_clk_levels Nathan Chancellor
@ 2019-07-04  5:52 ` Nathan Chancellor
  2019-07-08 15:55 ` [PATCH 0/7] amdgpu clang warning fixes on next-20190703 Alex Deucher
  7 siblings, 0 replies; 20+ messages in thread
From: Nathan Chancellor @ 2019-07-04  5:52 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David (ChunMing) Zhou,
	Harry Wentland, Leo Li, Rex Zhu, Evan Quan
  Cc: David Airlie, Daniel Vetter, amd-gfx, dri-devel, linux-kernel,
	clang-built-linux, 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")
Link: https://github.com/ClangBuiltLinux/linux/issues/588
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
index e62dd6919b24..e37b39987587 100644
--- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
@@ -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);
-- 
2.22.0


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

* Re: [PATCH 0/7] amdgpu clang warning fixes on next-20190703
  2019-07-04  5:52 [PATCH 0/7] amdgpu clang warning fixes on next-20190703 Nathan Chancellor
                   ` (6 preceding siblings ...)
  2019-07-04  5:52 ` [PATCH 7/7] drm/amd/powerplay: Zero initialize current_rpm in vega20_get_fan_speed_percent Nathan Chancellor
@ 2019-07-08 15:55 ` Alex Deucher
  2019-07-09  7:22   ` Nathan Chancellor
  7 siblings, 1 reply; 20+ messages in thread
From: Alex Deucher @ 2019-07-08 15:55 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Alex Deucher, Christian König, David (ChunMing) Zhou,
	Harry Wentland, Leo Li, Rex Zhu, Evan Quan, David Airlie, LKML,
	Maling list - DRI developers, clang-built-linux, amd-gfx list

Applied the series.  thanks!

Alex

On Thu, Jul 4, 2019 at 3:26 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> 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
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 1/7] drm/amdgpu/mes10.1: Fix header guard
  2019-07-04  5:52 ` [PATCH 1/7] drm/amdgpu/mes10.1: Fix header guard Nathan Chancellor
@ 2019-07-08 20:24   ` Arnd Bergmann
  0 siblings, 0 replies; 20+ messages in thread
From: Arnd Bergmann @ 2019-07-08 20:24 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Alex Deucher, Christian König, David (ChunMing) Zhou,
	Harry Wentland, Leo Li, Rex Zhu, Evan Quan, David Airlie,
	Daniel Vetter, amd-gfx list, dri-devel,
	Linux Kernel Mailing List, clang-built-linux

On Thu, Jul 4, 2019 at 7:52 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> 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)")
> Link: https://github.com/ClangBuiltLinux/linux/issues/582
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

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

Acked-by: Arnd Bergmann <arnd@arndb.de>

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

* Re: [PATCH 0/7] amdgpu clang warning fixes on next-20190703
  2019-07-08 15:55 ` [PATCH 0/7] amdgpu clang warning fixes on next-20190703 Alex Deucher
@ 2019-07-09  7:22   ` Nathan Chancellor
  0 siblings, 0 replies; 20+ messages in thread
From: Nathan Chancellor @ 2019-07-09  7:22 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Alex Deucher, Christian König, David (ChunMing) Zhou,
	Harry Wentland, Leo Li, Rex Zhu, Evan Quan, David Airlie, LKML,
	Maling list - DRI developers, clang-built-linux, amd-gfx list

On Mon, Jul 08, 2019 at 11:55:50AM -0400, Alex Deucher wrote:
> 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

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

* Re: [PATCH 5/7] drm/amd/display: Use proper enum conversion functions
  2019-07-04  5:52 ` [PATCH 5/7] drm/amd/display: Use proper enum conversion functions Nathan Chancellor
@ 2019-07-09 18:51   ` Arnd Bergmann
  2019-07-09 20:21     ` Nathan Chancellor
  2019-07-19  3:16   ` Nathan Chancellor
  1 sibling, 1 reply; 20+ messages in thread
From: Arnd Bergmann @ 2019-07-09 18:51 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Alex Deucher, Christian König, David (ChunMing) Zhou,
	Harry Wentland, Leo Li, Rex Zhu, Evan Quan, David Airlie,
	Daniel Vetter, amd-gfx list, dri-devel,
	Linux Kernel Mailing List, clang-built-linux

On Thu, Jul 4, 2019 at 7:52 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> 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.

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

From 61316b80c852d103bb61e1ce9904002414600125 Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <arnd@arndb.de>
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)")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
index eac09bfe3be2..88e3f8456b1c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
@@ -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;
        }

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

* Re: [PATCH 5/7] drm/amd/display: Use proper enum conversion functions
  2019-07-09 18:51   ` Arnd Bergmann
@ 2019-07-09 20:21     ` Nathan Chancellor
  0 siblings, 0 replies; 20+ messages in thread
From: Nathan Chancellor @ 2019-07-09 20:21 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Alex Deucher, Christian König, David (ChunMing) Zhou,
	Harry Wentland, Leo Li, Rex Zhu, Evan Quan, David Airlie,
	Daniel Vetter, amd-gfx list, dri-devel,
	Linux Kernel Mailing List, clang-built-linux

On Tue, Jul 09, 2019 at 08:51:33PM +0200, Arnd Bergmann wrote:
> On Thu, Jul 4, 2019 at 7:52 AM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > 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.
> 
> 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

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

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

* Re: [PATCH 6/7] drm/amd/powerplay: Use proper enums in vega20_print_clk_levels
  2019-07-04  5:52 ` [PATCH 6/7] drm/amd/powerplay: Use proper enums in vega20_print_clk_levels Nathan Chancellor
@ 2019-07-15  9:25   ` Arnd Bergmann
  2019-07-15 15:39     ` Nathan Chancellor
  0 siblings, 1 reply; 20+ messages in thread
From: Arnd Bergmann @ 2019-07-15  9:25 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Alex Deucher, Christian König, David (ChunMing) Zhou,
	Harry Wentland, Leo Li, Rex Zhu, Evan Quan, David Airlie,
	Daniel Vetter, amd-gfx list, dri-devel,
	Linux Kernel Mailing List, clang-built-linux, Kevin Wang

On Thu, Jul 4, 2019 at 7:52 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> 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")
> Link: https://github.com/ClangBuiltLinux/linux/issues/587
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---

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

>  drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
> index 0f14fe14ecd8..e62dd6919b24 100644
> --- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
> +++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
> @@ -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;

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

* Re: [PATCH 6/7] drm/amd/powerplay: Use proper enums in vega20_print_clk_levels
  2019-07-15  9:25   ` Arnd Bergmann
@ 2019-07-15 15:39     ` Nathan Chancellor
  2019-07-16  1:00       ` Quan, Evan
  0 siblings, 1 reply; 20+ messages in thread
From: Nathan Chancellor @ 2019-07-15 15:39 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Alex Deucher, Christian König, David (ChunMing) Zhou,
	Harry Wentland, Leo Li, Rex Zhu, Evan Quan, David Airlie,
	Daniel Vetter, amd-gfx list, dri-devel,
	Linux Kernel Mailing List, clang-built-linux, Kevin Wang

On Mon, Jul 15, 2019 at 11:25:29AM +0200, Arnd Bergmann wrote:
> On Thu, Jul 4, 2019 at 7:52 AM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > 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")
> > Link: https://github.com/ClangBuiltLinux/linux/issues/587
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> 
> 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

> 
> >  drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
> > index 0f14fe14ecd8..e62dd6919b24 100644
> > --- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
> > +++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
> > @@ -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;

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

* RE: [PATCH 6/7] drm/amd/powerplay: Use proper enums in vega20_print_clk_levels
  2019-07-15 15:39     ` Nathan Chancellor
@ 2019-07-16  1:00       ` Quan, Evan
  0 siblings, 0 replies; 20+ messages in thread
From: Quan, Evan @ 2019-07-16  1:00 UTC (permalink / raw)
  To: Nathan Chancellor, Arnd Bergmann
  Cc: Deucher, Alexander, Koenig, Christian, Zhou, David(ChunMing),
	Wentland, Harry, Li, Sun peng (Leo),
	Rex Zhu, David Airlie, Daniel Vetter, amd-gfx list, dri-devel,
	Linux Kernel Mailing List, clang-built-linux, Wang, Kevin(Yang)

Thanks!  This is reviewed-by: Evan Quan <evan.quan@amd.com>

Regards
Evan
> -----Original Message-----
> From: Nathan Chancellor <natechancellor@gmail.com>
> Sent: Monday, July 15, 2019 11:40 PM
> To: Arnd Bergmann <arnd@arndb.de>
> Cc: Deucher, Alexander <Alexander.Deucher@amd.com>; Koenig, Christian
> <Christian.Koenig@amd.com>; Zhou, David(ChunMing)
> <David1.Zhou@amd.com>; Wentland, Harry <Harry.Wentland@amd.com>;
> Li, Sun peng (Leo) <Sunpeng.Li@amd.com>; Rex Zhu <rex.zhu@amd.com>;
> Quan, Evan <Evan.Quan@amd.com>; David Airlie <airlied@linux.ie>; Daniel
> Vetter <daniel@ffwll.ch>; amd-gfx list <amd-gfx@lists.freedesktop.org>; dri-
> devel <dri-devel@lists.freedesktop.org>; Linux Kernel Mailing List <linux-
> kernel@vger.kernel.org>; clang-built-linux <clang-built-
> linux@googlegroups.com>; Wang, Kevin(Yang) <Kevin1.Wang@amd.com>
> Subject: Re: [PATCH 6/7] drm/amd/powerplay: Use proper enums in
> vega20_print_clk_levels
> 
> On Mon, Jul 15, 2019 at 11:25:29AM +0200, Arnd Bergmann wrote:
> > On Thu, Jul 4, 2019 at 7:52 AM Nathan Chancellor
> > <natechancellor@gmail.com> wrote:
> > >
> > > 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")
> > > Link: https://github.com/ClangBuiltLinux/linux/issues/587
> > > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > > ---
> >
> > 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
> 
> >
> > >  drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 6 +++---
> > >  1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
> > > b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
> > > index 0f14fe14ecd8..e62dd6919b24 100644
> > > --- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
> > > +++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
> > > @@ -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;

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

* Re: [PATCH 5/7] drm/amd/display: Use proper enum conversion functions
  2019-07-04  5:52 ` [PATCH 5/7] drm/amd/display: Use proper enum conversion functions Nathan Chancellor
  2019-07-09 18:51   ` Arnd Bergmann
@ 2019-07-19  3:16   ` Nathan Chancellor
  2019-07-25 16:00     ` Li, Sun peng (Leo)
  1 sibling, 1 reply; 20+ messages in thread
From: Nathan Chancellor @ 2019-07-19  3:16 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David (ChunMing) Zhou,
	Harry Wentland, Leo Li, Rex Zhu, Evan Quan
  Cc: David Airlie, Daniel Vetter, amd-gfx, dri-devel, linux-kernel,
	clang-built-linux

On Wed, Jul 03, 2019 at 10:52:16PM -0700, Nathan Chancellor wrote:
> 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)")
> Link: https://github.com/ClangBuiltLinux/linux/issues/586
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
> index eac09bfe3be2..0f76cfff9d9b 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
> @@ -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;
>  	}
> -- 
> 2.22.0
> 

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

Cheers,
Nathan

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

* Re: [PATCH 5/7] drm/amd/display: Use proper enum conversion functions
  2019-07-19  3:16   ` Nathan Chancellor
@ 2019-07-25 16:00     ` Li, Sun peng (Leo)
  2019-07-25 16:14       ` Kazlauskas, Nicholas
  0 siblings, 1 reply; 20+ messages in thread
From: Li, Sun peng (Leo) @ 2019-07-25 16:00 UTC (permalink / raw)
  To: Deucher, Alexander, Koenig, Christian, Zhou, David(ChunMing),
	Wentland, Harry, Rex Zhu, Quan, Evan
  Cc: Nathan Chancellor, David Airlie, Daniel Vetter, amd-gfx,
	dri-devel, linux-kernel, clang-built-linux



On 2019-07-18 11:16 p.m., Nathan Chancellor wrote:
> On Wed, Jul 03, 2019 at 10:52:16PM -0700, Nathan Chancellor wrote:
>> 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)")
>> Link: https://github.com/ClangBuiltLinux/linux/issues/586
>> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
>> ---
>>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
>> index eac09bfe3be2..0f76cfff9d9b 100644
>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
>> @@ -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?

>>  					  &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.

Reviewed-by: Leo Li <sunpeng.li@amd.com>

>>  						       &pp_clks))
>>  			return false;
>>  	}
>> -- 
>> 2.22.0
>>
> 
> Gentle ping for review, this is the last remaining warning that I see
> from amdgpu on next-20190718.
> 
> Cheers,
> Nathan
> 

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

* Re: [PATCH 5/7] drm/amd/display: Use proper enum conversion functions
  2019-07-25 16:00     ` Li, Sun peng (Leo)
@ 2019-07-25 16:14       ` Kazlauskas, Nicholas
  2019-07-25 17:26         ` Li, Sun peng (Leo)
  0 siblings, 1 reply; 20+ messages in thread
From: Kazlauskas, Nicholas @ 2019-07-25 16:14 UTC (permalink / raw)
  To: Li, Sun peng (Leo),
	Deucher, Alexander, Koenig, Christian, Zhou, David(ChunMing),
	Wentland, Harry, Rex Zhu, Quan, Evan
  Cc: David Airlie, linux-kernel, dri-devel, clang-built-linux,
	amd-gfx, Nathan Chancellor

On 7/25/19 12:00 PM, Li, Sun peng (Leo) wrote:
> 
> 
> On 2019-07-18 11:16 p.m., Nathan Chancellor wrote:
>> On Wed, Jul 03, 2019 at 10:52:16PM -0700, Nathan Chancellor wrote:
>>> 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)")
>>> Link: https://github.com/ClangBuiltLinux/linux/issues/586
>>> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
>>> ---
>>>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
>>> index eac09bfe3be2..0f76cfff9d9b 100644
>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
>>> @@ -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?
> 
>>>   					  &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.
> 
> Reviewed-by: Leo Li <sunpeng.li@amd.com>

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


> 
>>>   						       &pp_clks))
>>>   			return false;
>>>   	}
>>> -- 
>>> 2.22.0
>>>
>>
>> Gentle ping for review, this is the last remaining warning that I see
>> from amdgpu on next-20190718.
>>
>> Cheers,
>> Nathan
>>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 


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

* Re: [PATCH 5/7] drm/amd/display: Use proper enum conversion functions
  2019-07-25 16:14       ` Kazlauskas, Nicholas
@ 2019-07-25 17:26         ` Li, Sun peng (Leo)
  0 siblings, 0 replies; 20+ messages in thread
From: Li, Sun peng (Leo) @ 2019-07-25 17:26 UTC (permalink / raw)
  To: Kazlauskas, Nicholas, Deucher, Alexander, Koenig, Christian,
	Zhou, David(ChunMing),
	Wentland, Harry, Rex Zhu, Quan, Evan
  Cc: David Airlie, linux-kernel, dri-devel, clang-built-linux,
	amd-gfx, Nathan Chancellor



On 2019-07-25 12:14 p.m., Kazlauskas, Nicholas wrote:
> On 7/25/19 12:00 PM, Li, Sun peng (Leo) wrote:
>>
>>
>> On 2019-07-18 11:16 p.m., Nathan Chancellor wrote:
>>> On Wed, Jul 03, 2019 at 10:52:16PM -0700, Nathan Chancellor wrote:
>>>> 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)")
>>>> Link: https://github.com/ClangBuiltLinux/linux/issues/586
>>>> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
>>>> ---
>>>>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 4 ++--
>>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
>>>> index eac09bfe3be2..0f76cfff9d9b 100644
>>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
>>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c
>>>> @@ -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?
>>
>>>>   					  &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.
>>
>> Reviewed-by: Leo Li <sunpeng.li@amd.com>
> 
> 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

Good catch, I'll spin up something quick.

Leo

> 
> 
>>
>>>>   						       &pp_clks))
>>>>   			return false;
>>>>   	}
>>>> -- 
>>>> 2.22.0
>>>>
>>>
>>> Gentle ping for review, this is the last remaining warning that I see
>>> from amdgpu on next-20190718.
>>>
>>> Cheers,
>>> Nathan
>>>
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>
> 

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

end of thread, other threads:[~2019-07-25 17:26 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-04  5:52 [PATCH 0/7] amdgpu clang warning fixes on next-20190703 Nathan Chancellor
2019-07-04  5:52 ` [PATCH 1/7] drm/amdgpu/mes10.1: Fix header guard Nathan Chancellor
2019-07-08 20:24   ` Arnd Bergmann
2019-07-04  5:52 ` [PATCH 2/7] drm/amd/powerplay: Use memset to initialize metrics structs Nathan Chancellor
2019-07-04  5:52 ` [PATCH 3/7] drm/amd/powerplay: Use proper enums in smu_adjust_power_state_dynamic Nathan Chancellor
2019-07-04  5:52 ` [PATCH 4/7] drm/amd/powerplay: Zero initialize freq in smu_v11_0_get_current_clk_freq Nathan Chancellor
2019-07-04  5:52 ` [PATCH 5/7] drm/amd/display: Use proper enum conversion functions Nathan Chancellor
2019-07-09 18:51   ` Arnd Bergmann
2019-07-09 20:21     ` Nathan Chancellor
2019-07-19  3:16   ` Nathan Chancellor
2019-07-25 16:00     ` Li, Sun peng (Leo)
2019-07-25 16:14       ` Kazlauskas, Nicholas
2019-07-25 17:26         ` Li, Sun peng (Leo)
2019-07-04  5:52 ` [PATCH 6/7] drm/amd/powerplay: Use proper enums in vega20_print_clk_levels Nathan Chancellor
2019-07-15  9:25   ` Arnd Bergmann
2019-07-15 15:39     ` Nathan Chancellor
2019-07-16  1:00       ` Quan, Evan
2019-07-04  5:52 ` [PATCH 7/7] drm/amd/powerplay: Zero initialize current_rpm in vega20_get_fan_speed_percent Nathan Chancellor
2019-07-08 15:55 ` [PATCH 0/7] amdgpu clang warning fixes on next-20190703 Alex Deucher
2019-07-09  7:22   ` Nathan Chancellor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).