linux/drivers/gpu/drm/amd/display/dc
Huacai Chen 366e77cd49 drm/amd/display: Protect FPU in dml2_validate()/dml21_validate()
Commit 7da55c27e7 ("drm/amd/display: Remove incorrect FP context
start") removes the FP context protection of dml2_create(), and it said
"All the DC_FP_START/END should be used before call anything from DML2".

However, dml2_validate()/dml21_validate() are not protected from their
callers, causing such errors:

 do_fpu invoked from kernel context![#1]:
 CPU: 10 UID: 0 PID: 331 Comm: kworker/10:1H Not tainted 6.14.0-rc6+ #4
 Workqueue: events_highpri dm_irq_work_func [amdgpu]
 pc ffff800003191eb0 ra ffff800003191e60 tp 9000000107a94000 sp 9000000107a975b0
 a0 9000000140ce4910 a1 0000000000000000 a2 9000000140ce49b0 a3 9000000140ce49a8
 a4 9000000140ce49a8 a5 0000000100000000 a6 0000000000000001 a7 9000000107a97660
 t0 ffff800003790000 t1 9000000140ce5000 t2 0000000000000001 t3 0000000000000000
 t4 0000000000000004 t5 0000000000000000 t6 0000000000000000 t7 0000000000000000
 t8 0000000100000000 u0 ffff8000031a3b9c s9 9000000130bc0000 s0 9000000132400000
 s1 9000000140ec0000 s2 9000000132400000 s3 9000000140ce0000 s4 90000000057f8b88
 s5 9000000140ec0000 s6 9000000140ce4910 s7 0000000000000001 s8 9000000130d45010
 ra: ffff800003191e60 dml21_map_dc_state_into_dml_display_cfg+0x40/0x1140 [amdgpu]
   ERA: ffff800003191eb0 dml21_map_dc_state_into_dml_display_cfg+0x90/0x1140 [amdgpu]
  CRMD: 000000b0 (PLV0 -IE -DA +PG DACF=CC DACM=CC -WE)
  PRMD: 00000004 (PPLV0 +PIE -PWE)
  EUEN: 00000000 (-FPE -SXE -ASXE -BTE)
  ECFG: 00071c1d (LIE=0,2-4,10-12 VS=7)
 ESTAT: 000f0000 [FPD] (IS= ECode=15 EsubCode=0)
  PRID: 0014d010 (Loongson-64bit, Loongson-3C6000/S)
 Process kworker/10:1H (pid: 331, threadinfo=000000007bf9ddb0, task=00000000cc4ab9f3)
 Stack : 0000000100000000 0000043800000780 0000000100000001 0000000100000001
         0000000000000000 0000078000000000 0000000000000438 0000078000000000
         0000000000000438 0000078000000000 0000000000000438 0000000100000000
         0000000100000000 0000000100000000 0000000100000000 0000000100000000
         0000000000000001 9000000140ec0000 9000000132400000 9000000132400000
         ffff800003408000 ffff800003408000 9000000132400000 9000000140ce0000
         9000000140ce0000 ffff800003193850 0000000000000001 9000000140ec0000
         9000000132400000 9000000140ec0860 9000000140ec0738 0000000000000001
         90000001405e8000 9000000130bc0000 9000000140ec02a8 ffff8000031b5db8
         0000000000000000 0000043800000780 0000000000000003 ffff8000031b79cc
         ...
 Call Trace:
 [<ffff800003191eb0>] dml21_map_dc_state_into_dml_display_cfg+0x90/0x1140 [amdgpu]
 [<ffff80000319384c>] dml21_validate+0xcc/0x520 [amdgpu]
 [<ffff8000031b8948>] dc_validate_global_state+0x2e8/0x460 [amdgpu]
 [<ffff800002e94034>] create_validate_stream_for_sink+0x3d4/0x420 [amdgpu]
 [<ffff800002e940e4>] amdgpu_dm_connector_mode_valid+0x64/0x240 [amdgpu]
 [<900000000441d6b8>] drm_connector_mode_valid+0x38/0x80
 [<900000000441d824>] __drm_helper_update_and_validate+0x124/0x3e0
 [<900000000441ddc0>] drm_helper_probe_single_connector_modes+0x2e0/0x620
 [<90000000044050dc>] drm_client_modeset_probe+0x23c/0x1780
 [<9000000004420384>] __drm_fb_helper_initial_config_and_unlock+0x44/0x5a0
 [<9000000004403acc>] drm_client_dev_hotplug+0xcc/0x140
 [<ffff800002e9ab50>] handle_hpd_irq_helper+0x1b0/0x1e0 [amdgpu]
 [<90000000038f5da0>] process_one_work+0x160/0x300
 [<90000000038f6718>] worker_thread+0x318/0x440
 [<9000000003901b8c>] kthread+0x12c/0x220
 [<90000000038b1484>] ret_from_kernel_thread+0x8/0xa4

Unfortunately, protecting dml2_validate()/dml21_validate() out of DML2
causes "sleeping function called from invalid context", so protect them
with DC_FP_START() and DC_FP_END() inside.

Fixes: 7da55c27e7 ("drm/amd/display: Remove incorrect FP context start")
Cc: stable@vger.kernel.org
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Tested-by: Dongyan Qian <qiandongyan@loongson.cn>
Reviewed-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2025-04-07 14:36:50 -04:00
..
basics drm/amd/display: Fix BT2020 YCbCr limited/full range input 2025-02-19 15:14:10 -05:00
bios drm/amd/display/dc: Refactor remove duplications 2025-02-27 15:52:32 -05:00
clk_mgr drm/amd/display: Guard against setting dispclk low for dcn31x 2025-03-18 14:03:46 -04:00
core drm/amd/display: Change notification of link BW allocation 2025-03-18 14:03:46 -04:00
dccg drm/amd/display: Refactor DCN4x and related code 2025-02-25 11:44:02 -05:00
dce drm/amd/display: Use HW lock mgr for PSR1 when only one eDP 2025-03-18 14:03:46 -04:00
dce60 drm/amd/display: fix missing .is_two_pixels_per_container 2025-03-07 12:54:51 -05:00
dce80
dce110 drm/amd/display: Remove unused get_max_support_fbc_buffersize 2025-02-12 21:03:03 -05:00
dce112
dce120 drm/amd/display: Add support to configure CRC window on specific CRC instance 2025-01-10 12:03:45 -05:00
dcn10 drm/amd/display: log destination of vertical interrupt 2025-02-12 21:02:57 -05:00
dcn20
dcn21
dcn30 drm/amd/display: Remove unused cm3_helper_translate_curve_to_degamma_hw_format 2024-11-04 11:26:20 -05:00
dcn31 drm/amd/display: Refactor dcn31_panel_construct to avoid assert 2024-12-10 10:31:24 -05:00
dcn201
dcn301
dio drm/amd/display: misc for dio encoder refactor 2025-03-05 10:39:20 -05:00
dml drm/amd/display: Update static soc table 2025-03-18 14:03:47 -04:00
dml2 drm/amd/display: Protect FPU in dml2_validate()/dml21_validate() 2025-04-07 14:36:50 -04:00
dpp drm/amd/display: handle max_downscale_src_width fail check 2025-02-25 11:45:11 -05:00
dsc drm/amd/display: Allow reuse of of DCN4x code 2025-02-12 21:03:01 -05:00
dwb drm/amd/display: Remove unused dwb3_set_host_read_rate_control 2024-12-10 10:38:19 -05:00
gpio drm/amd/display: Add DCN36 GPIO 2025-02-12 21:04:07 -05:00
hdcp
hpo drm/amd/display: Refactor DCN4x and related code 2025-02-25 11:44:02 -05:00
hubbub drm/amd/display: Remove unused hubbub1_toggle_watermark_change_req 2025-02-12 21:03:03 -05:00
hubp drm/amd/display: Allow reuse of of DCN4x code 2025-02-12 21:03:01 -05:00
hwss drm/amd/display: prevent hang on link training fail 2025-03-26 17:43:25 -04:00
inc drm/amd/display: Change notification of link BW allocation 2025-03-18 14:03:46 -04:00
irq drm/amd/display: Add DCN36 IRQ 2025-02-12 21:04:07 -05:00
link drm/amd/display: Revert "Support for reg inbox0 for host->DMUB CMDs" 2025-03-18 14:03:46 -04:00
mmhubbub drm/amd/display: Allow reuse of of DCN4x code 2025-02-12 21:03:01 -05:00
mpc drm/amd/display: Refactor DCN4x and related code 2025-02-25 11:44:02 -05:00
opp
optc drm/amd/display: Refactor DCN4x and related code 2025-02-25 11:44:02 -05:00
pg
resource drm/amd/display: change kzalloc to kcalloc in dml1_validate() 2025-03-10 13:36:17 -04:00
sspl drm/amd/display: Remove incorrect macro guard 2025-03-13 23:11:55 -04:00
virtual
Makefile drm/amd/display: Move SPL to a new path 2025-02-12 21:03:01 -05:00
dc.h drm/amd/display: 3.2.325 2025-03-18 14:03:47 -04:00
dc_bios_types.h
dc_ddc_types.h
dc_dmub_srv.c drm/amd/display: Revert "Support for reg inbox0 for host->DMUB CMDs" 2025-03-18 14:03:46 -04:00
dc_dmub_srv.h drm/amd/display: Revert "Support for reg inbox0 for host->DMUB CMDs" 2025-03-18 14:03:46 -04:00
dc_dp_types.h drm/amd/display: Implement PCON regulated autonomous mode handling 2025-03-10 13:28:34 -04:00
dc_dsc.h drm/amd/display: Add Interface to Dump DSC Caps from dm 2025-01-06 14:44:27 -05:00
dc_edid_parser.c
dc_edid_parser.h
dc_hdmi_types.h
dc_helper.c drm/amd/display: Revert "Support for reg inbox0 for host->DMUB CMDs" 2025-03-18 14:03:46 -04:00
dc_hw_types.h drm/amd/display: Do not enable replay when vtotal update is pending. 2025-03-10 13:28:17 -04:00
dc_plane.h drm/amd/display: Rename panic function 2025-02-19 15:12:49 -05:00
dc_plane_priv.h
dc_spl_translate.c drm/amd/display: Move SPL to a new path 2025-02-12 21:03:01 -05:00
dc_spl_translate.h drm/amd/display: add back quality EASF and ISHARP and dc dependency changes 2024-08-27 17:53:58 -04:00
dc_stat.h
dc_state.h drm/amd/display: Eliminate recursive header inclusion 2024-10-01 17:37:50 -04:00
dc_state_priv.h
dc_stream.h drm/amd/display: Remove unused dc_stream_get_crtc_position 2025-02-12 21:03:02 -05:00
dc_stream_priv.h
dc_trace.h
dc_types.h drm/amd/display: Change notification of link BW allocation 2025-03-18 14:03:46 -04:00
dm_cp_psp.h
dm_event_log.h
dm_helpers.h drm/amd/display: Add HBlank reduction DPCD write to DPMS sequence 2025-01-06 14:44:27 -05:00
dm_pp_smu.h
dm_services.h drm/amd/display: ACPI Re-timer Programming 2025-02-25 11:44:36 -05:00
dm_services_types.h drm/amd/display: ACPI Re-timer Programming 2025-02-25 11:44:36 -05:00
irq_types.h drm/amd/display: add new IRQ enum for underflows 2025-02-12 21:04:09 -05:00
os_types.h