drm/amdgpu: Fix instances of -Wunused-const-variable with CONFIG_DEBUG_FS=n
Subsystems (3)
cover drm/amdgpu: Fix instances of -Wunused-const-variable with CONFIG_DEBUG_FS=n
Hi all,
After commit a25a9dae2067 ("drm/amd/amdgpu: enable W=1 for amdgpu"), I see a few instances of -Wunused-const-variable with configurations that do not enable CONFIG_DEBUG_FS, such as Alpine Linux's. This series includes two patches to resolve each warning I see.
---
Nathan Chancellor (2):
drm/amdgpu: Remove CONFIG_DEBUG_FS guard around body of amdgpu_rap_debugfs_init() drm/amdgpu: Move clocks closer to its only usage in amdgpu_parse_cg_state()
drivers/gpu/drm/amd/amdgpu/amdgpu_rap.c | 2 - drivers/gpu/drm/amd/pm/amdgpu_pm.c | 76 ++++++++++++++++----------------- 2 files changed, 38 insertions(+), 40 deletions(-)
---
base-commit: d297eedf83f5af96751c0da1e4355c19244a55a2
change-id: 20230615-amdgpu-wunused-const-variable-wo-debugfs-308ce8e17329
Best regards,
Signature · 1 line
Nathan Chancellor <[email protected]>
PATCH 1/2 drm/amdgpu: Remove CONFIG_DEBUG_FS guard around body of amdgpu_rap_debugfs_init()
After commit a25a9dae2067 ("drm/amd/amdgpu: enable W=1 for amdgpu"), there is an instance of -Wunused-const-variable when CONFIG_DEBUG_FS is disabled:
drivers/gpu/drm/amd/amdgpu/amdgpu_rap.c:110:37: error: unused variable 'amdgpu_rap_debugfs_ops' [-Werror,-Wunused-const-variable]
110 | static const struct file_operations amdgpu_rap_debugfs_ops = {
| ^
1 error generated.There is no reason for the body of this function to be guarded when CONFIG_DEBUG_FS is disabled, as debugfs_create_file() is a stub that just returns an error pointer in that situation. Remove the preprocessor guards so that the variable never appears unused, while not changing anything at run time.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_rap.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_rap.c +0 -2
@@ -116,7 +116,6 @@ static const struct file_operations amdgpu_rap_debugfs_ops = {void amdgpu_rap_debugfs_init (struct amdgpu_device *adev) { -#if defined(CONFIG_DEBUG_FS )struct drm_minor *minor =adev_to_drm (adev)->primary;if (!adev->psp.rap_context.context.initialized)
@@ -124,5 +123,4 @@ void amdgpu_rap_debugfs_init(struct amdgpu_device *adev)debugfs_create_file ("rap_test" ,S_IWUSR , minor->debugfs_root, adev, &amdgpu_rap_debugfs_ops); -#endif }
Signature · 1 line
2.41.0
PATCH 2/2 drm/amdgpu: Move clocks closer to its only usage in amdgpu_parse_cg_state()
In reply to Nathan ChancellorAfter commit a25a9dae2067 ("drm/amd/amdgpu: enable W=1 for amdgpu"), there is an instance of -Wunused-const-variable when CONFIG_DEBUG_FS is disabled:
drivers/gpu/drm/amd/amdgpu/../pm/amdgpu_pm.c:38:34: error: unused variable 'clocks' [-Werror,-Wunused-const-variable]
38 | static const struct cg_flag_name clocks[] = {
| ^
1 error generated.clocks is only used when CONFIG_DEBUG_FS is set, so move the definition into the CONFIG_DEBUG_FS block right above its only usage to clear up the warning.
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 76 +++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 38 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +38 -38
@@ -35,44 +35,6 @@#include <linux/pm_runtime.h> #include <asm/processor.h> -static const struct cg_flag_name clocks[] = { - {AMD_CG_SUPPORT_GFX_FGCG ,"Graphics Fine Grain Clock Gating" }, - {AMD_CG_SUPPORT_GFX_MGCG ,"Graphics Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_GFX_MGLS ,"Graphics Medium Grain memory Light Sleep" }, - {AMD_CG_SUPPORT_GFX_CGCG ,"Graphics Coarse Grain Clock Gating" }, - {AMD_CG_SUPPORT_GFX_CGLS ,"Graphics Coarse Grain memory Light Sleep" }, - {AMD_CG_SUPPORT_GFX_CGTS ,"Graphics Coarse Grain Tree Shader Clock Gating" }, - {AMD_CG_SUPPORT_GFX_CGTS_LS ,"Graphics Coarse Grain Tree Shader Light Sleep" }, - {AMD_CG_SUPPORT_GFX_CP_LS ,"Graphics Command Processor Light Sleep" }, - {AMD_CG_SUPPORT_GFX_RLC_LS ,"Graphics Run List Controller Light Sleep" }, - {AMD_CG_SUPPORT_GFX_3D_CGCG ,"Graphics 3D Coarse Grain Clock Gating" }, - {AMD_CG_SUPPORT_GFX_3D_CGLS ,"Graphics 3D Coarse Grain memory Light Sleep" }, - {AMD_CG_SUPPORT_MC_LS ,"Memory Controller Light Sleep" }, - {AMD_CG_SUPPORT_MC_MGCG ,"Memory Controller Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_SDMA_LS ,"System Direct Memory Access Light Sleep" }, - {AMD_CG_SUPPORT_SDMA_MGCG ,"System Direct Memory Access Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_BIF_MGCG ,"Bus Interface Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_BIF_LS ,"Bus Interface Light Sleep" }, - {AMD_CG_SUPPORT_UVD_MGCG ,"Unified Video Decoder Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_VCE_MGCG ,"Video Compression Engine Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_HDP_LS ,"Host Data Path Light Sleep" }, - {AMD_CG_SUPPORT_HDP_MGCG ,"Host Data Path Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_DRM_MGCG ,"Digital Right Management Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_DRM_LS ,"Digital Right Management Light Sleep" }, - {AMD_CG_SUPPORT_ROM_MGCG ,"Rom Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_DF_MGCG ,"Data Fabric Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_VCN_MGCG ,"VCN Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_HDP_DS ,"Host Data Path Deep Sleep" }, - {AMD_CG_SUPPORT_HDP_SD ,"Host Data Path Shutdown" }, - {AMD_CG_SUPPORT_IH_CG ,"Interrupt Handler Clock Gating" }, - {AMD_CG_SUPPORT_JPEG_MGCG ,"JPEG Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_REPEATER_FGCG ,"Repeater Fine Grain Clock Gating" }, - {AMD_CG_SUPPORT_GFX_PERF_CLK ,"Perfmon Clock Gating" }, - {AMD_CG_SUPPORT_ATHUB_MGCG ,"Address Translation Hub Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_ATHUB_LS ,"Address Translation Hub Light Sleep" }, - {0 ,NULL }, -}; - static const struct hwmon_temp_label { enum PP_HWMON_TEMP channel; const char *label;
@@ -3684,6 +3646,44 @@ static int amdgpu_debugfs_pm_info_pp(struct seq_file *m, struct amdgpu_device *areturn 0 ; } +static const struct cg_flag_name clocks[] = { + {AMD_CG_SUPPORT_GFX_FGCG ,"Graphics Fine Grain Clock Gating" }, + {AMD_CG_SUPPORT_GFX_MGCG ,"Graphics Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_GFX_MGLS ,"Graphics Medium Grain memory Light Sleep" }, + {AMD_CG_SUPPORT_GFX_CGCG ,"Graphics Coarse Grain Clock Gating" }, + {AMD_CG_SUPPORT_GFX_CGLS ,"Graphics Coarse Grain memory Light Sleep" }, + {AMD_CG_SUPPORT_GFX_CGTS ,"Graphics Coarse Grain Tree Shader Clock Gating" }, + {AMD_CG_SUPPORT_GFX_CGTS_LS ,"Graphics Coarse Grain Tree Shader Light Sleep" }, + {AMD_CG_SUPPORT_GFX_CP_LS ,"Graphics Command Processor Light Sleep" }, + {AMD_CG_SUPPORT_GFX_RLC_LS ,"Graphics Run List Controller Light Sleep" }, + {AMD_CG_SUPPORT_GFX_3D_CGCG ,"Graphics 3D Coarse Grain Clock Gating" }, + {AMD_CG_SUPPORT_GFX_3D_CGLS ,"Graphics 3D Coarse Grain memory Light Sleep" }, + {AMD_CG_SUPPORT_MC_LS ,"Memory Controller Light Sleep" }, + {AMD_CG_SUPPORT_MC_MGCG ,"Memory Controller Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_SDMA_LS ,"System Direct Memory Access Light Sleep" }, + {AMD_CG_SUPPORT_SDMA_MGCG ,"System Direct Memory Access Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_BIF_MGCG ,"Bus Interface Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_BIF_LS ,"Bus Interface Light Sleep" }, + {AMD_CG_SUPPORT_UVD_MGCG ,"Unified Video Decoder Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_VCE_MGCG ,"Video Compression Engine Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_HDP_LS ,"Host Data Path Light Sleep" }, + {AMD_CG_SUPPORT_HDP_MGCG ,"Host Data Path Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_DRM_MGCG ,"Digital Right Management Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_DRM_LS ,"Digital Right Management Light Sleep" }, + {AMD_CG_SUPPORT_ROM_MGCG ,"Rom Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_DF_MGCG ,"Data Fabric Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_VCN_MGCG ,"VCN Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_HDP_DS ,"Host Data Path Deep Sleep" }, + {AMD_CG_SUPPORT_HDP_SD ,"Host Data Path Shutdown" }, + {AMD_CG_SUPPORT_IH_CG ,"Interrupt Handler Clock Gating" }, + {AMD_CG_SUPPORT_JPEG_MGCG ,"JPEG Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_REPEATER_FGCG ,"Repeater Fine Grain Clock Gating" }, + {AMD_CG_SUPPORT_GFX_PERF_CLK ,"Perfmon Clock Gating" }, + {AMD_CG_SUPPORT_ATHUB_MGCG ,"Address Translation Hub Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_ATHUB_LS ,"Address Translation Hub Light Sleep" }, + {0 ,NULL }, +}; +static void amdgpu_parse_cg_state (struct seq_file *m,u64 flags) {int i;
Signature · 1 line
2.41.0
Alex Deucher
AppliedRe: [PATCH 2/2] drm/amdgpu: Move clocks closer to its only usage in amdgpu_parse_cg_state()
Applied the series. Thanks!
Alex
Quoted 117 lines · Nathan Chancellor
After commit
a25a9dae2067("drm/amd/amdgpu: enable W=1 for amdgpu"), there is an instance of -Wunused-const-variable whenCONFIG_DEBUG_FSis disabled:drivers/gpu/drm/amd/amdgpu/../pm/amdgpu_pm.c:38:34: error: unused variable 'clocks' [-Werror,-Wunused-const-variable] 38 | static const struct cg_flag_name clocks[] = { | ^ 1 error generated.clocks is only used when
CONFIG_DEBUG_FSis set, so move the definition into theCONFIG_DEBUG_FSblock right above its only usage to clear up the warning.Signed-off-by Nathan Chancellor <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 76 +++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 38 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +38
-39@@ -35,44 +35,6 @@#include <linux/pm_runtime.h> #include <asm/processor.h> -static const struct cg_flag_name clocks[] = { - {AMD_CG_SUPPORT_GFX_FGCG ,"Graphics Fine Grain Clock Gating" }, - {AMD_CG_SUPPORT_GFX_MGCG ,"Graphics Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_GFX_MGLS ,"Graphics Medium Grain memory Light Sleep" }, - {AMD_CG_SUPPORT_GFX_CGCG ,"Graphics Coarse Grain Clock Gating" }, - {AMD_CG_SUPPORT_GFX_CGLS ,"Graphics Coarse Grain memory Light Sleep" }, - {AMD_CG_SUPPORT_GFX_CGTS ,"Graphics Coarse Grain Tree Shader Clock Gating" }, - {AMD_CG_SUPPORT_GFX_CGTS_LS ,"Graphics Coarse Grain Tree Shader Light Sleep" }, - {AMD_CG_SUPPORT_GFX_CP_LS ,"Graphics Command Processor Light Sleep" }, - {AMD_CG_SUPPORT_GFX_RLC_LS ,"Graphics Run List Controller Light Sleep" }, - {AMD_CG_SUPPORT_GFX_3D_CGCG ,"Graphics 3D Coarse Grain Clock Gating" }, - {AMD_CG_SUPPORT_GFX_3D_CGLS ,"Graphics 3D Coarse Grain memory Light Sleep" }, - {AMD_CG_SUPPORT_MC_LS ,"Memory Controller Light Sleep" }, - {AMD_CG_SUPPORT_MC_MGCG ,"Memory Controller Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_SDMA_LS ,"System Direct Memory Access Light Sleep" }, - {AMD_CG_SUPPORT_SDMA_MGCG ,"System Direct Memory Access Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_BIF_MGCG ,"Bus Interface Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_BIF_LS ,"Bus Interface Light Sleep" }, - {AMD_CG_SUPPORT_UVD_MGCG ,"Unified Video Decoder Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_VCE_MGCG ,"Video Compression Engine Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_HDP_LS ,"Host Data Path Light Sleep" }, - {AMD_CG_SUPPORT_HDP_MGCG ,"Host Data Path Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_DRM_MGCG ,"Digital Right Management Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_DRM_LS ,"Digital Right Management Light Sleep" }, - {AMD_CG_SUPPORT_ROM_MGCG ,"Rom Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_DF_MGCG ,"Data Fabric Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_VCN_MGCG ,"VCN Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_HDP_DS ,"Host Data Path Deep Sleep" }, - {AMD_CG_SUPPORT_HDP_SD ,"Host Data Path Shutdown" }, - {AMD_CG_SUPPORT_IH_CG ,"Interrupt Handler Clock Gating" }, - {AMD_CG_SUPPORT_JPEG_MGCG ,"JPEG Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_REPEATER_FGCG ,"Repeater Fine Grain Clock Gating" }, - {AMD_CG_SUPPORT_GFX_PERF_CLK ,"Perfmon Clock Gating" }, - {AMD_CG_SUPPORT_ATHUB_MGCG ,"Address Translation Hub Medium Grain Clock Gating" }, - {AMD_CG_SUPPORT_ATHUB_LS ,"Address Translation Hub Light Sleep" }, - {0 ,NULL }, -}; - static const struct hwmon_temp_label { enum PP_HWMON_TEMP channel; const char *label;@@ -3684,6 +3646,44 @@ static int amdgpu_debugfs_pm_info_pp(struct seq_file *m, struct amdgpu_device *areturn 0 ; } +static const struct cg_flag_name clocks[] = { + {AMD_CG_SUPPORT_GFX_FGCG ,"Graphics Fine Grain Clock Gating" }, + {AMD_CG_SUPPORT_GFX_MGCG ,"Graphics Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_GFX_MGLS ,"Graphics Medium Grain memory Light Sleep" }, + {AMD_CG_SUPPORT_GFX_CGCG ,"Graphics Coarse Grain Clock Gating" }, + {AMD_CG_SUPPORT_GFX_CGLS ,"Graphics Coarse Grain memory Light Sleep" }, + {AMD_CG_SUPPORT_GFX_CGTS ,"Graphics Coarse Grain Tree Shader Clock Gating" }, + {AMD_CG_SUPPORT_GFX_CGTS_LS ,"Graphics Coarse Grain Tree Shader Light Sleep" }, + {AMD_CG_SUPPORT_GFX_CP_LS ,"Graphics Command Processor Light Sleep" }, + {AMD_CG_SUPPORT_GFX_RLC_LS ,"Graphics Run List Controller Light Sleep" }, + {AMD_CG_SUPPORT_GFX_3D_CGCG ,"Graphics 3D Coarse Grain Clock Gating" }, + {AMD_CG_SUPPORT_GFX_3D_CGLS ,"Graphics 3D Coarse Grain memory Light Sleep" }, + {AMD_CG_SUPPORT_MC_LS ,"Memory Controller Light Sleep" }, + {AMD_CG_SUPPORT_MC_MGCG ,"Memory Controller Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_SDMA_LS ,"System Direct Memory Access Light Sleep" }, + {AMD_CG_SUPPORT_SDMA_MGCG ,"System Direct Memory Access Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_BIF_MGCG ,"Bus Interface Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_BIF_LS ,"Bus Interface Light Sleep" }, + {AMD_CG_SUPPORT_UVD_MGCG ,"Unified Video Decoder Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_VCE_MGCG ,"Video Compression Engine Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_HDP_LS ,"Host Data Path Light Sleep" }, + {AMD_CG_SUPPORT_HDP_MGCG ,"Host Data Path Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_DRM_MGCG ,"Digital Right Management Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_DRM_LS ,"Digital Right Management Light Sleep" }, + {AMD_CG_SUPPORT_ROM_MGCG ,"Rom Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_DF_MGCG ,"Data Fabric Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_VCN_MGCG ,"VCN Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_HDP_DS ,"Host Data Path Deep Sleep" }, + {AMD_CG_SUPPORT_HDP_SD ,"Host Data Path Shutdown" }, + {AMD_CG_SUPPORT_IH_CG ,"Interrupt Handler Clock Gating" }, + {AMD_CG_SUPPORT_JPEG_MGCG ,"JPEG Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_REPEATER_FGCG ,"Repeater Fine Grain Clock Gating" }, + {AMD_CG_SUPPORT_GFX_PERF_CLK ,"Perfmon Clock Gating" }, + {AMD_CG_SUPPORT_ATHUB_MGCG ,"Address Translation Hub Medium Grain Clock Gating" }, + {AMD_CG_SUPPORT_ATHUB_LS ,"Address Translation Hub Light Sleep" }, + {0 ,NULL }, +}; +static void amdgpu_parse_cg_state (struct seq_file *m,u64 flags) {int i; --2.41.0