drm/amd/amdgpu: enable W=1 for amdgpu
Subsystems (3)
PATCH 1/1 drm/amd/amdgpu: enable W=1 for amdgpu
We have a clean build with W=1 as of
commit 12a15dd589ac ("drm/amd/display/amdgpu_dm/amdgpu_dm_helpers: Move SYNAPTICS_DEVICE_ID into CONFIG_DRM_AMD_DC_DCN ifdef"). So, let's enable these checks unconditionally for the entire module to catch these errors during development.
--- drivers/gpu/drm/amd/amdgpu/Makefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/Makefile +12 -1
@@ -40,7 +40,18 @@ ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \ -I$(FULL_AMD_PATH)/amdkfd subdir-ccflags-y := -Wextra -subdir-ccflags-y += $(call cc-option, -Wunused-but-set-variable) +subdir-ccflags-y += -Wunused +subdir-ccflags-y += -Wmissing-prototypes +subdir-ccflags-y += -Wmissing-declarations +subdir-ccflags-y += -Wmissing-include-dirs +subdir-ccflags-y += -Wold-style-definition +subdir-ccflags-y += -Wmissing-format-attribute +# Need this to avoid recursive variable evaluation issues +cond-flags := $(call cc-option, -Wunused-but-set-variable) \ + $(call cc-option, -Wunused-const-variable) \ + $(call cc-option, -Wstringop-truncation) \ + $(call cc-option, -Wpacked-not-aligned) +subdir-ccflags-y += $(cond-flags) subdir-ccflags-y += -Wno-unused-parameter subdir-ccflags-y += -Wno-type-limits subdir-ccflags-y += -Wno-sign-compare
Signature · 1 line
2.40.1
+ Masahiro and linux-kbuild
Quoted 9 lines · Hamza Mahfooz
We have a clean build with W=1 as of
commit12a15dd589ac("drm/amd/display/amdgpu_dm/amdgpu_dm_helpers: MoveSYNAPTICS_DEVICE_IDintoCONFIG_DRM_AMD_DC_DCNifdef"). So, let's enable these checks unconditionally for the entire module to catch these errors during development.Cc Alex Deucher <[email protected]>Cc Nathan Chancellor <[email protected]>Signed-off-by Hamza Mahfooz <[email protected]>
I think this is fine, especially since it will help catch issues in amdgpu quickly and hopefully encourage developers to fix their problems before they make it to a tree with wider impact lika -next.
However, this is now the third place that W=1 has been effectively enabled (i915 and btrfs are the other two I know of) and it would be nice if this was a little more unified, especially since it is not uncommon for the warnings under W=1 to shift around and keeping them unified will make maintainence over the longer term a little easier. I am not sure if this has been brought up in the past and I don't want to hold up this change but I suspect this sentiment of wanting to enable W=1 on a per-subsystem basis is going to continue to grow.
Regardless, for clang 11.1.0 to 16.0.5, I see no warnings when building drivers/gpu/drm/amd/amdgpu/ with Arch Linux's configuration or allmodconfig.
Quoted 31 lines
--- drivers/gpu/drm/amd/amdgpu/Makefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/Makefile +12
-1@@ -40,7 +40,18 @@ ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \ -I$(FULL_AMD_PATH)/amdkfd subdir-ccflags-y := -Wextra -subdir-ccflags-y += $(call cc-option, -Wunused-but-set-variable) +subdir-ccflags-y += -Wunused +subdir-ccflags-y += -Wmissing-prototypes +subdir-ccflags-y += -Wmissing-declarations +subdir-ccflags-y += -Wmissing-include-dirs +subdir-ccflags-y += -Wold-style-definition +subdir-ccflags-y += -Wmissing-format-attribute +# Need this to avoid recursive variable evaluation issues +cond-flags := $(call cc-option, -Wunused-but-set-variable) \ + $(call cc-option, -Wunused-const-variable) \ + $(call cc-option, -Wstringop-truncation) \ + $(call cc-option, -Wpacked-not-aligned) +subdir-ccflags-y += $(cond-flags) subdir-ccflags-y += -Wno-unused-parameter subdir-ccflags-y += -Wno-type-limits subdir-ccflags-y += -Wno-sign-compareSignature · 1 line
2.40.1
Quoted 18 lines · Nathan Chancellor
+ Masahiro and linux-kbuild
Quoted 9 lines · Hamza Mahfooz
We have a clean build with W=1 as of
commit12a15dd589ac("drm/amd/display/amdgpu_dm/amdgpu_dm_helpers: MoveSYNAPTICS_DEVICE_IDintoCONFIG_DRM_AMD_DC_DCNifdef"). So, let's enable these checks unconditionally for the entire module to catch these errors during development.Cc Alex Deucher <[email protected]>Cc Nathan Chancellor <[email protected]>Signed-off-by Hamza Mahfooz <[email protected]>I think this is fine, especially since it will help catch issues in amdgpu quickly and hopefully encourage developers to fix their problems before they make it to a tree with wider impact lika -next.
Quoted 8 lines
However, this is now the third place that W=1 has been effectively enabled (i915 and btrfs are the other two I know of) and it would be nice if this was a little more unified, especially since it is not uncommon for the warnings under W=1 to shift around and keeping them unified will make maintainence over the longer term a little easier. I am not sure if this has been brought up in the past and I don't want to hold up this change but I suspect this sentiment of wanting to enable W=1 on a per-subsystem basis is going to continue to grow.
I believe this patch is the right way because we will be able to add a new warning option to scripts/Makefile.extrawarn without fixing any code.
I remember somebody argued that drivers should be able to do
subdir-ccflags-y += $(W1_FLAGS)
However, if a new flag, -Wfoo, emits warnings for drivers/gpu/drm/{i915,amd},
you cannot add it to W=1 until fixing the code.
If many drivers start to do likewise,
W=1 warning will not be W=1 any more.
Another good thing for hard-coding warning options is you can lift up a warning flag one by one.
Let's say you fixed the entire DRM subsystem so it is -Wunused free now.
Then, you can move -Wunused to drivers/gpu/drm/Makefile, while other warning options stay in drivers Makefiles.
Quoted 39 lines
Regardless, for clang 11.1.0 to 16.0.5, I see no warnings when building
drivers/gpu/drm/amd/amdgpu/with Arch Linux's configuration or allmodconfig.Reviewed-by Nathan Chancellor <[email protected]>Tested-by Nathan Chancellor <[email protected]>Quoted 31 lines
--- drivers/gpu/drm/amd/amdgpu/Makefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/Makefile +12
-2@@ -40,7 +40,18 @@ ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \ -I$(FULL_AMD_PATH)/amdkfd subdir-ccflags-y := -Wextra -subdir-ccflags-y += $(call cc-option, -Wunused-but-set-variable) +subdir-ccflags-y += -Wunused +subdir-ccflags-y += -Wmissing-prototypes +subdir-ccflags-y += -Wmissing-declarations +subdir-ccflags-y += -Wmissing-include-dirs +subdir-ccflags-y += -Wold-style-definition +subdir-ccflags-y += -Wmissing-format-attribute +# Need this to avoid recursive variable evaluation issues +cond-flags := $(call cc-option, -Wunused-but-set-variable) \ + $(call cc-option, -Wunused-const-variable) \ + $(call cc-option, -Wstringop-truncation) \ + $(call cc-option, -Wpacked-not-aligned) +subdir-ccflags-y += $(cond-flags) subdir-ccflags-y += -Wno-unused-parameter subdir-ccflags-y += -Wno-type-limits subdir-ccflags-y += -Wno-sign-compare --2.40.1
Signature · 2 lines
Best Regards Masahiro Yamada
Quoted 30 lines · Masahiro Yamada
Quoted 18 lines · Nathan Chancellor
+ Masahiro and linux-kbuild
Quoted 9 lines · Hamza Mahfooz
We have a clean build with W=1 as of
commit12a15dd589ac("drm/amd/display/amdgpu_dm/amdgpu_dm_helpers: MoveSYNAPTICS_DEVICE_IDintoCONFIG_DRM_AMD_DC_DCNifdef"). So, let's enable these checks unconditionally for the entire module to catch these errors during development.Cc Alex Deucher <[email protected]>Cc Nathan Chancellor <[email protected]>Signed-off-by Hamza Mahfooz <[email protected]>I think this is fine, especially since it will help catch issues in amdgpu quickly and hopefully encourage developers to fix their problems before they make it to a tree with wider impact lika -next.
Quoted 8 lines
However, this is now the third place that W=1 has been effectively enabled (i915 and btrfs are the other two I know of) and it would be nice if this was a little more unified, especially since it is not uncommon for the warnings under W=1 to shift around and keeping them unified will make maintainence over the longer term a little easier. I am not sure if this has been brought up in the past and I don't want to hold up this change but I suspect this sentiment of wanting to enable W=1 on a per-subsystem basis is going to continue to grow.
Quoted 7 lines
I believe this patch is the right way because we will be able to add a new warning option to
scripts/Makefile.extrawarnwithout fixing any code.I remember somebody argued that drivers should be able to do
subdir-ccflags-y += $(W1_FLAGS)
Personally, I think this would be the viable way to make the kernel free of W=1 warnings. Make it clean driver and subsystem at a time, with constant progress. Currently, there's haphazard fixing of issues, with new ones creeping back in, because kernel-wide W=1 is too verbose for most developers. It's whac-a-mole.
Quoted 3 lines
However, if a new flag, -Wfoo, emits warnings for
drivers/gpu/drm/{i915,amd},
you cannot add it to W=1 until fixing the code.
Or adding -Wno-foo where it breaks, until fixed.
Quoted 2 lines
If many drivers start to do likewise,
W=1 warning will not be W=1 any more.
I don't know, is the goal to fix the warnings, or keep adding stuff to W=1 so that it'll always emit warnings? :p
BR,
Jani.
Quoted 55 lines
Another good thing for hard-coding warning options is you can lift up a warning flag one by one.
Let's say you fixed the entire DRM subsystem so it is -Wunused free now.
Then, you can move -Wunused to
drivers/gpu/drm/Makefile, while other warning options stay in drivers Makefiles.Quoted 39 lines
Regardless, for clang 11.1.0 to 16.0.5, I see no warnings when building
drivers/gpu/drm/amd/amdgpu/with Arch Linux's configuration or allmodconfig.Reviewed-by Nathan Chancellor <[email protected]>Tested-by Nathan Chancellor <[email protected]>Quoted 31 lines
--- drivers/gpu/drm/amd/amdgpu/Makefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/Makefile +12
-2@@ -40,7 +40,18 @@ ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \ -I$(FULL_AMD_PATH)/amdkfd subdir-ccflags-y := -Wextra -subdir-ccflags-y += $(call cc-option, -Wunused-but-set-variable) +subdir-ccflags-y += -Wunused +subdir-ccflags-y += -Wmissing-prototypes +subdir-ccflags-y += -Wmissing-declarations +subdir-ccflags-y += -Wmissing-include-dirs +subdir-ccflags-y += -Wold-style-definition +subdir-ccflags-y += -Wmissing-format-attribute +# Need this to avoid recursive variable evaluation issues +cond-flags := $(call cc-option, -Wunused-but-set-variable) \ + $(call cc-option, -Wunused-const-variable) \ + $(call cc-option, -Wstringop-truncation) \ + $(call cc-option, -Wpacked-not-aligned) +subdir-ccflags-y += $(cond-flags) subdir-ccflags-y += -Wno-unused-parameter subdir-ccflags-y += -Wno-type-limits subdir-ccflags-y += -Wno-sign-compare --2.40.1
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center