Re: [PATCH v2 24/30] drm/amd/display: Move FPU Guards From DML To DC - Part 2

2026-05-11 Thread Xi Ruoyao
On Fri, 2026-05-08 at 16:11 +0800, Xi Ruoyao wrote:
> On Thu, 2026-03-26 at 10:57 +0800, ChuanYu Tseng wrote:
> 
> > 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.
> 
> /* snip */
> 
> > diff --git a/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_wrapper.c 
> > b/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_wrapper.c
> 
> We have:
> 
> CFLAGS_$(AMDDALPATH)/dc/dml2_0/dml2_wrapper.o := $(dml2_rcflags)
> 
> and
> 
> dml2_rcflags := $(CC_FLAGS_NO_FPU)
> 
> so this file isn't compiled as a FPU unit.  Why removing the guards
> here?

> 
> /* snip */
> 
> > index 408559d6fb2d..f8250c80be02 100644
> > --- a/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_wrapper.c
> > +++ b/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_wrapper.c
> > @@ -6,7 +6,20 @@
> >   */
> >  
> >  #include "dml2_internal_types.h"
> > +#include "dml2_wrapper.h"
> >  #include "dml2_wrapper_fpu.h"
> > +#include "dml21_wrapper.h"
> > +#include "dml21_wrapper_fpu.h"
> > +
> > +#include "dc_fpu.h"
> > +
> > +struct dml2_context *dml2_allocate_memory(void)
> > +{
> > +   struct dml2_context *dml2;
> > +
> > +   DC_RUN_WITH_PREEMPTION_ENABLED(dml2 = vzalloc(sizeof(struct 
> > dml2_context)));
> > +   return dml2;
> > +}
> >  
> >  bool dml2_validate(const struct dc *in_dc, struct dc_state *context, 
> > struct dml2_context *dml2,
> >     enum dc_validate_mode validate_mode)
> > @@ -23,16 +36,12 @@ bool dml2_validate(const struct dc *in_dc, struct 
> > dc_state *context, struct dml2
> >     return out;
> >     }
> >  
> > -   DC_FP_START();
> 
> Notably the removal of this is causing:
> 
> [    3.943927] do_fpu invoked from kernel context![#1]:
> [    3.948860] CPU: 0 UID: 0 PID: 11 Comm: kworker/0:1 Not tainted 
> 7.0.3-aosc-main-4k #2 PREEMPT(lazy)

Oh, I didn't expect the code path of 7.0.3 is so different from the
mainline (7.1-rc1).  The mainline has guarded this elsewhere and the
breakage on 7.0.3 is caused by some difference reason that I'm still
trying to figure out...

-- 
Xi Ruoyao 


Re: [PATCH v2 24/30] drm/amd/display: Move FPU Guards From DML To DC - Part 2

2026-05-11 Thread Xi Ruoyao
On Thu, 2026-03-26 at 10:57 +0800, ChuanYu Tseng wrote:

> 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.

/* snip */

> diff --git a/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_wrapper.c 
> b/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_wrapper.c

We have:

CFLAGS_$(AMDDALPATH)/dc/dml2_0/dml2_wrapper.o := $(dml2_rcflags)

and

dml2_rcflags := $(CC_FLAGS_NO_FPU)

so this file isn't compiled as a FPU unit.  Why removing the guards
here?

/* snip */

> index 408559d6fb2d..f8250c80be02 100644
> --- a/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_wrapper.c
> +++ b/drivers/gpu/drm/amd/display/dc/dml2_0/dml2_wrapper.c
> @@ -6,7 +6,20 @@
>   */
>  
>  #include "dml2_internal_types.h"
> +#include "dml2_wrapper.h"
>  #include "dml2_wrapper_fpu.h"
> +#include "dml21_wrapper.h"
> +#include "dml21_wrapper_fpu.h"
> +
> +#include "dc_fpu.h"
> +
> +struct dml2_context *dml2_allocate_memory(void)
> +{
> + struct dml2_context *dml2;
> +
> + DC_RUN_WITH_PREEMPTION_ENABLED(dml2 = vzalloc(sizeof(struct 
> dml2_context)));
> + return dml2;
> +}
>  
>  bool dml2_validate(const struct dc *in_dc, struct dc_state *context, struct 
> dml2_context *dml2,
>   enum dc_validate_mode validate_mode)
> @@ -23,16 +36,12 @@ bool dml2_validate(const struct dc *in_dc, struct 
> dc_state *context, struct dml2
>   return out;
>   }
>  
> - DC_FP_START();

Notably the removal of this is causing:

[3.943927] do_fpu invoked from kernel context![#1]:
[3.948860] CPU: 0 UID: 0 PID: 11 Comm: kworker/0:1 Not tainted 
7.0.3-aosc-main-4k #2 PREEMPT(lazy)
[3.957938] Hardware name: Loongson 
Loongson-3B6000x1-7A2000x1-XB612B0_v1.1/XB612B0_v1.1, BIOS 
Loongson-FwSdk-V5.0.0431-stable202602 04/10/26 09:20:09
[3.971334] Workqueue: sync_wq local_pci_probe_callback
[3.976528] pc 82becd80 ra 82becd30 tp 9001005d8000 sp 
9001005db5e0
[3.984827] a0 80001326ebf8 a1  a2 80001326ec98 a3 
80001326ec90
[3.993124] a4 80001326ec90 a5  a6  a7 

[4.001422] t0 83327000 t1 80001326f000 t2 0001 t3 

[4.009720] t4 0004 t5 0100 t6  t7 

[4.018018] t8  u0 82be8220 s9 9001413e2000 s0 
900160c0
[4.026316] s1 900161c8 s2 900160c0 s3 9001223af080 s4 
900161c8
[4.034613] s5 900160c0 s6 900161c8 s7 900161c4 s8 
80001326a000
[4.042912]ra: 82becd30 
dml21_map_dc_state_into_dml_display_cfg+0x40/0x12a0 [amdgpu]
[4.052169]   ERA: 82becd80 
dml21_map_dc_state_into_dml_display_cfg+0x90/0x12a0 [amdgpu]
[4.061277]  CRMD: 00b0 (PLV0 -IE -DA +PG DACF=CC DACM=CC -WE)
[4.067423]  PRMD: 0004 (PPLV0 +PIE -PWE)
[4.071749]  EUEN:  (-FPE -SXE -ASXE -BTE)
[4.076508]  ECFG: 00071c1d (LIE=0,2-4,10-12 VS=7)
[4.081266] ESTAT: 000f [FPD] (IS= ECode=15 EsubCode=0)
[4.086801]  PRID: 0014d011 (Loongson-64bit, Loongson-3B6000)
[4.092507] Modules linked in: amdgpu(+) hid_logitech_dj i2c_algo_bit 
drm_ttm_helper ttm drm_exec drm_suballoc_helper drm_buddy 
drm_panel_backlight_quirks gpu_sched amdxcp drm_display_helper cec hid_generic 
pwm_loongson la_ow_syscall
 ntsync i2c_dev dmi_sysfs
[4.115253] Process kworker/0:1 (pid: 11, threadinfo=187c43c8, 
task=627a7089)
[4.123725] Stack : 8000135e6360 8000135e66b8  
04380780
[4.131681] 83328000 900161c4 900161c802d8 
82c32b28
[4.139637] 8000135e63f0   

[4.147592]    
900121846010
[4.155548]  900161c8 900161c8 
0001
[4.163504] 0001 9001223af080 900160c0 
80001326a000
[4.171460] 80001326a000 82bef274 900161c86000 
0001
[4.179415] 0010 0001 900161c8 
82aeb330
[4.187371] 900160c0 900160c0 9001413e2000 
9001223af080
[4.195326] 0010 0001 9001415b 
82851348
[4.203282] ...
[4.205705] Call Trace:
[4.205707] [] 
dml21_map_dc_state_into_dml_display_cfg+0x90/0x12a0 [amdgpu]
[4.216978] [] dml21_validate+0xc0/0x160 [amdgpu]
[4.223573] [] dcn401_validate_bandwidth+0xdc/0x290 
[amdgpu]
[4.231156] []