Reviewed-by: Wayne Lin <[email protected]>

On Thu, 05 Nov 2026 11:23:04 -0800, Jeff Johnson wrote:
> 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_selection
>
> This 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.
>
> 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(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.h 
> b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.h
> index a761e85a9973..867fe9023fc7 100644
> --- a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.h
> +++ b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.h
> @@ -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_ */
> diff --git a/drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.h 
> b/drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.h
> index a4fa0365cd4f..b081801f664e 100644
> --- a/drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.h
> +++ b/drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.h
> @@ -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_ */
> diff --git a/drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.h 
> b/drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.h
> index fee03a5dd596..00cf48b14f53 100644
> --- a/drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.h
> +++ b/drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.h
> @@ -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_ */
> diff --git a/drivers/gpu/drm/amd/display/dc/inc/dc_core_interface.h 
> b/drivers/gpu/drm/amd/display/dc/inc/dc_core_interface.h
> index 35a6218c1285..264bd8bf3bc0 100644
> --- a/drivers/gpu/drm/amd/display/dc/inc/dc_core_interface.h
> +++ b/drivers/gpu/drm/amd/display/dc/inc/dc_core_interface.h
> @@ -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
>
>

Reply via email to