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
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 <[email protected]>
---
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
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)")
Link: https://github.com/ClangBuiltLinux/linux/issues/583
Signed-off-by: Nathan Chancellor <[email protected]>
---
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
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 <[email protected]>
---
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
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 <[email protected]>
---
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
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 <[email protected]>
---
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
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 <[email protected]>
---
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
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, ¤t_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 <[email protected]>
---
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, ¤t_rpm);
--
2.22.0
Applied the series. thanks!
Alex
On Thu, Jul 4, 2019 at 3:26 AM Nathan Chancellor
<[email protected]> 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
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
On Thu, Jul 4, 2019 at 7:52 AM Nathan Chancellor
<[email protected]> 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 <[email protected]>
I ran into the same one now, and saw your version before sending an
identical patch.
Acked-by: Arnd Bergmann <[email protected]>
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
On Thu, Jul 4, 2019 at 7:52 AM Nathan Chancellor
<[email protected]> 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 <[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)")
Signed-off-by: Arnd Bergmann <[email protected]>
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;
}
On Tue, Jul 09, 2019 at 08:51:33PM +0200, Arnd Bergmann wrote:
> On Thu, Jul 4, 2019 at 7:52 AM Nathan Chancellor
> <[email protected]> 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
On Thu, Jul 4, 2019 at 7:52 AM Nathan Chancellor
<[email protected]> 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 <[email protected]>
> ---
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;
On Mon, Jul 15, 2019 at 11:25:29AM +0200, Arnd Bergmann wrote:
> On Thu, Jul 4, 2019 at 7:52 AM Nathan Chancellor
> <[email protected]> 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 <[email protected]>
> > ---
>
> 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;
Thanks! This is reviewed-by: Evan Quan <[email protected]>
Regards
Evan
> -----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
>
> On Mon, Jul 15, 2019 at 11:25:29AM +0200, Arnd Bergmann wrote:
> > On Thu, Jul 4, 2019 at 7:52 AM Nathan Chancellor
> > <[email protected]> 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 <[email protected]>
> > > ---
> >
> > 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;
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 <[email protected]>
> ---
> 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
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 <[email protected]>
>> ---
>> 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 <[email protected]>
>> &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
>
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 <[email protected]>
>>> ---
>>> 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 <[email protected]>
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
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
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 <[email protected]>
>>>> ---
>>>> 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 <[email protected]>
>
> 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
>> [email protected]
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>
>