On Thu, 26 Mar 2026, at 03:57, ChuanYu Tseng wrote:
> From: Rafal Ostrowski <[email protected]>
>
> [Why]
> FPU guards (DC_FP_START/DC_FP_END) are required to wrap around code that
> can manipulates floats. To do this properly, the FPU guards must be used
> in a file that is not compiled as a FPU unit. If the guards are used in
> a file that is a FPU unit, other sections in the file that aren't guarded
> may be end up being compiled to use FPU operations.
>
> [How]
> Added DC_FP_START and DC_FP_END to DC functions that call DML functions
> using FPU.
>
> Reviewed-by: Dillon Varone <[email protected]>
> Signed-off-by: Rafal Ostrowski <[email protected]>
> Signed-off-by: Alex Hung <[email protected]>
> ---
>  .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.c    | 25 ++++++-
>  .../gpu/drm/amd/display/amdgpu_dm/dc_fpu.h    | 17 ++++-
>  .../display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c  |  2 -
>  .../display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c  |  2 -
>  drivers/gpu/drm/amd/display/dc/core/dc.c      |  5 +-
>  .../gpu/drm/amd/display/dc/core/dc_state.c    | 75 ++++++++++++++-----
>  .../gpu/drm/amd/display/dc/core/dc_stream.c   | 13 +++-
>  .../amd/display/dc/hwss/dcn401/dcn401_hwseq.c |  3 +-
>  .../dc/resource/dcn35/dcn35_resource.c        | 10 ++-
>  .../dc/resource/dcn35/dcn35_resource.h        |  1 +
>  .../dc/resource/dcn351/dcn351_resource.c      | 10 ++-
>  .../dc/resource/dcn36/dcn36_resource.c        |  4 +-
>  .../dc/resource/dcn401/dcn401_resource.c      | 30 ++++++--
>  .../dc/resource/dcn42/dcn42_resource.c        | 25 +++++--
>  14 files changed, 169 insertions(+), 53 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 4e921632bc4e..5e95419d3798 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.h
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.h
> @@ -28,15 +28,30 @@
>  #define __DC_FPU_H__
> 
>  void dc_assert_fp_enabled(void);
> +bool dc_is_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__)
> +#ifdef CONFIG_DRM_AMD_DC_FP
> +#define DC_RUN_WITH_PREEMPTION_ENABLED(code) \
> +     do { \
> +             bool dc_fp_enabled = dc_is_fp_enabled(); \
> +             if (dc_fp_enabled) \
> +                     DC_FP_END(); \
> +             code; \
> +             if (dc_fp_enabled) \
> +                     DC_FP_START(); \
> +     } while (0)
> +#else
> +#define DC_RUN_WITH_PREEMPTION_ENABLED(code) code
> +#endif // !CONFIG_DRM_AMD_DC_FP
>  #else
>  #define DC_FP_START()        BUILD_BUG()
>  #define DC_FP_END()  BUILD_BUG()
> -#endif
> +#define DC_RUN_WITH_PREEMPTION_ENABLED(code) code

This looks wrong to me. If _LINUX_FPU_COMPILATION_UNIT is #define'd,
it means the code runs within a DC_FP_START/END pair, and so doing
nothing will not re-enable preemption.

I think this #define should probably just be dropped. If that breaks
the build, it means the code is already fundamentally broken and
needs fixing.


Reply via email to