drm/amd/display: use include guards instead of #pragma once in Core 2 headers
Subsystems (3)
PATCH 1/1 drm/amd/display: use include guards instead of #pragma once in Core 2 headers
Commit 9d1a737c3c82 ("drm/amd/display: Keep public DC lifecycle APIs stable beside Core 2") added four headers that use #pragma once, the only headers in drivers/gpu/drm/amd/display/ to do so; every other header in the subsystem uses #ifndef include guards.
dc_core_interface.h is included more than once within a single translation unit (via dc.h and again via api_shim.h / dc_core2.h). In the amdgpu build all display include paths are spelled with a "-I.../amdgpu/../display/..." prefix, so the header is reached through two paths that differ only by a ".." component.
gcc canonicalizes the ".." and deduplicates the header by its real path, so the normal CC build is fine. sparse (make C=1/C=2) does not canonicalize ".." for #pragma once, treats the two spellings as different files and processes the header twice, which breaks the build:
dc_core_interface.h:14: error: redefinition of \
unsigned int enum dc2_selectionThis fails the CHECK pass for api_shim.c, dc_core2.c and core/dc.c.
Convert the four new headers to standard #ifndef include guards, which sparse honors regardless of how the path is spelled, matching the rest of the subsystem. No functional change for gcc builds.
---
Issue debugged and patch generated using Claude Code Opus 4.8. I have reviewed the patch and have verified a clean W=1 C=1 build.
--- drivers/gpu/drm/amd/display/dc/core2/dc_core2.h | 5 ++++- drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.h | 5 ++++- drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.h | 5 ++++- drivers/gpu/drm/amd/display/dc/inc/dc_core_interface.h | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/dc/core2/dc_core2.h +4 -1
@@ -3,7 +3,8 @@* Copyright 2026 Advanced Micro Devices, Inc. */ -#pragma once +#ifndef DC_CORE2_H_ +#define DC_CORE2_H_ #include "inc/dc_core_interface.h"
@@ -17,3 +18,5 @@ struct dc_core2 {const struct dc2_funcs *core2_funcs (void );void core2_construct (struct dc *dc);void core2_destruct (struct dc *dc); + +#endif /* DC_CORE2_H_ */
drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.h +4 -1
@@ -3,8 +3,11 @@* Copyright 2026 Advanced Micro Devices, Inc. */ -#pragma once +#ifndef DC_CORE2_INIT_H_ +#define DC_CORE2_INIT_H_ struct dc ;void core2_hardware_init (struct dc *dc); + +#endif /* DC_CORE2_INIT_H_ */
drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.h +4 -1
@@ -3,7 +3,8 @@* Copyright 2026 Advanced Micro Devices, Inc. */ -#pragma once +#ifndef DC_API_DISPATCH_API_SHIM_H_ +#define DC_API_DISPATCH_API_SHIM_H_ #include "dc.h" #include "inc/dc_core_interface.h"
@@ -17,3 +18,5 @@ struct dc2 {#define TO_DC2 (ptr) ((struct dc2 *)(ptr))void api_shim_construct (struct dc *dc,const struct dc_init_data *init_params); + +#endif /* DC_API_DISPATCH_API_SHIM_H_ */
drivers/gpu/drm/amd/display/dc/inc/dc_core_interface.h +4 -1
@@ -3,7 +3,8 @@* Copyright 2026 Advanced Micro Devices, Inc. */ -#pragma once +#ifndef DC_CORE_INTERFACE_H_ +#define DC_CORE_INTERFACE_H_ struct dc ;
@@ -29,3 +30,5 @@ struct dc2_funcs {void legacy_hardware_init (struct dc *dc);void legacy_hardware_release (struct dc *dc);const struct dc2_funcs *dc2_legacy_funcs (void ); + +#endif /* DC_CORE_INTERFACE_H_ */
---
base-commit: d7e11a5269dc892cbee8a01dccbdb20bb4f653da
change-id: 20261105-amdgpu-local-fix-908074837d48
Quoted 120 lines · Jeff Johnson
Commit
9d1a737c3c82("drm/amd/display: Keep public DC lifecycle APIs stable beside Core 2") added four headers that use #pragma once, the only headers indrivers/gpu/drm/amd/display/to do so; every other header in the subsystem uses #ifndef include guards.
dc_core_interface.his included more than once within a single translation unit (viadc.hand again viaapi_shim.h/dc_core2.h). In the amdgpu build all display include paths are spelled with a "-I.../amdgpu/../display/..." prefix, so the header is reached through two paths that differ only by a ".." component.gcc canonicalizes the ".." and deduplicates the header by its real path, so the normal CC build is fine. sparse (make C=1/C=2) does not canonicalize ".." for #pragma once, treats the two spellings as different files and processes the header twice, which breaks the build:
dc_core_interface.h:14: error: redefinition of \ unsigned int enum dc2_selectionThis fails the CHECK pass for
api_shim.c,dc_core2.candcore/dc.c.Convert the four new headers to standard #ifndef include guards, which sparse honors regardless of how the path is spelled, matching the rest of the subsystem. No functional change for gcc builds.
Fixes 9d1a737c3c82 ("drm/amd/display: Keep public DC lifecycle APIs stable beside Core 2")Signed-off-by Jeff Johnson <[email protected]>---
Issue debugged and patch generated using Claude Code Opus 4.8. I have reviewed the patch and have verified a clean W=1 C=1 build.--- drivers/gpu/drm/amd/display/dc/core2/dc_core2.h | 5 ++++- drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.h | 5 ++++- drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.h | 5 ++++- drivers/gpu/drm/amd/display/dc/inc/dc_core_interface.h | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/display/dc/core2/dc_core2.h +4
-1@@ -3,7 +3,8 @@* Copyright 2026 Advanced Micro Devices, Inc. */ -#pragma once +#ifndef DC_CORE2_H_ +#define DC_CORE2_H_ #include "inc/dc_core_interface.h" @@ -17,3 +18,5 @@ struct dc_core2 {const struct dc2_funcs *core2_funcs (void );void core2_construct (struct dc *dc);void core2_destruct (struct dc *dc); + +#endif /* DC_CORE2_H_ */ drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.h +4
-1@@ -3,8 +3,11 @@* Copyright 2026 Advanced Micro Devices, Inc. */ -#pragma once +#ifndef DC_CORE2_INIT_H_ +#define DC_CORE2_INIT_H_ struct dc ;void core2_hardware_init (struct dc *dc); + +#endif /* DC_CORE2_INIT_H_ */ drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.h +4
-1@@ -3,7 +3,8 @@* Copyright 2026 Advanced Micro Devices, Inc. */ -#pragma once +#ifndef DC_API_DISPATCH_API_SHIM_H_ +#define DC_API_DISPATCH_API_SHIM_H_ #include "dc.h" #include "inc/dc_core_interface.h" @@ -17,3 +18,5 @@ struct dc2 {#define TO_DC2 (ptr) ((struct dc2 *)(ptr))void api_shim_construct (struct dc *dc,const struct dc_init_data *init_params); + +#endif /* DC_API_DISPATCH_API_SHIM_H_ */ drivers/gpu/drm/amd/display/dc/inc/dc_core_interface.h +4
-2@@ -3,7 +3,8 @@* Copyright 2026 Advanced Micro Devices, Inc. */ -#pragma once +#ifndef DC_CORE_INTERFACE_H_ +#define DC_CORE_INTERFACE_H_ struct dc ;@@ -29,3 +30,5 @@ struct dc2_funcs {void legacy_hardware_init (struct dc *dc);void legacy_hardware_release (struct dc *dc);const struct dc2_funcs *dc2_legacy_funcs (void ); + +#endif /* DC_CORE_INTERFACE_H_ */ ---base-commit:
d7e11a5269dc892cbee8a01dccbdb20bb4f653da
change-id: 20261105-amdgpu-local-fix-908074837d48