drm/amdgpu: suppress compile warnings
Subsystems (3)
PATCH 1/1 drm/amdgpu: suppress compile warnings
Suppress the compile warnings below:
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu13/smu_v13_0_7_ppt.c:1407:12: warning:
stack frame size (1040) exceeds limit (1024) in 'smu_v13_0_7_get_power_profile_mode' [-Wframe-larger-than] drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:1986:6: warning:
no previous prototype for function 'gfx_v11_0_rlc_stop' [-Wmissing-prototypes]
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 +- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1 -1
@@ -1983,7 +1983,7 @@ static int gfx_v11_0_init_csb(struct amdgpu_device *adev)return 0 ; } -void gfx_v11_0_rlc_stop (struct amdgpu_device *adev) +static void gfx_v11_0_rlc_stop (struct amdgpu_device *adev) {u32 tmp =RREG32_SOC15 (GC ,0 , regRLC_CNTL);
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +10 -2
@@ -1406,7 +1406,7 @@ static int smu_v13_0_7_get_power_limit(struct smu_context *smu,static int smu_v13_0_7_get_power_profile_mode (struct smu_context *smu,char *buf) { -DpmActivityMonitorCoeffIntExternal_t activity_monitor_external[PP_SMC_POWER_PROFILE_COUNT ]; +DpmActivityMonitorCoeffIntExternal_t *activity_monitor_external;uint32_t i, j, size =0 ;int16_t workload_type =0 ;int result =0 ;
@@ -1414,6 +1414,11 @@ static int smu_v13_0_7_get_power_profile_mode(struct smu_context *smu, char *bufif (!buf)return -EINVAL ; + activity_monitor_external =kzalloc (sizeof (DpmActivityMonitorCoeffIntExternal_t) *PP_SMC_POWER_PROFILE_COUNT , +GFP_KERNEL ); +if (!activity_monitor_external) +return -ENOMEM ; + size +=sysfs_emit_at (buf, size," " );for (i =0 ; i <=PP_SMC_POWER_PROFILE_WINDOW3D ; i++) size += sysfs_emit_at(buf, size, "%-14s%s", amdgpu_pp_profile_name[i],
@@ -1426,14 +1431,17 @@ static int smu_v13_0_7_get_power_profile_mode(struct smu_context *smu, char *buf workload_type =smu_cmn_to_asic_specific_index (smu,CMN2ASIC_MAPPING_WORKLOAD , i); -if (workload_type <0 ) +if (workload_type <0 ) { +kfree (activity_monitor_external);return -EINVAL ; + } result =smu_cmn_update_table (smu,SMU_TABLE_ACTIVITY_MONITOR_COEFF , workload_type, (void *)(&activity_monitor_external[i]), false);if (result) {dev_err (smu->adev->dev,"[%s] Failed to get activity monitor!" , __func__); +kfree (activity_monitor_external);return result; } }
Signature · 1 line
2.29.0
Am 30.05.22 um 08:50 schrieb Evan Quan:
Quoted 41 lines
Suppress the compile warnings below:
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu13/smu_v13_0_7_ppt.c:1407:12: warning:
stack frame size (1040) exceeds limit (1024) in 'smu_v13_0_7_get_power_profile_mode' [-Wframe-larger-than]drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:1986:6: warning:
no previous prototype for function 'gfx_v11_0_rlc_stop' [-Wmissing-prototypes]Signed-off-by Evan Quan <[email protected]>Change-Id I679436c91cb98afb9fcbef8942fd90a17e5234b5--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 +- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1
-1@@ -1983,7 +1983,7 @@ static int gfx_v11_0_init_csb(struct amdgpu_device *adev)return 0 ; } -void gfx_v11_0_rlc_stop (struct amdgpu_device *adev) +static void gfx_v11_0_rlc_stop (struct amdgpu_device *adev) {u32 tmp =RREG32_SOC15 (GC ,0 , regRLC_CNTL);drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +1
-1@@ -1406,7 +1406,7 @@ static int smu_v13_0_7_get_power_limit(struct smu_context *smu,static int smu_v13_0_7_get_power_profile_mode (struct smu_context *smu,char *buf) { -DpmActivityMonitorCoeffIntExternal_t activity_monitor_external[PP_SMC_POWER_PROFILE_COUNT ]; +DpmActivityMonitorCoeffIntExternal_t *activity_monitor_external;uint32_t i, j, size =0 ;int16_t workload_type =0 ;int result =0 ;
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c static int smu_v13_0_7_get_power_profile_mode(struct smu_context *smu, char *buf · line 1418
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +2
-0@@ -1414,6 +1414,11 @@ static int smu_v13_0_7_get_power_profile_mode(struct smu_context *smu, char *bufif (!buf)return -EINVAL ; + activity_monitor_external =kzalloc (sizeof (DpmActivityMonitorCoeffIntExternal_t) *PP_SMC_POWER_PROFILE_COUNT , +GFP_KERNEL );
The static checkers will warn about that as well. Please use kcalloc(sizeof(...), count, GFP_KERNEL);
Apart from that looks good to me.
Regards,
Christian.
Quoted 25 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +7
-1+if (!activity_monitor_external) +return -ENOMEM ; + size +=sysfs_emit_at (buf, size," " );for (i =0 ; i <=PP_SMC_POWER_PROFILE_WINDOW3D ; i++) size += sysfs_emit_at(buf, size, "%-14s%s", amdgpu_pp_profile_name[i],@@ -1426,14 +1431,17 @@ static int smu_v13_0_7_get_power_profile_mode(struct smu_context *smu, char *buf workload_type =smu_cmn_to_asic_specific_index (smu,CMN2ASIC_MAPPING_WORKLOAD , i); -if (workload_type <0 ) +if (workload_type <0 ) { +kfree (activity_monitor_external);return -EINVAL ; + } result =smu_cmn_update_table (smu,SMU_TABLE_ACTIVITY_MONITOR_COEFF , workload_type, (void *)(&activity_monitor_external[i]), false);if (result) {dev_err (smu->adev->dev,"[%s] Failed to get activity monitor!" , __func__); +kfree (activity_monitor_external);return result; } }
[AMD Official Use Only - General]
Quoted 65 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Monday, May 30, 2022 3:12 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: suppress compile warningsAm 30.05.22 um 08:50 schrieb Evan Quan:
Quoted 3 lines
Suppress the compile warnings below:
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu13/smu_v13_0_7_ppt.c:1407:12: warning:Quoted 11 lines
stack frame size (1040) exceeds limit (1024) in '
smu_v13_0_7_get_power_profile_mode' [-Wframe-larger-than]drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c:1986:6: warning:
no previous prototype for function 'gfx_v11_0_rlc_stop' [-Wmissing-prototypes]Signed-off-by Evan Quan <[email protected]>Change-Id I679436c91cb98afb9fcbef8942fd90a17e5234b5--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 +- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 12++++++++++--
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c static int gfx_v11_0_init_csb(struct
Quoted 8 lines
2 files changed, 11 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +0
-0@@ -1983,7 +1983,7 @@ static int gfx_v11_0_init_csb(struct
amdgpu_device*adev)Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1
-1return 0 ; } -void gfx_v11_0_rlc_stop (struct amdgpu_device *adev) +static void gfx_v11_0_rlc_stop (struct amdgpu_device *adev) {u32 tmp =RREG32_SOC15 (GC ,0 , regRLC_CNTL);drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +0
-0drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c static int smu_v13_0_7_get_power_limit(struct · line 1408
Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +0
-0@@ -1406,7 +1406,7 @@ static int smu_v13_0_7_get_power_limit(structsmu_context *smu, static int smu_v13_0_7_get_power_profile_mode(struct smu_context*smu, char *buf)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c static int smu_v13_0_7_get_power_limit(struct · line 1410
Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +0
-1{ - DpmActivityMonitorCoeffIntExternal_tactivity_monitor_external[PP_SMC_POWER_PROFILE_COUNT];
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c static int
Quoted 5 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +1
-0+DpmActivityMonitorCoeffIntExternal_t *activity_monitor_external;uint32_t i, j, size =0 ;int16_t workload_type =0 ;int result = 0;drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +0
-0@@ -1414,6 +1414,11 @@ static intsmu_v13_0_7_get_power_profile_mode(struct
smu_context*smu, char *bufQuoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +0
-0if (!buf)return -EINVAL ;
Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c static int · line 1417
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +1
-0+ activity_monitor_external =kzalloc(sizeof(DpmActivityMonitorCoeffIntExternal_t) *
PP_SMC_POWER_PROFILE_COUNT,drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c static int smu_v13_0_7_get_power_profile_mode(struct smu_context *smu, char *buf · line 1418
Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +1
-0+ GFP_KERNEL);The static checkers will warn about that as well. Please use
kcalloc(sizeof(...), count, GFP_KERNEL);
[Quan, Evan] I actually do not know that.. The warning is about the stack frame size (1040). The space allocated by kzalloc/kmalloc is not on the stack. Per my knowledge, it should not have such limitation. Did I miss something?
BR
Evan
Quoted 38 lines
Apart from that looks good to me.
Regards,
Christian.Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +3
-0+if (!activity_monitor_external) +return -ENOMEM ; + size +=sysfs_emit_at (buf, size," " );for (i =0 ; i <=PP_SMC_POWER_PROFILE_WINDOW3D ; i++) size += sysfs_emit_at(buf, size, "%-14s%s",amdgpu_pp_profile_name[i], @@ -1426,14 +1431,17 @@ static int
smu_v13_0_7_get_power_profile_mode(struct
smu_context*smu, char *bufQuoted 2 lines
workload_type= smu_cmn_to_asic_specific_index(smu,
CMN2ASIC_MAPPING_WORKLOAD,drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c static int smu_v13_0_7_get_power_profile_mode(struct smu_context *smu, char *buf · line 1439
Quoted 9 lines
i);
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +3
-1-if (workload_type <0 ) +if (workload_type <0 ) { +kfree (activity_monitor_external);return -EINVAL ; + } result = smu_cmn_update_table(smu,
SMU_TABLE_ACTIVITY_MONITOR_COEFF,workload_type,Quoted 1 line
(void
*)(&activity_monitor_external[i]), false);
Quoted 2 lines
if (result) { dev_err(smu->adev->dev, "[%s] Failed to get activitymonitor!",
Quoted 5 lines
__func__);drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +1
-0+kfree (activity_monitor_external);return result; } }