Skip to contentSkip to conversation

drm/amd: Permit DC_FP_START/END only in non-FP compilation units

PATCH In review Ard Biesheuvel 5 participants 5 messages Oct 9, 2025 – Oct 12, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd: Permit DC_FP_START/END only in non-FP compilation units

From: Ard Biesheuvel <[email protected]>

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 <[email protected]>
Cc Jun Lei <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Leo Li <[email protected]>
Cc Rodrigo Siqueira <[email protected]>
Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>
---
 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(-)
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.h +8 -0
index b8275b397920..4e921632bc4e 100644
@@ -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__ */
drivers/gpu/drm/amd/display/dc/os_types.h +0 -2
index 782316348941..6af831710489 100644
@@ -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 */
 
 /*
Signature · 1 line
2.51.0.710.ga91ca5db03-goog
maintainer
#1 lore raw
Quoted 8 lines · Ard Biesheuvel

From: Ard Biesheuvel <[email protected]>

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.

If I'm not completely mistaken that is actually an issue on basically all architectures, at least x86 is affected as well if I'm not completely mistaken.

Quoted 10 lines
Cc Austin Zheng <[email protected]>
Cc Jun Lei <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Leo Li <[email protected]>
Cc Rodrigo Siqueira <[email protected]>
Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>

Anyway, patch looks sane to me but I'm not so deep in the DC code to fully judge.

Fell free to add Acked-by: Christian König <[email protected]>, but Harry and Leo need to take a look.

Thanks,
Christian.

Quoted 35 lines
---
 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(-)
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.h +8 -0
index b8275b397920..4e921632bc4e 100644
@@ -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__ */
drivers/gpu/drm/amd/display/dc/os_types.h +0 -2
index 782316348941..6af831710489 100644
@@ -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 */
 
 /*
maintainer Reviewed-by
#2 lore raw
Quoted 23 lines · Christian König
Quoted 8 lines · Ard Biesheuvel

From: Ard Biesheuvel <[email protected]>

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.

If I'm not completely mistaken that is actually an issue on basically all architectures, at least x86 is affected as well if I'm not completely mistaken.

Quoted 10 lines
Cc Austin Zheng <[email protected]>
Cc Jun Lei <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Leo Li <[email protected]>
Cc Rodrigo Siqueira <[email protected]>
Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>
Quoted 4 lines

Anyway, patch looks sane to me but I'm not so deep in the DC code to fully judge.

Fell free to add Acked-by: Christian König <[email protected]>, but Harry and Leo need to take a look.

Thanks. Good safe-guard. Flags a bunch of issues in the current code. Let me fix them before merging it.

Harry

Quoted 39 lines

Thanks,
Christian.

Quoted 35 lines
---
 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(-)
drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.h +8 -0
index b8275b397920..4e921632bc4e 100644
@@ -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__ */
drivers/gpu/drm/amd/display/dc/os_types.h +0 -2
index 782316348941..6af831710489 100644
@@ -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 */
 
 /*
#3 lore raw
Quoted 29 lines · Harry Wentland
Quoted 25 lines · Christian König
Quoted 8 lines · Ard Biesheuvel

From: Ard Biesheuvel <[email protected]>

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.

If I'm not completely mistaken that is actually an issue on basically all architectures, at least x86 is affected as well if I'm not completely mistaken.

Quoted 10 lines
Cc Austin Zheng <[email protected]>
Cc Jun Lei <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Leo Li <[email protected]>
Cc Rodrigo Siqueira <[email protected]>
Cc Alex Deucher <[email protected]>
Cc "Christian König" <[email protected]>

Anyway, patch looks sane to me but I'm not so deep in the DC code to fully judge.

Quoted 8 lines
Quoted 2 lines

Fell free to add Acked-by: Christian König <[email protected]>, but Harry and Leo need to take a look.

Thanks. Good safe-guard. Flags a bunch of issues in the current code. Let me fix them before merging it.

Thanks.

I already fixed a bunch here:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=ddbfac152830e38d488ff8e45ab7eaf5d72f8527

#4 lore raw
In reply to Ard Biesheuvel
kernel test robot noticed the following build errors:

Hi Ard,

kernel test robot noticed the following build errors:

[auto build test ERROR on soc/for-next]
[also build test ERROR on linus/master v6.17 next-20251010] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ard-Biesheuvel/drm-amd-Permit-DC_FP_START-END-only-in-non-FP-compilation-units/20251010-120206
base:   https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
patch link:    https://lore.kernel.org/r/20251009150621.3886079-2-ardb%2Bgit%40google.com
patch subject: [PATCH] drm/amd: Permit DC_FP_START/END only in non-FP compilation units

:::::: branch date: 14 hours ago
:::::: commit date: 14 hours ago
config: x86_64-randconfig-071-20251010 (https://download.01.org/0day-ci/archive/20251011/[email protected]/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251011/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml2_wrapper.c:563:2: error: call to '__compiletime_assert_610' declared with 'error' attribute: BUILD_BUG failed
     563 |         DC_FP_START();
         |         ^
   drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/dc_fpu.h:38:23: note: expanded from macro 'DC_FP_START'
      38 | #define DC_FP_START()   BUILD_BUG()
         |                         ^
   include/linux/build_bug.h:59:21: note: expanded from macro 'BUILD_BUG'
      59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
         |                     ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:583:2: note: expanded from macro '_compiletime_assert'
     583 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:576:4: note: expanded from macro '__compiletime_assert'
     576 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:39:1: note: expanded from here
      39 | __compiletime_assert_610
         | ^
   drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml2_wrapper.c:615:2: error: call to '__compiletime_assert_612' declared with 'error' attribute: BUILD_BUG failed
     615 |         DC_FP_START();
         |         ^
   drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/dc_fpu.h:38:23: note: expanded from macro 'DC_FP_START'
      38 | #define DC_FP_START()   BUILD_BUG()
         |                         ^
   include/linux/build_bug.h:59:21: note: expanded from macro 'BUILD_BUG'
      59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
         |                     ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
      39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
         |                                     ^
   note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:583:2: note: expanded from macro '_compiletime_assert'
     583 |         __compiletime_assert(condition, msg, prefix, suffix)
         |         ^
   include/linux/compiler_types.h:576:4: note: expanded from macro '__compiletime_assert'
     576 |                         prefix ## suffix();                             \
         |                         ^
   <scratch space>:45:1: note: expanded from here
      45 | __compiletime_assert_612
         | ^

2 errors generated.

vim +563 drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml2_wrapper.c

7966f319c66d94 Qingqing Zhuo    2023-07-28  547  
269c1d1443d668 Yan Li           2025-05-14  548  bool dml2_validate(const struct dc *in_dc, struct dc_state *context, struct dml2_context *dml2,
269c1d1443d668 Yan Li           2025-05-14  549  	enum dc_validate_mode validate_mode)
7966f319c66d94 Qingqing Zhuo    2023-07-28  550  {
7966f319c66d94 Qingqing Zhuo    2023-07-28  551  	bool out = false;
7966f319c66d94 Qingqing Zhuo    2023-07-28  552  
cc263c3a0c9f38 Joshua Aberback  2024-03-07  553  	if (!dml2)
7966f319c66d94 Qingqing Zhuo    2023-07-28  554  		return false;
cc263c3a0c9f38 Joshua Aberback  2024-03-07  555  	dml2_apply_debug_options(in_dc, dml2);
7966f319c66d94 Qingqing Zhuo    2023-07-28  556  
00c391102abc13 Aurabindo Pillai 2024-03-20  557  	/* DML2.1 validation path */
00c391102abc13 Aurabindo Pillai 2024-03-20  558  	if (dml2->architecture == dml2_architecture_21) {
269c1d1443d668 Yan Li           2025-05-14  559  		out = dml21_validate(in_dc, context, dml2, validate_mode);
00c391102abc13 Aurabindo Pillai 2024-03-20  560  		return out;
00c391102abc13 Aurabindo Pillai 2024-03-20  561  	}
7966f319c66d94 Qingqing Zhuo    2023-07-28  562  
366e77cd4923c3 Huacai Chen      2025-03-27 @563  	DC_FP_START();
366e77cd4923c3 Huacai Chen      2025-03-27  564  
269c1d1443d668 Yan Li           2025-05-14  565  	/* Use dml_validate_only for DC_VALIDATE_MODE_ONLY and DC_VALIDATE_MODE_AND_STATE_INDEX path */
269c1d1443d668 Yan Li           2025-05-14  566  	if (validate_mode != DC_VALIDATE_MODE_AND_PROGRAMMING)
b02b0fc488ba6e Yan Li           2025-05-21  567  		out = dml2_validate_only(context, validate_mode);
7966f319c66d94 Qingqing Zhuo    2023-07-28  568  	else
b02b0fc488ba6e Yan Li           2025-05-21  569  		out = dml2_validate_and_build_resource(in_dc, context, validate_mode);
366e77cd4923c3 Huacai Chen      2025-03-27  570  
366e77cd4923c3 Huacai Chen      2025-03-27  571  	DC_FP_END();
366e77cd4923c3 Huacai Chen      2025-03-27  572  
7966f319c66d94 Qingqing Zhuo    2023-07-28  573  	return out;
7966f319c66d94 Qingqing Zhuo    2023-07-28  574  }
7966f319c66d94 Qingqing Zhuo    2023-07-28  575  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki