From a574f53ed52e7c5c0e67e67efd76f296d42f0cdd Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Thu, 9 Oct 2025 17:06:21 +0200 Subject: [PATCH] drm/amd/display: Permit DC_FP_START/END only in non-FP compilation units MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit [WHAT] Test the existing CPP macro _LINUX_FPU_COMPILATION_UNIT, which is set when building source files that are permitted to use floating point, in the implementation of DC_FP_START/END so that those are only usable in non-FP code. This is a requirement of the generic kernel mode FPU API, as some architectures (i.e., arm64) cannot safely enable FP codegen in arbitrary code. Cc: Austin Zheng Cc: Jun Lei Cc: Harry Wentland Cc: Leo Li Cc: Rodrigo Siqueira Cc: Alex Deucher Cc: "Christian König" Cc: amd-gfx@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org Suggested-by: Christian König Acked-by: Christian König Reviewed-by: Alex Hung Signed-off-by: Ard Biesheuvel Signed-off-by: Alex Hung Tested-by: Dan Wheeler Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.h | 8 ++++++++ drivers/gpu/drm/amd/display/dc/os_types.h | 2 -- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.h b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.h index b8275b3979205..4e921632bc4e9 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.h +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.h @@ -31,4 +31,12 @@ void dc_assert_fp_enabled(void); void dc_fpu_begin(const char *function_name, const int line); void dc_fpu_end(const char *function_name, const int line); +#ifndef _LINUX_FPU_COMPILATION_UNIT +#define DC_FP_START() dc_fpu_begin(__func__, __LINE__) +#define DC_FP_END() dc_fpu_end(__func__, __LINE__) +#else +#define DC_FP_START() BUILD_BUG() +#define DC_FP_END() BUILD_BUG() +#endif + #endif /* __DC_FPU_H__ */ diff --git a/drivers/gpu/drm/amd/display/dc/os_types.h b/drivers/gpu/drm/amd/display/dc/os_types.h index 782316348941b..6af831710489e 100644 --- a/drivers/gpu/drm/amd/display/dc/os_types.h +++ b/drivers/gpu/drm/amd/display/dc/os_types.h @@ -55,8 +55,6 @@ #if defined(CONFIG_DRM_AMD_DC_FP) #include "amdgpu_dm/dc_fpu.h" -#define DC_FP_START() dc_fpu_begin(__func__, __LINE__) -#define DC_FP_END() dc_fpu_end(__func__, __LINE__) #endif /* CONFIG_DRM_AMD_DC_FP */ /* -- 2.47.3