DC Patches for Nov 30 2026
v2 cover DC Patches for Nov 30 2026
This version brings along the following updates:
- Harden AUX handling: clamp the AUX reply length as unsigned, keep the DPCD read result signed in the MST ISR, and copy only the status byte on a DMUB AUX write status retry, with a test for the reply copy
- Cast the clamped rate conversion
- Make BLS sequences compliant: split HWSS_CURSOR_LOCK into flat BLS operations and make DPP_SET_INPUT_TRANSFER_FUNC BLS compliant
- Account for downspread and DFS in clock validation and read the max LSDMA bandwidth from DMU
- Precompute EASF lookup thresholds
- Add pipe init to core2
- Fix HDMI FRL no_timeout behavior
- Re-enable driver-controlled HUBP/DPP power gating on DCN42 and DCN42b
- DC2: program DSC on one stream, program YCbCr output, flip every DPP pipe of the stream, skip streams with no OTG master, and sync OTG timing in the non-seamless commit
- DC2: add a per-ASIC default for DC2 selection and report BLS step overflow behind a debug option
- Disable Replay and PSR across GPU reset and correctly block Panel Replay on MST
- Cover gamma 2.4 and 2.6 on the wide curve
- Improve P-state admissibility logic and revoke alternate channel P-State before pipe teardown
- Refactor Max VStartup calculations for DCN6
- Add VRR support on direct MST sinks
- Move shared dcn401 builder code to its own file
v2: Fixed the incorrect cover letter and added missing patches from v1
Charlene Liu (1):
drm/amd/display: enable dcn42b hubp/dpp pg control from driver side
Dillon Varone (2):
drm/amd/display: Refactor Max VStartup calculations for DCN6 drm/amd/display: Improve P-state admissability logic
Fangzhi Zuo (1):
drm/amd/display: VRR Support on Direct MST Sinks
Harry Wentland (1):
drm/amd/display: cover gamma 2.4 and 2.6 on the wide curve
Ilya Bakoulin (2):
drm/amd/display: Account for downspread and DFS in clock validation drm/amd/display: Fix HDMI FRL no_timeout behavior
Ivan Lipski (2):
drm/amd/display: Read max LSDMA BW from DMU drm/amd/display: Revoke alternate channel P-State before pipe teardown
James Lin (2):
drm/amd/display: cast clamped rate conversion drm/amd/display: Allow disabling CRC capture when the stream is gone
Leo Chen (1):
drm/amd/display: Re-enable HUBP/DPP Driver PG on DCN42
Peichen Huang (1):
drm/amd/display: block pr in mst right
Piotr Maziarz (1):
drm/amd/display: Split HWSS_CURSOR_LOCK into flat BLS operations
Rafal Ostrowski (1):
drm/amd/display: Make DPP_SET_INPUT_TRANSFER_FUNC BLS compliant
Taimur Hassan (1):
drm/amd/display: Promote DC to 3.2.410
Tom Chung (4):
drm/amd/display: clamp AUX reply length as unsigned drm/amd/display: keep the DPCD read result signed in the MST ISR drm/amd/display: copy only the status byte on a DMUB AUX write status
retry
drm/amd/display: test the DMUB AUX write status reply copy
Tomasz Siemek (2):
drm/amd/display: Add pipe init to core2 drm/amd/display: Add a per-ASIC default for the DC2 selection
Tony Cheng (7):
drm/amd/display: Program DSC on one stream in DC2 drm/amd/display: Flip every DPP pipe of the stream in DC2 drm/amd/display: Report a DC2 BLS step overflow behind a debug option drm/amd/display: Program YCbCr output in DC2 drm/amd/display: Skip a stream with no OTG master in DC2 drm/amd/display: Sync OTG timing in the DC2 non-seamless commit drm/amd/display: Move shared dcn401 builder code to its own file
deguo (1):
drm/amd/display: Precompute EASF lookup thresholds
.../display/amdgpu_dm/amdgpu_dm_connector.c | 44 +- .../drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c | 12 +- .../amd/display/amdgpu_dm/amdgpu_dm_dmub.c | 8 +- .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 5 +- .../tests/amdgpu_dm_connector_test.c | 130 ++ .../amdgpu_dm/tests/amdgpu_dm_crc_test.c | 4 +- .../amdgpu_dm/tests/amdgpu_dm_dmub_test.c | 81 + .../tests/amdgpu_dm_mst_types_test.c | 2 + drivers/gpu/drm/amd/display/dc/Makefile | 1 + .../amd/display/dc/bls_builder/bls_builder.c | 2 +- .../amd/display/dc/bls_builder/bls_builder.h | 5 + .../dc/bls_builder/bls_builder_internal.h | 3 +- .../bls_builder/bls_builder_private_types.h | 9 +- .../dc/bls_builder/dcn401_builder_internal.c | 1817 +++++++++++++++++ .../dc/bls_builder/dcn401_builder_internal.h | 8 + .../dc/bls_builder/dcn401_init_builder.c | 16 +- .../bls_builder/dcn401_init_builder_legacy.c | 2 +- .../bls_builder/dcn401_non_seamless_builder.c | 125 +- .../dc/bls_builder/dcn401_seamless_builder.c | 1755 +--------------- .../display/dc/bls_executor/bls_executor.c | 175 +- .../display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c | 35 +- .../drm/amd/display/dc/core/dc_hw_sequencer.c | 305 ++- .../gpu/drm/amd/display/dc/core2/dc_core2.c | 45 +- .../gpu/drm/amd/display/dc/core2/dc_core2.h | 8 + .../drm/amd/display/dc/core2/dc_core2_init.c | 71 +- drivers/gpu/drm/amd/display/dc/dc.h | 4 +- .../amd/display/dc/dc_api_dispatch/api_shim.c | 30 +- .../amd/display/dc/dc_api_dispatch/api_shim.h | 1 + .../amd/display/dc/dcn10/dcn10_cm_common.c | 4 +- .../amd/display/dc/dcn30/dcn30_cm_common.c | 2 + .../dml2_0/dml21/src/dml2_cga/dml2_cga_dcn6.c | 43 +- .../dml2_core_dcn5_funcs_mode_support.c | 11 +- .../src/dml2_core/dml2_core_dcn6_calcs.h | 6 +- .../dml2_core/dml2_core_dcn6_calcs_dchub.c | 19 +- .../dml2_core/dml2_core_dcn6_calcs_dchub.h | 6 +- .../dml2_core_dcn6_funcs_initialize.c | 3 + .../dml2_core_dcn6_funcs_mode_support.c | 18 +- .../src/dml2_core/dml2_core_shared_types.h | 1 + .../dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c | 20 +- .../src/inc/dml2_internal_shared_types.h | 2 + .../display/dc/hubbub/dcn10/dcn10_hubbub.c | 1 + .../display/dc/hubbub/dcn20/dcn20_hubbub.c | 1 + .../display/dc/hubbub/dcn201/dcn201_hubbub.c | 1 + .../display/dc/hubbub/dcn21/dcn21_hubbub.c | 1 + .../display/dc/hubbub/dcn30/dcn30_hubbub.c | 3 +- .../display/dc/hubbub/dcn301/dcn301_hubbub.c | 1 + .../display/dc/hubbub/dcn31/dcn31_hubbub.c | 3 +- .../display/dc/hubbub/dcn32/dcn32_hubbub.c | 3 +- .../display/dc/hubbub/dcn35/dcn35_hubbub.c | 3 +- .../display/dc/hubbub/dcn401/dcn401_hubbub.c | 3 +- .../display/dc/hubbub/dcn42/dcn42_hubbub.c | 3 +- .../display/dc/hubbub/dcn60/dcn60_hubbub.c | 1 + .../amd/display/dc/hwss/dce110/dce110_hwseq.c | 19 +- .../amd/display/dc/hwss/dcn10/dcn10_hwseq.c | 133 +- .../amd/display/dc/hwss/dcn10/dcn10_hwseq.h | 2 + .../amd/display/dc/hwss/dcn10/dcn10_init.c | 1 + .../amd/display/dc/hwss/dcn20/dcn20_hwseq.c | 45 +- .../amd/display/dc/hwss/dcn20/dcn20_hwseq.h | 5 +- .../amd/display/dc/hwss/dcn20/dcn20_init.c | 1 + .../amd/display/dc/hwss/dcn201/dcn201_init.c | 1 + .../amd/display/dc/hwss/dcn21/dcn21_init.c | 1 + .../amd/display/dc/hwss/dcn30/dcn30_hwseq.c | 32 +- .../amd/display/dc/hwss/dcn30/dcn30_hwseq.h | 2 +- .../amd/display/dc/hwss/dcn30/dcn30_init.c | 1 + .../amd/display/dc/hwss/dcn301/dcn301_init.c | 1 + .../amd/display/dc/hwss/dcn31/dcn31_init.c | 1 + .../amd/display/dc/hwss/dcn314/dcn314_init.c | 1 + .../amd/display/dc/hwss/dcn32/dcn32_hwseq.c | 102 +- .../amd/display/dc/hwss/dcn32/dcn32_hwseq.h | 5 +- .../amd/display/dc/hwss/dcn32/dcn32_init.c | 1 + .../amd/display/dc/hwss/dcn35/dcn35_hwseq.c | 3 +- .../amd/display/dc/hwss/dcn35/dcn35_init.c | 1 + .../amd/display/dc/hwss/dcn351/dcn351_init.c | 1 + .../amd/display/dc/hwss/dcn401/dcn401_hwseq.c | 74 +- .../amd/display/dc/hwss/dcn401/dcn401_hwseq.h | 5 +- .../amd/display/dc/hwss/dcn401/dcn401_init.c | 3 +- .../amd/display/dc/hwss/dcn42/dcn42_hwseq.c | 56 +- .../amd/display/dc/hwss/dcn42/dcn42_hwseq.h | 13 +- .../amd/display/dc/hwss/dcn42/dcn42_init.c | 1 + .../amd/display/dc/hwss/dcn60/dcn60_hwseq.c | 33 +- .../amd/display/dc/hwss/dcn60/dcn60_hwseq.h | 2 +- .../amd/display/dc/hwss/dcn60/dcn60_init.c | 1 + .../drm/amd/display/dc/hwss/hw_sequencer.h | 172 +- .../display/dc/hwss/hw_sequencer_private.h | 22 +- .../gpu/drm/amd/display/dc/inc/core_types.h | 2 - .../amd/display/dc/inc/dc_core_interface.h | 14 +- .../gpu/drm/amd/display/dc/inc/hw/dchubbub.h | 1 + .../gpu/drm/amd/display/dc/inc/hw/hw_shared.h | 2 + .../drm/amd/display/dc/link/link_dpms_v1.c | 1 + .../dc/link/protocols/link_dp_panel_replay.c | 20 +- .../display/dc/link/protocols/link_hdmi_frl.c | 25 +- .../display/dc/link/protocols/link_hdmi_frl.h | 1 + .../dc/resource/dcn42/dcn42_resource.c | 4 +- .../dc/resource/dcn42b/dcn42b_resource.c | 4 +- .../dcn60/dcn60_soc_and_ip_translator.c | 2 + .../display/dc/sspl/dc_spl_scl_easf_filters.c | 478 ++--- .../display/dc/sspl/dc_spl_scl_easf_filters.h | 3 +- .../workaround_manager/workaround_manager.c | 122 +- .../amd/display/modules/freesync/freesync.c | 2 +- 99 files changed, 3748 insertions(+), 2536 deletions(-) create mode 100644 drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.c
--
2.56.1
PATCH v2 1/30 drm/amd/display: cast clamped rate conversion
From: James Lin <[email protected]>
[Why]vrr_refresh_hz_u8() returns an unsigned char, but the clamped refresh rate is calculated as an unsigned int. The implicit narrowing conversion can trigger compiler warnings.
[How]
Cast the result to unsigned char after clamping it to 255. The cast makes the conversion explicit without changing the value encoded in the FreeSync infopacket.
--- drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/modules/freesync/freesync.c +1 -1
@@ -574,7 +574,7 @@ static bool vrr_settings_require_update(struct core_freesync *core_freesync,/* v1/v2 packets hold each rate in one byte; saturate instead of wrapping. */ static unsigned char vrr_refresh_hz_u8 (unsigned int refresh_in_uhz) { -return min ((refresh_in_uhz +500000 ) /1000000 ,255U ); +return (unsigned char )min ((refresh_in_uhz +500000 ) /1000000 ,255U ); } static void build_vrr_infopacket_data_v1(const struct mod_vrr_params *vrr,
Signature · 1 line
2.56.1
PATCH v2 2/30 drm/amd/display: Split HWSS_CURSOR_LOCK into flat BLS operations
In reply to George ZhangFrom: Piotr Maziarz <[email protected]>
[WHY]HWSS_CURSOR_LOCK carried dc and pipe_ctx, and its executor called dc->hwss.cursor_lock(), which decided at run time between the VUPDATE keepout delay, the DMUB inbox1 lock and the MPC cursor lock, against the BLS contract.
[HOW]
Add hwss.build_cursor_lock_sequence, implemented by dcn10_build_cursor_lock_sequence() and bound wherever dcn10_cursor_lock is. It captures the VUPDATE window, stream timing and lock targets when the sequence is built. hwss_add_cursor_lock() turns that into TG_DELAY_CURSOR_UNTIL_VUPDATE (lock only), then DMUB_HW_LOCK_MGR_CMD or MPC_CURSOR_LOCK. Without the builder (DCE), it emits the pipe control lock that DCE binds as cursor_lock. dcn10_cursor_lock() runs the same executors, and the fast sequence uses hwss_add_cursor_lock() instead of hand-built steps. HWSS_CURSOR_LOCK is removed.
--- .../drm/amd/display/dc/core/dc_hw_sequencer.c | 180 +++++++++++++----- .../amd/display/dc/hwss/dcn10/dcn10_hwseq.c | 118 ++++-------- .../amd/display/dc/hwss/dcn10/dcn10_hwseq.h | 2 + .../amd/display/dc/hwss/dcn10/dcn10_init.c | 1 + .../amd/display/dc/hwss/dcn20/dcn20_init.c | 1 + .../amd/display/dc/hwss/dcn201/dcn201_init.c | 1 + .../amd/display/dc/hwss/dcn21/dcn21_init.c | 1 + .../amd/display/dc/hwss/dcn30/dcn30_init.c | 1 + .../amd/display/dc/hwss/dcn301/dcn301_init.c | 1 + .../amd/display/dc/hwss/dcn31/dcn31_init.c | 1 + .../amd/display/dc/hwss/dcn314/dcn314_init.c | 1 + .../amd/display/dc/hwss/dcn32/dcn32_init.c | 1 + .../amd/display/dc/hwss/dcn35/dcn35_init.c | 1 + .../amd/display/dc/hwss/dcn351/dcn351_init.c | 1 + .../amd/display/dc/hwss/dcn401/dcn401_init.c | 1 + .../amd/display/dc/hwss/dcn42/dcn42_init.c | 1 + .../amd/display/dc/hwss/dcn60/dcn60_init.c | 1 + .../drm/amd/display/dc/hwss/hw_sequencer.h | 56 +++++- 18 files changed, 236 insertions(+), 134 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c +129 -51
@@ -1387,20 +1387,10 @@ void hwss_build_fast_sequence(struct dc *dc,if (enable_cursor_offload && dc->hwss.begin_cursor_offload_update) {hwss_add_begin_cursor_offload_update (&seq_state, dc, current_pipe); }else { - block_sequence[*num_steps].params.cursor_lock_params.dc = dc; - block_sequence[*num_steps].params.cursor_lock_params.pipe_ctx = current_pipe; - block_sequence[*num_steps].params.cursor_lock_params.lock = true; - block_sequence[*num_steps].func =HWSS_CURSOR_LOCK ; - (*num_steps)++; - -if (current_pipe->next_odm_pipe) { - block_sequence[*num_steps].params.cursor_lock_params.dc = dc; - block_sequence[*num_steps].params.cursor_lock_params.pipe_ctx = - current_pipe->next_odm_pipe; - block_sequence[*num_steps].params.cursor_lock_params.lock = true; - block_sequence[*num_steps].func =HWSS_CURSOR_LOCK ; - (*num_steps)++; - } +hwss_add_cursor_lock (&seq_state, dc, current_pipe, true); +if (current_pipe->next_odm_pipe) +hwss_add_cursor_lock (&seq_state, dc, + current_pipe->next_odm_pipe, true); } }
@@ -1435,20 +1425,10 @@ void hwss_build_fast_sequence(struct dc *dc,if (enable_cursor_offload && dc->hwss.commit_cursor_offload_update) {hwss_add_commit_cursor_offload_update (&seq_state, dc, cursor_pipe_to_program); }else { - block_sequence[*num_steps].params.cursor_lock_params.dc = dc; - block_sequence[*num_steps].params.cursor_lock_params.pipe_ctx = cursor_pipe_to_program; - block_sequence[*num_steps].params.cursor_lock_params.lock = false; - block_sequence[*num_steps].func =HWSS_CURSOR_LOCK ; - (*num_steps)++; - -if (cursor_pipe_to_program->next_odm_pipe) { - block_sequence[*num_steps].params.cursor_lock_params.dc = dc; - block_sequence[*num_steps].params.cursor_lock_params.pipe_ctx = - cursor_pipe_to_program->next_odm_pipe; - block_sequence[*num_steps].params.cursor_lock_params.lock = false; - block_sequence[*num_steps].func =HWSS_CURSOR_LOCK ; - (*num_steps)++; - } +hwss_add_cursor_lock (&seq_state, dc, cursor_pipe_to_program, false); +if (cursor_pipe_to_program->next_odm_pipe) +hwss_add_cursor_lock (&seq_state, dc, + cursor_pipe_to_program->next_odm_pipe, false); } } }
@@ -1477,11 +1457,7 @@ void hwss_build_fast_sequence(struct dc *dc,if (enable_cursor_offload && dc->hwss.begin_cursor_offload_update) {hwss_add_begin_cursor_offload_update (&seq_state, dc, current_pipe); }else { - block_sequence[*num_steps].params.cursor_lock_params.dc = dc; - block_sequence[*num_steps].params.cursor_lock_params.pipe_ctx = current_pipe; - block_sequence[*num_steps].params.cursor_lock_params.lock = true; - block_sequence[*num_steps].func =HWSS_CURSOR_LOCK ; - (*num_steps)++; +hwss_add_cursor_lock (&seq_state, dc, current_pipe, true); } }
@@ -1510,11 +1486,7 @@ void hwss_build_fast_sequence(struct dc *dc,if (enable_cursor_offload && dc->hwss.commit_cursor_offload_update) {hwss_add_commit_cursor_offload_update (&seq_state, dc, cursor_pipe_to_program); }else { - block_sequence[*num_steps].params.cursor_lock_params.dc = dc; - block_sequence[*num_steps].params.cursor_lock_params.pipe_ctx = cursor_pipe_to_program; - block_sequence[*num_steps].params.cursor_lock_params.lock = false; - block_sequence[*num_steps].func =HWSS_CURSOR_LOCK ; - (*num_steps)++; +hwss_add_cursor_lock (&seq_state, dc, cursor_pipe_to_program, false); } } }
@@ -2152,9 +2124,6 @@ void hwss_execute_sequence(struct dc *dc,case HUBP_MEM_PROGRAM_VIEWPORT :hwss_hubp_mem_program_viewport (params);break ; -case HWSS_CURSOR_LOCK : -hwss_cursor_lock (params); -break ;case HWSS_BEGIN_CURSOR_OFFLOAD_UPDATE :hwss_begin_cursor_offload_update (dc, params);break ;
@@ -2266,6 +2235,15 @@ void hwss_execute_sequence(struct dc *dc,case DMUB_FAMS2_UPDATE_CONFIG :hwss_dmub_fams2_update_config (params);break ; +case TG_DELAY_CURSOR_UNTIL_VUPDATE : +hwss_tg_delay_cursor_until_vupdate (params); +break ; +case MPC_CURSOR_LOCK : +hwss_mpc_cursor_lock (params); +break ; +case DMUB_HW_LOCK_MGR_CMD : +hwss_dmub_hw_lock_mgr_cmd (params); +break ;default :ASSERT (false);break ;
@@ -4554,14 +4532,72 @@ void hwss_hubp_mem_program_viewport(union block_sequence_params *params) hubp->funcs->mem_program_viewport (hubp, viewport, viewport_c); } -void hwss_cursor_lock (union block_sequence_params *params) +/** +* hwss_tg_delay_cursor_until_vupdate() - Delay cursor update if too close to VUPDATE. +* +* Software keepout workaround to prevent cursor update locking from stalling +* out cursor updates indefinitely or from old values from being retained in +* the case where the viewport changes in the same frame as the cursor. +* +* The idea is to calculate the remaining time from VPOS to VUPDATE. If it's +* too close to VUPDATE, then stall out until VUPDATE finishes. +* +* TODO: Optimize cursor programming to be once per frame before VUPDATE +* to avoid the need for this workaround. +* +* @params: TG, stream timing and VUPDATE window captured when building +*/ +void hwss_tg_delay_cursor_until_vupdate (union block_sequence_params *params) { -struct dc *dc = params->cursor_lock_params.dc; -struct pipe_ctx *pipe_ctx = params->cursor_lock_params.pipe_ctx; -bool lock = params->cursor_lock_params.lock; +const struct tg_delay_cursor_until_vupdate_params *p = + ¶ms->tg_delay_cursor_until_vupdate_params; +struct crtc_position position; +uint32_t vupdate_end = p->vupdate_end; +unsigned int lines_to_vupdate, us_to_vupdate, vpos; +unsigned int us_per_line, us_vupdate; + + p->tg->funcs->get_position (p->tg, &position); + vpos = position.vertical_count; -if (dc && dc->hwss.cursor_lock) - dc->hwss.cursor_lock (dc, pipe_ctx, lock); +if (vpos <= p->vupdate_start) { +/* VPOS is in VACTIVE or back porch. */ + lines_to_vupdate = p->vupdate_start - vpos; + }else { + lines_to_vupdate = p->v_total - vpos + p->vupdate_start; + } + +/* Calculate time until VUPDATE in microseconds. */ + us_per_line = p->h_total *10000u / p->pix_clk_100hz; + us_to_vupdate = lines_to_vupdate * us_per_line; + +/* Stall out until the cursor update completes. */ +if (vupdate_end < p->vupdate_start) + vupdate_end += p->v_total; + +/* Position is in the range of vupdate start and end*/ +if (lines_to_vupdate > p->v_total - vupdate_end + p->vupdate_start) + us_to_vupdate =0 ; + +/* 70 us is a conservative estimate of cursor update time*/ +if (us_to_vupdate >70 ) +return ; + + us_vupdate = (vupdate_end - p->vupdate_start +1 ) * us_per_line; +udelay (us_to_vupdate + us_vupdate); +} + +void hwss_mpc_cursor_lock (union block_sequence_params *params) +{ +struct mpc_cursor_lock_params *p = ¶ms->mpc_cursor_lock_params; + + p->mpc->funcs->cursor_lock (p->mpc, p->opp_inst, p->lock); +} + +void hwss_dmub_hw_lock_mgr_cmd (union block_sequence_params *params) +{ +struct dmub_hw_lock_mgr_cmd_params *p = ¶ms->dmub_hw_lock_mgr_cmd_params; + +dmub_hw_lock_mgr_cmd (p->dmub_srv, p->lock, &p->hw_locks, &p->inst_flags); }void hwss_begin_cursor_offload_update (struct dc *dc,union block_sequence_params *params)
@@ -6389,15 +6425,57 @@ void hwss_add_cursor_lock(struct block_sequence_state *seq_state, struct pipe_ctx *pipe_ctx, bool lock) { +struct cursor_lock_sequence_params params = {0 }; +/* cursor lock is per MPCC tree, so only need to lock one pipe per stream */ if (!pipe_ctx || pipe_ctx->top_pipe)return ; +if (!dc->hwss.build_cursor_lock_sequence) { +/* DCE binds cursor_lock to hwss_pipe_control_lock. */ +if (dc->hwss.cursor_lock) +hwss_add_optc_pipe_control_lock (seq_state, dc, pipe_ctx, lock); +return ; + } + +if (!dc->hwss.build_cursor_lock_sequence (dc, pipe_ctx, lock, ¶ms)) +return ; + +if (params.delay_until_vupdate) +hwss_add_tg_delay_cursor_until_vupdate (seq_state, ¶ms.delay); + +if (params.use_dmub_inbox1) +hwss_add_dmub_hw_lock_mgr_cmd (seq_state, ¶ms.dmub_lock); +else +hwss_add_mpc_cursor_lock (seq_state, ¶ms.mpc_lock); +} + +void hwss_add_tg_delay_cursor_until_vupdate (struct block_sequence_state *seq_state, +const struct tg_delay_cursor_until_vupdate_params *params) +{ +if (*seq_state->num_steps <MAX_HWSS_BLOCK_SEQUENCE_SIZE ) { + seq_state->steps[*seq_state->num_steps].func =TG_DELAY_CURSOR_UNTIL_VUPDATE ; + seq_state->steps[*seq_state->num_steps].params.tg_delay_cursor_until_vupdate_params = *params; + (*seq_state->num_steps)++; + } +} + +void hwss_add_mpc_cursor_lock (struct block_sequence_state *seq_state, +const struct mpc_cursor_lock_params *params) +{ +if (*seq_state->num_steps <MAX_HWSS_BLOCK_SEQUENCE_SIZE ) { + seq_state->steps[*seq_state->num_steps].func =MPC_CURSOR_LOCK ; + seq_state->steps[*seq_state->num_steps].params.mpc_cursor_lock_params = *params; + (*seq_state->num_steps)++; + } +} + +void hwss_add_dmub_hw_lock_mgr_cmd (struct block_sequence_state *seq_state, +const struct dmub_hw_lock_mgr_cmd_params *params) +{if (*seq_state->num_steps <MAX_HWSS_BLOCK_SEQUENCE_SIZE ) { - seq_state->steps[*seq_state->num_steps].func =HWSS_CURSOR_LOCK ; - seq_state->steps[*seq_state->num_steps].params.cursor_lock_params.dc = dc; - seq_state->steps[*seq_state->num_steps].params.cursor_lock_params.pipe_ctx = pipe_ctx; - seq_state->steps[*seq_state->num_steps].params.cursor_lock_params.lock = lock; + seq_state->steps[*seq_state->num_steps].func =DMUB_HW_LOCK_MGR_CMD ; + seq_state->steps[*seq_state->num_steps].params.dmub_hw_lock_mgr_cmd_params = *params; (*seq_state->num_steps)++; } }
drivers/gpu/drm/amd/display/dc/hwss/dcn10/dcn10_hwseq.c +41 -77
137 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hwss/dcn10/dcn10_hwseq.h +2 -0
@@ -58,6 +58,8 @@ void dcn10_set_wait_for_update_needed_for_pipe(struct dc *dc, struct pipe_ctx *pipe_ctx);void dcn10_tg_lock (struct tg_lock_params *params); +bool dcn10_build_cursor_lock_sequence (struct dc *dc,struct pipe_ctx *pipe,bool lock, +struct cursor_lock_sequence_params *params);void dcn10_cursor_lock (struct dc *dc,struct pipe_ctx *pipe,bool lock); void dcn10_blank_pixel_data( struct dc *dc,
drivers/gpu/drm/amd/display/dc/hwss/dcn10/dcn10_init.c +1 -0
@@ -57,6 +57,7 @@ static const struct hw_sequencer_funcs dcn10_funcs = { .disable_audio_stream = dce110_disable_audio_stream, .disable_plane = dcn10_disable_plane, .build_pipe_control_lock_sequence = dce_build_pipe_control_lock_sequence, + .build_cursor_lock_sequence = dcn10_build_cursor_lock_sequence, .tg_lock = dcn10_tg_lock, .cursor_lock = dcn10_cursor_lock, .interdependent_update_lock = dcn10_lock_all_pipes,
drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_init.c +1 -0
@@ -58,6 +58,7 @@ static const struct hw_sequencer_funcs dcn20_funcs = { .disable_audio_stream = dce110_disable_audio_stream, .disable_plane = dcn20_disable_plane, .build_pipe_control_lock_sequence = dcn20_build_pipe_control_lock_sequence, + .build_cursor_lock_sequence = dcn10_build_cursor_lock_sequence, .tg_lock = dcn20_tg_lock, .interdependent_update_lock = dcn10_lock_all_pipes, .cursor_lock = dcn10_cursor_lock,
drivers/gpu/drm/amd/display/dc/hwss/dcn201/dcn201_init.c +1 -0
@@ -58,6 +58,7 @@ static const struct hw_sequencer_funcs dcn201_funcs = { .disable_audio_stream = dce110_disable_audio_stream, .disable_plane = dcn10_disable_plane, .build_pipe_control_lock_sequence = dce_build_pipe_control_lock_sequence, + .build_cursor_lock_sequence = dcn10_build_cursor_lock_sequence, .tg_lock = dcn201_tg_lock, .interdependent_update_lock = dcn10_lock_all_pipes, .cursor_lock = dcn10_cursor_lock,
drivers/gpu/drm/amd/display/dc/hwss/dcn21/dcn21_init.c +1 -0
@@ -58,6 +58,7 @@ static const struct hw_sequencer_funcs dcn21_funcs = { .disable_audio_stream = dce110_disable_audio_stream, .disable_plane = dcn20_disable_plane, .build_pipe_control_lock_sequence = dcn20_build_pipe_control_lock_sequence, + .build_cursor_lock_sequence = dcn10_build_cursor_lock_sequence, .tg_lock = dcn20_tg_lock, .interdependent_update_lock = dcn10_lock_all_pipes, .cursor_lock = dcn10_cursor_lock,
drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_init.c +1 -0
@@ -59,6 +59,7 @@ static const struct hw_sequencer_funcs dcn30_funcs = { .disable_plane = dcn20_disable_plane, .disable_pixel_data = dcn20_disable_pixel_data, .build_pipe_control_lock_sequence = dcn20_build_pipe_control_lock_sequence, + .build_cursor_lock_sequence = dcn10_build_cursor_lock_sequence, .tg_lock = dcn20_tg_lock, .interdependent_update_lock = dcn10_lock_all_pipes, .cursor_lock = dcn10_cursor_lock,
drivers/gpu/drm/amd/display/dc/hwss/dcn301/dcn301_init.c +1 -0
@@ -60,6 +60,7 @@ static const struct hw_sequencer_funcs dcn301_funcs = { .disable_audio_stream = dce110_disable_audio_stream, .disable_plane = dcn20_disable_plane, .build_pipe_control_lock_sequence = dcn20_build_pipe_control_lock_sequence, + .build_cursor_lock_sequence = dcn10_build_cursor_lock_sequence, .tg_lock = dcn20_tg_lock, .interdependent_update_lock = dcn10_lock_all_pipes, .cursor_lock = dcn10_cursor_lock,
drivers/gpu/drm/amd/display/dc/hwss/dcn31/dcn31_init.c +1 -0
@@ -62,6 +62,7 @@ static const struct hw_sequencer_funcs dcn31_funcs = { .disable_plane = dcn20_disable_plane, .disable_pixel_data = dcn20_disable_pixel_data, .build_pipe_control_lock_sequence = dcn20_build_pipe_control_lock_sequence, + .build_cursor_lock_sequence = dcn10_build_cursor_lock_sequence, .tg_lock = dcn20_tg_lock, .interdependent_update_lock = dcn10_lock_all_pipes, .cursor_lock = dcn10_cursor_lock,
drivers/gpu/drm/amd/display/dc/hwss/dcn314/dcn314_init.c +1 -0
@@ -64,6 +64,7 @@ static const struct hw_sequencer_funcs dcn314_funcs = { .disable_plane = dcn20_disable_plane, .disable_pixel_data = dcn20_disable_pixel_data, .build_pipe_control_lock_sequence = dcn20_build_pipe_control_lock_sequence, + .build_cursor_lock_sequence = dcn10_build_cursor_lock_sequence, .tg_lock = dcn20_tg_lock, .interdependent_update_lock = dcn10_lock_all_pipes, .cursor_lock = dcn10_cursor_lock,
drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_init.c +1 -0
@@ -62,6 +62,7 @@ static const struct hw_sequencer_funcs dcn32_funcs = { .disable_plane = dcn20_disable_plane, .disable_pixel_data = dcn20_disable_pixel_data, .build_pipe_control_lock_sequence = dcn20_build_pipe_control_lock_sequence, + .build_cursor_lock_sequence = dcn10_build_cursor_lock_sequence, .tg_lock = dcn20_tg_lock, .interdependent_update_lock = dcn32_interdependent_update_lock, .cursor_lock = dcn10_cursor_lock,
drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_init.c +1 -0
@@ -66,6 +66,7 @@ static const struct hw_sequencer_funcs dcn35_funcs = { .disable_plane = dcn35_disable_plane, .disable_pixel_data = dcn20_disable_pixel_data, .build_pipe_control_lock_sequence = dcn20_build_pipe_control_lock_sequence, + .build_cursor_lock_sequence = dcn10_build_cursor_lock_sequence, .tg_lock = dcn20_tg_lock, .interdependent_update_lock = dcn10_lock_all_pipes, .cursor_lock = dcn10_cursor_lock,
drivers/gpu/drm/amd/display/dc/hwss/dcn351/dcn351_init.c +1 -0
@@ -65,6 +65,7 @@ static const struct hw_sequencer_funcs dcn351_funcs = { .disable_plane = dcn35_disable_plane, .disable_pixel_data = dcn20_disable_pixel_data, .build_pipe_control_lock_sequence = dcn20_build_pipe_control_lock_sequence, + .build_cursor_lock_sequence = dcn10_build_cursor_lock_sequence, .tg_lock = dcn20_tg_lock, .interdependent_update_lock = dcn10_lock_all_pipes, .cursor_lock = dcn10_cursor_lock,
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_init.c +1 -0
@@ -42,6 +42,7 @@ static const struct hw_sequencer_funcs dcn401_funcs = { .disable_plane = dcn20_disable_plane, .disable_plane_sequence = dcn401_disable_plane_sequence, .build_pipe_control_lock_sequence = dcn20_build_pipe_control_lock_sequence, + .build_cursor_lock_sequence = dcn10_build_cursor_lock_sequence, .tg_lock = dcn20_tg_lock, .interdependent_update_lock = dcn401_interdependent_update_lock, .cursor_lock = dcn10_cursor_lock,
drivers/gpu/drm/amd/display/dc/hwss/dcn42/dcn42_init.c +1 -0
@@ -44,6 +44,7 @@ static const struct hw_sequencer_funcs dcn42_funcs = { .disable_audio_stream = dce110_disable_audio_stream, .disable_plane = dcn35_disable_plane, .build_pipe_control_lock_sequence = dcn20_build_pipe_control_lock_sequence, + .build_cursor_lock_sequence = dcn10_build_cursor_lock_sequence, .tg_lock = dcn20_tg_lock, .interdependent_update_lock = dcn401_interdependent_update_lock, .cursor_lock = dcn10_cursor_lock,
drivers/gpu/drm/amd/display/dc/hwss/dcn60/dcn60_init.c +1 -0
@@ -44,6 +44,7 @@ static const struct hw_sequencer_funcs dcn60_funcs = { .disable_plane = dcn20_disable_plane, .disable_plane_sequence = dcn401_disable_plane_sequence, .build_pipe_control_lock_sequence = dcn20_build_pipe_control_lock_sequence, + .build_cursor_lock_sequence = dcn10_build_cursor_lock_sequence, .tg_lock = dcn20_tg_lock, .interdependent_update_lock = dcn401_interdependent_update_lock, .cursor_lock = dcn10_cursor_lock,
drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h +50 -6
99 lines not on this page · raw message
Signature · 1 line
2.56.1
PATCH v2 3/30 drm/amd/display: clamp AUX reply length as unsigned
In reply to George ZhangFrom: Tom Chung <[email protected]>
[why]min_t(int, ret, payload->length) casts the uint32_t payload->length to int, so a length above INT_MAX would turn negative, win the comparison and reach memcpy() as a huge size_t. No caller can produce such a length today, so this is a defensive change.
[how]
Compare as uint32_t. ret is already clamped to [1, 16] above, so the result is unchanged for every real length.
Found by CodeQL (CERT-C INT31-C).
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.c +1 -1
@@ -929,7 +929,7 @@ int amdgpu_dm_process_dmub_aux_transfer_sync(* so only clamp to payload->length for regular transfers. */ if (!payload->write_status_update) - ret =min_t (int, ret, payload->length); + ret =min_t (uint32_t, ret, payload->length);memcpy (payload->data, p_notify->aux_reply.data, ret); }else {
Signature · 1 line
2.56.1
PATCH v2 4/30 drm/amd/display: keep the DPCD read result signed in the MST ISR
In reply to George ZhangFrom: Tom Chung <[email protected]>
[why]dm_handle_mst_sideband_msg_ready_event() stores the ssize_t return of drm_dp_dpcd_read() in a uint8_t, so -errno becomes 256 - errno. No errno happens to equal the expected 2 or 4 bytes, so the loop still breaks on error, but the type is wrong; the matching write result a few lines below is already ssize_t.
[how]
Declare dret as ssize_t so a negative return compares unequal with dpcd_bytes_to_read.
Found by CodeQL (CERT-C INT31-C).
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +1 -1
@@ -789,7 +789,7 @@ void dm_handle_mst_sideband_msg_ready_event( enum mst_msg_ready_type msg_rdy_type) {uint8_t esi[DP_PSR_ERROR_STATUS -DP_SINK_COUNT_ESI ] = {0 }; -uint8_t dret; +ssize_t dret;bool new_irq_handled = false;int dpcd_addr;uint8_t dpcd_bytes_to_read;
Signature · 1 line
2.56.1
PATCH v2 5/30 drm/amd/display: copy only the status byte on a DMUB AUX write status retry
In reply to George ZhangFrom: Tom Chung <[email protected]>
[why]
On an I2C-over-AUX write status retry, payload->length is 0 and payload->data still points at the caller's write buffer, which can be a single byte. amdgpu_dm_process_dmub_aux_transfer_sync() skips the payload->length clamp on this path, so a reply longer than one byte writes up to 15 bytes past that buffer. A sink that follows the DisplayPort specification replies with at most one byte, so this guards against a non-compliant reply.
[how]
Clamp the write status copy to one byte, and keep the payload->length clamp for regular transfers.
Found by CodeQL (CERT-C INT31-C).
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_dmub.c +4 -2
@@ -926,9 +926,11 @@ int amdgpu_dm_process_dmub_aux_transfer_sync(* During a write-status-update retry the caller zeroes * payload->length while still expecting the partial-write * status byte in payload->data (see dce_aux_transfer_with_retries), -* so only clamp to payload->length for regular transfers. +* so copy only that byte there. */ -if (!payload->write_status_update) +if (payload->write_status_update) + ret =min_t (uint32_t, ret,1 ); +else ret =min_t (uint32_t, ret, payload->length);memcpy (payload->data, p_notify->aux_reply.data, ret);
Signature · 1 line
2.56.1
PATCH v2 6/30 drm/amd/display: test the DMUB AUX write status reply copy
In reply to George ZhangFrom: Tom Chung <[email protected]>
[why]
No test covered the write status retry path fixed in the previous commit, where a 16 byte reply overwrote the caller's buffer.
[how]
Add a KUnit case that answers a write status retry with a 16 byte reply and checks that the call returns 1 and copies only the status byte.
--- .../amdgpu_dm/tests/amdgpu_dm_dmub_test.c | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_dmub_test.c +81 -0
@@ -1335,6 +1335,86 @@ static void dm_test_process_dmub_aux_transfer_sync_copies_data(struct kunit *tesKUNIT_EXPECT_EQ (test, data[2 ],0x33 ); } +/** +* dm_test_process_dmub_aux_transfer_sync_write_status - Test AUX write status reply +* @test: The KUnit test context +* +* A write-status-update retry still points payload->data at the caller's write +* buffer, with payload->length zeroed. Only the partial-write status byte may +* be copied there, however long a reply the sink sends. +*/ +static void dm_test_process_dmub_aux_transfer_sync_write_status (struct kunit *test) +{ +struct amdgpu_device *adev; +struct dc_context *ctx; +struct dc_context *dc_ctx; +struct dc *dc; +struct dc_link *link; +struct ddc_service *ddc; +struct aux_payload *payload; +struct dmub_notification *notify; +enum aux_return_code_type result =AUX_RET_ERROR_UNKNOWN ; +u8 data[16 ] = {0 }; +u8 reply =0 ; +int ret; +int i; + + adev =kunit_kzalloc (test,sizeof (*adev),GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test, adev); + + ctx =kunit_kzalloc (test,sizeof (*ctx),GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test, ctx); + + dc_ctx =kunit_kzalloc (test,sizeof (*dc_ctx),GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test, dc_ctx); + + dc =kunit_kzalloc (test,sizeof (*dc),GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test, dc); + + link =kunit_kzalloc (test,sizeof (*link),GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test, link); + + ddc =kunit_kzalloc (test,sizeof (*ddc),GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test, ddc); + + payload =kunit_kzalloc (test,sizeof (*payload),GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test, payload); + + notify =kunit_kzalloc (test,sizeof (*notify),GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test, notify); + + link->ddc = ddc; + dc->ctx = dc_ctx; + dc->link_count =1 ; + dc->links[0 ] = link; + dc_ctx->dc = dc; + dc_ctx->driver_context = adev; + dc_ctx->dmub_srv =NULL ; + ctx->dc = dc; + ctx->driver_context = adev; +spin_lock_init (&adev->dm.dmub_lock); + adev->dm.dmub_notify = notify; +mutex_init (&adev->dm.dpia_aux_lock); +init_completion (&adev->dm.dmub_aux_transfer_done); +complete (&adev->dm.dmub_aux_transfer_done); + payload->data = data; + payload->reply = &reply; + payload->length =0 ; + payload->i2c_over_aux = true; + payload->write_status_update = true; + notify->result =AUX_RET_SUCCESS ; + notify->aux_reply.length =sizeof (notify->aux_reply.data); +memset (notify->aux_reply.data,0x5A ,sizeof (notify->aux_reply.data)); + + ret =amdgpu_dm_process_dmub_aux_transfer_sync (ctx,0 , payload, &result); + +KUNIT_EXPECT_EQ (test, ret,1 ); +KUNIT_EXPECT_EQ (test, result,AUX_RET_SUCCESS ); +KUNIT_EXPECT_EQ (test, data[0 ],0x5A ); +for (i =1 ; i <ARRAY_SIZE (data); i++) +KUNIT_EXPECT_EQ (test, data[i],0 ); +} +/** * dm_test_process_dmub_aux_transfer_sync_zero_length - Test AUX reply with no data * @test: The KUnit test context
@@ -2253,6 +2333,7 @@ static struct kunit_case amdgpu_dm_dmub_tests[] = {KUNIT_CASE (dm_test_process_dmub_aux_transfer_sync_engine_acquire),KUNIT_CASE (dm_test_process_dmub_aux_transfer_sync_protocol_error),KUNIT_CASE (dm_test_process_dmub_aux_transfer_sync_copies_data), +KUNIT_CASE (dm_test_process_dmub_aux_transfer_sync_write_status),KUNIT_CASE (dm_test_process_dmub_aux_transfer_sync_zero_length), KUNIT_CASE_SLOW(dm_test_process_dmub_aux_transfer_sync_timeout),/* amdgpu_dm_process_dmub_set_config_sync() */
Signature · 1 line
2.56.1
PATCH v2 7/30 drm/amd/display: Account for downspread and DFS in clock validation
In reply to George ZhangFrom: Ilya Bakoulin <[email protected]>
[Why]
ODM selection can choose a combine factor that fails the final DISPCLK check when downspread raises the clock requirement above the limit. Clamping ramp margin to a cap between DFS steps can also round the request up past the cap even when the mandatory clock fits.
[How]
Use the highest supported DFS step for the DCN6 ramp-margin clamp and account for downspread when passing that ceiling to ODM selection. Preserve the final check for mandatory clock requirements. Derive the DISPCLK ceiling from the highest DFS step at or below the clock table's maximum DISPCLK, floored to whole kHz.
Account for downspread in the DCN5 DISPCLK, DPPCLK, and DSCCLK limits.
--- .../dml2_0/dml21/src/dml2_cga/dml2_cga_dcn6.c | 43 +++++++++++++++---- .../dml2_core_dcn5_funcs_mode_support.c | 11 +++-- .../dml2_core_dcn6_funcs_mode_support.c | 5 +-- .../src/inc/dml2_internal_shared_types.h | 1 + 4 files changed, 46 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_cga/dml2_cga_dcn6.c +35 -8
@@ -14,6 +14,29 @@ static double cga_dcn6_add_overhead_percent(double clk, double overhead_percent)return clk * (1 + overhead_percent /100.0 ); } +static double cga_dcn6_scaled_vco_mhz (const struct dml2_clock_granularity_adjuster *adjuster) +{ +return math_floor2 (adjuster->dispclk_dppclk_vco_speed_mhz,CLOCK_UNIT_GRANULARITY ) * +DFS_DIVIDER_RANGE_SCALE_FACTOR ; +} + +static unsigned int cga_dcn6_max_dfs_dispclk_khz (const struct dml2_clock_granularity_adjuster *adjuster, +unsigned int max_dispclk_khz) +{ +unsigned int scaled_vco_khz; +unsigned int divider; + +if (adjuster->dispclk_dppclk_vco_speed_mhz ==0.0 ) +return max_dispclk_khz; + + scaled_vco_khz = (unsigned int )(cga_dcn6_scaled_vco_mhz (adjuster) *1000.0 +0.5 ); +/* The reported DFS clock is floored to kHz. Find the smallest divider +* for which the exact clock is strictly below max_dispclk_khz + 1. +*/ + divider = scaled_vco_khz / (max_dispclk_khz +1 ) +1 ; +return scaled_vco_khz / divider; +} +static double cga_dcn6_calculate_refclk_mhz (const struct dml2_clock_granularity_adjuster *adjuster,const double *clks_mhz,unsigned int count) {
@@ -40,11 +63,11 @@ static double cga_dcn6_calculate_actual_dispclk_mhz(const struct dml2_clock_gran dispclk_with_downspread_mhz =cga_dcn6_add_overhead_percent (dispclk_mhz, adjuster->dcn_downspread_percent); dispclk_with_ramp_margin_mhz =cga_dcn6_add_overhead_percent ( dispclk_with_downspread_mhz, adjuster->dispclk_ramp_margin_percent); -if (dispclk_with_downspread_mhz <= adjuster->max_dispclk_mhz && - dispclk_with_ramp_margin_mhz > adjuster->max_dispclk_mhz) -/* when dispclk with ramp margin is slightly over max, clamp the ramp margin to the max dispclk */ -return math_floor2 (adjuster->max_dispclk_mhz,CLOCK_UNIT_GRANULARITY ); -else if (dispclk_with_downspread_mhz > adjuster->max_dispclk_mhz) +if (dispclk_with_downspread_mhz <= adjuster->max_adjusted_dispclk_mhz && + dispclk_with_ramp_margin_mhz > adjuster->max_adjusted_dispclk_mhz) +/* Clamp optional ramp margin to the highest reachable DFS clock. */ +return adjuster->max_adjusted_dispclk_mhz; +else if (dispclk_with_downspread_mhz > adjuster->max_adjusted_dispclk_mhz)return math_floor2 (dispclk_with_downspread_mhz,CLOCK_UNIT_GRANULARITY );else return math_floor2 (dispclk_with_ramp_margin_mhz,CLOCK_UNIT_GRANULARITY );
@@ -63,8 +86,7 @@ static double cga_dcn6_adjust_to_dfs_clock_value_mhz(const struct dml2_clock_gra/* There are cases when a clock is not needed */ return 0 ; - vco_speed_scaled_mhz =math_floor2 (adjuster->dispclk_dppclk_vco_speed_mhz,0.001 ); - vco_speed_scaled_mhz *=DFS_DIVIDER_RANGE_SCALE_FACTOR ; + vco_speed_scaled_mhz =cga_dcn6_scaled_vco_mhz (adjuster); vco_divider = vco_speed_scaled_mhz / clk_mhz; vco_divider =math_floor (vco_divider); adjusted_clock_mhz = vco_speed_scaled_mhz / vco_divider;
@@ -137,11 +159,16 @@ static double cga_dcn6_adjust_dcfclk_deepsleep_mhz(const struct dml2_clock_granustatic void cga_dcn6_initialize (const struct dml2_cga_initialize_in_out *in_out) { +const struct dml2_clk_table *dispclk = &in_out->soc_bb->clk_table.dispclk; + in_out->adjuster->dcn_downspread_percent = in_out->soc_bb->dcn_downspread_percent; in_out->adjuster->dispclk_dppclk_vco_speed_mhz = in_out->soc_bb->dispclk_dppclk_vco_speed_mhz; in_out->adjuster->dispclk_ramp_margin_percent = in_out->ip->dispclk_ramp_margin_percent; + in_out->adjuster->max_adjusted_dispclk_mhz = +cga_dcn6_max_dfs_dispclk_khz (in_out->adjuster, + dispclk->clk_values_khz[dispclk->num_clk_values -1 ]) /1000.0 ; in_out->adjuster->max_dispclk_mhz = - in_out->soc_bb->clk_table.dispclk.clk_values_khz[in_out->soc_bb->clk_table.dispclk.num_clk_values -1 ] /1000.0 ; + in_out->adjuster->max_adjusted_dispclk_mhz / (1.0 + in_out->soc_bb->dcn_downspread_percent /100.0 ); }void cga_dcn6_create (struct dml2_clock_granularity_adjuster *adjuster)
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn5_funcs_mode_support.c +8 -3
@@ -2485,6 +2485,11 @@ static void dcn5_ms_get_stream_support_info(const struct dml2_display_cfg *displDML_LOG_VERBOSE ("DML::%s: vblank_reserved_time_us = %u\n" , __func__, out->vblank_reserved_time_us); } +static double dcn5_ms_subtract_dcn_overhead_percent (double clk,const struct dml2_utm_soc_bb *utm_soc_bb) +{ +return clk / (1.0 + utm_soc_bb->dcn_downspread_percent /100.0 ); +} +static void dcn5_ms_setup_mode_lib_constants (struct dml2_core_calcs_mode_support_ex *in_out_params) {struct dml2_core_internal_display_mode_lib *mode_lib = in_out_params->mode_lib;
@@ -2503,9 +2508,9 @@ static void dcn5_ms_setup_mode_lib_constants(struct dml2_core_calcs_mode_support sizeof(struct dml2_core_internal_mode_support)); mode_lib->ms.use_legacy_dsc_delay_formula = mode_lib->ip.use_legacy_dsc_delay_formula; mode_lib->ms.num_active_planes = display_cfg->num_planes; - mode_lib->ms.max_dispclk_freq_mhz = (double ) utm_soc_bb->max_dispclk_khz /1000 ; - mode_lib->ms.max_dscclk_freq_mhz = (double ) utm_soc_bb->max_dscclk_khz /1000 ; - mode_lib->ms.max_dppclk_freq_mhz = (double ) utm_soc_bb->max_dppclk_khz /1000 ; + mode_lib->ms.max_dispclk_freq_mhz =dcn5_ms_subtract_dcn_overhead_percent ((double ) utm_soc_bb->max_dispclk_khz /1000 , utm_soc_bb); + mode_lib->ms.max_dscclk_freq_mhz =dcn5_ms_subtract_dcn_overhead_percent ((double ) utm_soc_bb->max_dscclk_khz /1000 , utm_soc_bb); + mode_lib->ms.max_dppclk_freq_mhz =dcn5_ms_subtract_dcn_overhead_percent ((double ) utm_soc_bb->max_dppclk_khz /1000 , utm_soc_bb);DML_LOG_VERBOSE ("DML::%s: --- START --- \n" , __func__); DML_LOG_VERBOSE("DML::%s: num_active_planes = %u\n", __func__,
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_funcs_mode_support.c +2 -3
@@ -860,7 +860,6 @@ void dcn6_ms_calculate_odm_mode( {const struct dml2_display_cfg *display_cfg = ctx->display_cfg;const struct dml2_core_ip_params *ip = ctx->ip; -const struct dml2_utm_soc_bb *soc_bb = ctx->soc_bb;struct dml2_core_internal_mode_support *inputs = states;struct dml2_core_internal_mode_support *outputs = states;const struct dml2_stream_parameters *stream;
@@ -880,7 +879,7 @@ void dcn6_ms_calculate_odm_mode( stream->output.output_format, stream->output.output_encoder, stream->overrides.odm_mode, - ((double ) soc_bb->max_dispclk_khz /1000 ), + ctx->clock_adjuster->max_dispclk_mhz, inputs->RequiresDSC[k],// DSCEnable totalNumberOfActiveDPP, ip->max_num_dpp,
@@ -1176,7 +1175,7 @@ bool dcn6_ms_check_dispclk_and_dppclk_support(struct dml2_core_internal_mode_support *outputs = states;DML_LOG_FUNC_ENTER (); - outputs->support.DISPCLK_DPPCLK_Support = (inputs->RequiredDISPCLK <= ((double ) soc_bb->max_dispclk_khz /1000 )) + outputs->support.DISPCLK_DPPCLK_Support = (inputs->RequiredDISPCLK <= ctx->clock_adjuster->max_adjusted_dispclk_mhz) && (inputs->GlobalDPPCLK <= ((double ) soc_bb->max_dppclk_khz /1000 ));DML_LOG_DEBUG_BOOL (outputs->support.DISPCLK_DPPCLK_Support);
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/inc/dml2_internal_shared_types.h +1 -0
@@ -163,6 +163,7 @@ struct dml2_clock_granularity_adjuster {double dispclk_dppclk_vco_speed_mhz;double dispclk_ramp_margin_percent;double max_dispclk_mhz; +double max_adjusted_dispclk_mhz;void (*initialize)(const struct dml2_cga_initialize_in_out *in_out);double (*adjust_dispclk_mhz)(const struct dml2_clock_granularity_adjuster *adjuster,double dispclk_mhz); void (*adjust_dppclks_mhz)(const struct dml2_clock_granularity_adjuster *adjuster, unsigned int count,
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH v2 07/30] drm/amd/display: Account for downspread and DFS in clock validation
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] drm/amd/display: precision mismatch in cga_dcn6_initialize() DFS ceiling - [Low] drm/amd/display…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] drm/amd/display: precision mismatch in cga_dcn6_initialize() DFS ceiling
- [Low] drm/amd/display: missing Fixes: trailer for commit 7f7d7ea1fa51 --
commit 89c9a06cc3d1454a268be85d4e1c884dc45f81fd
Author: Ilya Bakoulin <[email protected]>
Quoted 15 lines
drm/amd/display: Account for downspread and DFS in clock validation
[Why]
ODM selection can choose a combine factor that fails the final DISPCLK check when downspread raises the clock requirement above the limit. Clamping ramp margin to a cap between DFS steps can also round the request up past the cap even when the mandatory clock fits.[How]
Use the highest supported DFS step for the DCN6 ramp-margin clamp and account for downspread when passing that ceiling to ODM selection. Preserve the final check for mandatory clock requirements. Derive the DISPCLK ceiling from the highest DFS step at or below the clock table's maximum DISPCLK, floored to whole kHz.
Quoted 5 lines
Account for downspread in the DCN5 DISPCLK, DPPCLK, and DSCCLK limits.
Cc Wenjing Liu <[email protected]>Signed-off-by Ilya Bakoulin <[email protected]>Signed-off-by George Zhang <[email protected]>
[Severity: Low]
This fixes clock validation in DCN5 and DCN6. Should it include a Fixes:
tag for 7f7d7ea1fa51 ("drm/amd/display: Add new sources for DCN6")?
Quoted 4 lines
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_cga/dml2_cga_dcn6.c +0
-0
[ ... ]
Quoted 33 lines
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_cga/dml2_cga_dcn6.c +8
-7@@ -40,11 +63,11 @@ static double cga_dcn6_calculate_actual_dispclk_mhz(const struct dml2_clock_gran dispclk_with_downspread_mhz =cga_dcn6_add_overhead_percent (dispclk_mhz, adjuster->dcn_downspread_percent); dispclk_with_ramp_margin_mhz =cga_dcn6_add_overhead_percent ( dispclk_with_downspread_mhz, adjuster->dispclk_ramp_margin_percent); -if (dispclk_with_downspread_mhz <= adjuster->max_dispclk_mhz && - dispclk_with_ramp_margin_mhz > adjuster->max_dispclk_mhz) -/* when dispclk with ramp margin is slightly over max, clamp the ramp margin to the max dispclk */ -return math_floor2 (adjuster->max_dispclk_mhz,CLOCK_UNIT_GRANULARITY ); -else if (dispclk_with_downspread_mhz > adjuster->max_dispclk_mhz) +if (dispclk_with_downspread_mhz <= adjuster->max_adjusted_dispclk_mhz && + dispclk_with_ramp_margin_mhz > adjuster->max_adjusted_dispclk_mhz) +/* Clamp optional ramp margin to the highest reachable DFS clock. */ +return adjuster->max_adjusted_dispclk_mhz; +else if (dispclk_with_downspread_mhz > adjuster->max_adjusted_dispclk_mhz)return math_floor2 (dispclk_with_downspread_mhz,CLOCK_UNIT_GRANULARITY );else return math_floor2 (dispclk_with_ramp_margin_mhz,CLOCK_UNIT_GRANULARITY );@@ -63,8 +86,7 @@ static double cga_dcn6_adjust_to_dfs_clock_value_mhz(const struct dml2_clock_gra/* There are cases when a clock is not needed */ return 0 ; - vco_speed_scaled_mhz =math_floor2 (adjuster->dispclk_dppclk_vco_speed_mhz,0.001 ); - vco_speed_scaled_mhz *=DFS_DIVIDER_RANGE_SCALE_FACTOR ; + vco_speed_scaled_mhz =cga_dcn6_scaled_vco_mhz (adjuster); vco_divider = vco_speed_scaled_mhz / clk_mhz; vco_divider =math_floor (vco_divider); adjusted_clock_mhz = vco_speed_scaled_mhz / vco_divider;@@ -137,11 +159,16 @@ static double cga_dcn6_adjust_dcfclk_deepsleep_mhz(const struct dml2_clock_granustatic void cga_dcn6_initialize (const struct dml2_cga_initialize_in_out *in_out) { +const struct dml2_clk_table *dispclk = &in_out->soc_bb->clk_table.dispclk; +
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_cga/dml2_cga_dcn6.c static double cga_dcn6_adjust_dcfclk_deepsleep_mhz(const struct dml2_clock_granu · line 172
Quoted 10 lines
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_cga/dml2_cga_dcn6.c +4
-1in_out->adjuster->dcn_downspread_percent = in_out->soc_bb->dcn_downspread_percent; in_out->adjuster->dispclk_dppclk_vco_speed_mhz = in_out->soc_bb->dispclk_dppclk_vco_speed_mhz; in_out->adjuster->dispclk_ramp_margin_percent = in_out->ip->dispclk_ramp_margin_percent; + in_out->adjuster->max_adjusted_dispclk_mhz = +cga_dcn6_max_dfs_dispclk_khz (in_out->adjuster, + dispclk->clk_values_khz[dispclk->num_clk_values -1 ]) /1000.0 ; in_out->adjuster->max_dispclk_mhz = - in_out->soc_bb->clk_table.dispclk.clk_values_khz[in_out->soc_bb->clk_table.dispclk.num_clk_values -1 ] /1000.0 ; + in_out->adjuster->max_adjusted_dispclk_mhz / (1.0 + in_out->soc_bb->dcn_downspread_percent /100.0 ); }
[Severity: Medium]
Can computing max_adjusted_dispclk_mhz via / 1000.0 cause dcn6_ms_check_dispclk_and_dppclk_support() to reject valid modes at the top DFS step?
cga_dcn6_adjust_to_dfs_clock_value_mhz() quantizes RequiredDISPCLK with math_floor2(..., CLOCK_UNIT_GRANULARITY), which multiplies the integer kHz value K by 0.001 (((int)(arg / 0.001)) * 0.001). In IEEE 754 binary64, 0.001 is strictly greater than 1.0 / 1000.0, so for many integer kHz values (e.g. K = 1309090 kHz at 3600 MHz VCO / divider 11), K * 0.001 is 1 ULP larger than K / 1000.0. Moreover, when scaled_vco_khz is an exact multiple of the divider and K / 1000.0 rounds up, passing a clamped clk_mhz = adjuster->max_adjusted_dispclk_mhz into cga_dcn6_adjust_to_dfs_clock_value_mhz() yields vco_speed_scaled_mhz / clk_mhz < divider, so math_floor(vco_divider) steps down to divider - 1 and bumps RequiredDISPCLK to the next higher DFS step. In both cases, inputs->RequiredDISPCLK <= ctx->clock_adjuster->max_adjusted_dispclk_mhz fails.
Multiplying the kHz value by CLOCK_UNIT_GRANULARITY (or passing the unfloored DFS clock for the top divider through cga_dcn6_adjust_to_dfs_clock_value_mhz()) would keep both sides on the same floating-point representation.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
PATCH v2 8/30 drm/amd/display: Read max LSDMA BW from DMU
In reply to George ZhangFrom: Ivan Lipski <[email protected]>
[Why&How]
We parse LSDMA bandwidth info from DMU, so we should set it to the SOC BB.
--- .../soc_and_ip_translator/dcn60/dcn60_soc_and_ip_translator.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/soc_and_ip_translator/dcn60/dcn60_soc_and_ip_translator.c +2 -0
@@ -78,6 +78,8 @@ static void dcn60_update_soc_bb_with_values_from_dmub(struct dml2_soc_bb *soc_bbif (dmub_bb_params->alternate_dram_carveout_size_mb >0 ) soc_bb->power_management_parameters.alternate_dram_carveout_size_mb = dmub_bb_params->alternate_dram_carveout_size_mb; +if (dmub_bb_params->max_lsdma_bandwidth_kbps >0 ) + soc_bb->max_lsdma_bandwidth_kbps = dmub_bb_params->max_lsdma_bandwidth_kbps;/* populate alt-channel info */ for (i =0 ; i <2 ; i++) {
Signature · 1 line
2.56.1
PATCH v2 9/30 drm/amd/display: Precompute EASF lookup thresholds
In reply to George ZhangFrom: deguo <[email protected]>
[WHY]
EASF register lookups and filter selection repeatedly convert constant scale-ratio thresholds to 31.32 fixed-point values at runtime.
[HOW]
Precompute the thresholds at compile time with the same rounding as spl_fixpt_from_fraction. Use them for register lookups and 3/4/6-tap coefficient selection in both S1.10 and S1.12 formats. Mark the lookup tables const. Name the macro parameters num and denom.
--- .../display/dc/sspl/dc_spl_scl_easf_filters.c | 478 +++++++++--------- .../display/dc/sspl/dc_spl_scl_easf_filters.h | 3 +- 2 files changed, 241 insertions(+), 240 deletions(-)
drivers/gpu/drm/amd/display/dc/sspl/dc_spl_scl_easf_filters.c +240 -238
@@ -2000,213 +2000,217 @@ static const uint16_t easf_filter_6tap_64p_ratio_1_00_s1_12[198] = { 0x0064, 0x3dd4, 0x09c8, 0x09c8, 0x3dd4, 0x0064, }; -static struct scale_ratio_to_reg_value_lookup easf_v_bf3_mode_lookup[] = { - {3 ,10 ,0x0000 }, - {4 ,10 ,0x0000 }, - {5 ,10 ,0x0000 }, - {6 ,10 ,0x0000 }, - {7 ,10 ,0x0000 }, - {8 ,10 ,0x0000 }, - {9 ,10 ,0x0000 }, - {1 ,1 ,0x0000 }, - {-1 ,-1 ,0x0002 }, -}; - -static struct scale_ratio_to_reg_value_lookup easf_h_bf3_mode_lookup[] = { - {3 ,10 ,0x0000 }, - {4 ,10 ,0x0000 }, - {5 ,10 ,0x0000 }, - {6 ,10 ,0x0000 }, - {7 ,10 ,0x0000 }, - {8 ,10 ,0x0000 }, - {9 ,10 ,0x0000 }, - {1 ,1 ,0x0000 }, - {-1 ,-1 ,0x0002 }, -}; - -static struct scale_ratio_to_reg_value_lookup easf_reducer_gain6_6tap_lookup[] = { - {3 ,10 ,0x4100 }, - {4 ,10 ,0x4100 }, - {5 ,10 ,0x4100 }, - {6 ,10 ,0x4100 }, - {7 ,10 ,0x4100 }, - {8 ,10 ,0x4100 }, - {9 ,10 ,0x4100 }, - {1 ,1 ,0x4100 }, - {-1 ,-1 ,0x4100 }, -}; - -static struct scale_ratio_to_reg_value_lookup easf_reducer_gain4_6tap_lookup[] = { - {3 ,10 ,0x4000 }, - {4 ,10 ,0x4000 }, - {5 ,10 ,0x4000 }, - {6 ,10 ,0x4000 }, - {7 ,10 ,0x4000 }, - {8 ,10 ,0x4000 }, - {9 ,10 ,0x4000 }, - {1 ,1 ,0x4000 }, - {-1 ,-1 ,0x4000 }, -}; - -static struct scale_ratio_to_reg_value_lookup easf_gain_ring6_6tap_lookup[] = { - {3 ,10 ,0x0000 }, - {4 ,10 ,0x251F }, - {5 ,10 ,0x291F }, - {6 ,10 ,0xA51F }, - {7 ,10 ,0xA51F }, - {8 ,10 ,0xAA66 }, - {9 ,10 ,0xA51F }, - {1 ,1 ,0xA640 }, - {-1 ,-1 ,0xA640 }, -}; - -static struct scale_ratio_to_reg_value_lookup easf_gain_ring4_6tap_lookup[] = { - {3 ,10 ,0x0000 }, - {4 ,10 ,0x9600 }, - {5 ,10 ,0xA460 }, - {6 ,10 ,0xA8E0 }, - {7 ,10 ,0xAC00 }, - {8 ,10 ,0xAD20 }, - {9 ,10 ,0xAFC0 }, - {1 ,1 ,0xB058 }, - {-1 ,-1 ,0xB058 }, -}; - -static struct scale_ratio_to_reg_value_lookup easf_reducer_gain6_4tap_lookup[] = { - {3 ,10 ,0x4100 }, - {4 ,10 ,0x4100 }, - {5 ,10 ,0x4100 }, - {6 ,10 ,0x4100 }, - {7 ,10 ,0x4100 }, - {8 ,10 ,0x4100 }, - {9 ,10 ,0x4100 }, - {1 ,1 ,0x4100 }, - {-1 ,-1 ,0x4100 }, -}; - -static struct scale_ratio_to_reg_value_lookup easf_reducer_gain4_4tap_lookup[] = { - {3 ,10 ,0x4000 }, - {4 ,10 ,0x4000 }, - {5 ,10 ,0x4000 }, - {6 ,10 ,0x4000 }, - {7 ,10 ,0x4000 }, - {8 ,10 ,0x4000 }, - {9 ,10 ,0x4000 }, - {1 ,1 ,0x4000 }, - {-1 ,-1 ,0x4000 }, -}; - -static struct scale_ratio_to_reg_value_lookup easf_gain_ring6_4tap_lookup[] = { - {3 ,10 ,0x0000 }, - {4 ,10 ,0x0000 }, - {5 ,10 ,0x0000 }, - {6 ,10 ,0x0000 }, - {7 ,10 ,0x0000 }, - {8 ,10 ,0x0000 }, - {9 ,10 ,0x0000 }, - {1 ,1 ,0x0000 }, - {-1 ,-1 ,0x0000 }, -}; - -static struct scale_ratio_to_reg_value_lookup easf_gain_ring4_4tap_lookup[] = { - {3 ,10 ,0x0000 }, - {4 ,10 ,0x0000 }, - {5 ,10 ,0x0000 }, - {6 ,10 ,0x9900 }, - {7 ,10 ,0xA100 }, - {8 ,10 ,0xA8C0 }, - {9 ,10 ,0xAB20 }, - {1 ,1 ,0xAC00 }, - {-1 ,-1 ,0xAC00 }, -}; - -static struct scale_ratio_to_reg_value_lookup easf_3tap_dntilt_uptilt_offset_lookup[] = { - {3 ,10 ,0x0000 }, - {4 ,10 ,0x0000 }, - {5 ,10 ,0x0000 }, - {6 ,10 ,0x0000 }, - {7 ,10 ,0x0000 }, - {8 ,10 ,0x4100 }, - {9 ,10 ,0x9F00 }, - {1 ,1 ,0xA4C0 }, - {-1 ,-1 ,0xA8D8 }, -}; - -static struct scale_ratio_to_reg_value_lookup easf_3tap_uptilt_maxval_lookup[] = { - {3 ,10 ,0x0000 }, - {4 ,10 ,0x0000 }, - {5 ,10 ,0x0000 }, - {6 ,10 ,0x0000 }, - {7 ,10 ,0x0000 }, - {8 ,10 ,0x4000 }, - {9 ,10 ,0x24FE }, - {1 ,1 ,0x2D64 }, - {-1 ,-1 ,0x3ADB }, -}; - -static struct scale_ratio_to_reg_value_lookup easf_3tap_dntilt_slope_lookup[] = { - {3 ,10 ,0x3800 }, - {4 ,10 ,0x3800 }, - {5 ,10 ,0x3800 }, - {6 ,10 ,0x3800 }, - {7 ,10 ,0x3800 }, - {8 ,10 ,0x3886 }, - {9 ,10 ,0x3940 }, - {1 ,1 ,0x3A4E }, - {-1 ,-1 ,0x3B66 }, -}; - -static struct scale_ratio_to_reg_value_lookup easf_3tap_uptilt1_slope_lookup[] = { - {3 ,10 ,0x3800 }, - {4 ,10 ,0x3800 }, - {5 ,10 ,0x3800 }, - {6 ,10 ,0x3800 }, - {7 ,10 ,0x3800 }, - {8 ,10 ,0x36F4 }, - {9 ,10 ,0x359C }, - {1 ,1 ,0x3360 }, - {-1 ,-1 ,0x2F20 }, -}; - -static struct scale_ratio_to_reg_value_lookup easf_3tap_uptilt2_slope_lookup[] = { - {3 ,10 ,0x0000 }, - {4 ,10 ,0x0000 }, - {5 ,10 ,0x0000 }, - {6 ,10 ,0x0000 }, - {7 ,10 ,0x0000 }, - {8 ,10 ,0x0000 }, - {9 ,10 ,0x359C }, - {1 ,1 ,0x31F0 }, - {-1 ,-1 ,0x1F00 }, -}; - -static struct scale_ratio_to_reg_value_lookup easf_3tap_uptilt2_offset_lookup[] = { - {3 ,10 ,0x0000 }, - {4 ,10 ,0x0000 }, - {5 ,10 ,0x0000 }, - {6 ,10 ,0x0000 }, - {7 ,10 ,0x0000 }, - {8 ,10 ,0x0000 }, - {9 ,10 ,0x9F00 }, - {1 ,1 ,0xA400 }, - {-1 ,-1 ,0x9E00 }, +#define EASF_SCALE_RATIO (num, denom) \ + ((((long long)(num) << FIXED31_32_BITS_PER_FRACTIONAL_PART) + \ + (denom) / 2) / (denom)) + +static const struct scale_ratio_to_reg_value_lookup easf_v_bf3_mode_lookup[] = { + {EASF_SCALE_RATIO (3 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (4 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (5 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (6 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (7 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (8 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (9 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (1 ,1 ),0x0000 }, + {-1 ,0x0002 }, +}; + +static const struct scale_ratio_to_reg_value_lookup easf_h_bf3_mode_lookup[] = { + {EASF_SCALE_RATIO (3 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (4 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (5 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (6 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (7 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (8 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (9 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (1 ,1 ),0x0000 }, + {-1 ,0x0002 }, +}; + +static const struct scale_ratio_to_reg_value_lookup easf_reducer_gain6_6tap_lookup[] = { + {EASF_SCALE_RATIO (3 ,10 ),0x4100 }, + {EASF_SCALE_RATIO (4 ,10 ),0x4100 }, + {EASF_SCALE_RATIO (5 ,10 ),0x4100 }, + {EASF_SCALE_RATIO (6 ,10 ),0x4100 }, + {EASF_SCALE_RATIO (7 ,10 ),0x4100 }, + {EASF_SCALE_RATIO (8 ,10 ),0x4100 }, + {EASF_SCALE_RATIO (9 ,10 ),0x4100 }, + {EASF_SCALE_RATIO (1 ,1 ),0x4100 }, + {-1 ,0x4100 }, +}; + +static const struct scale_ratio_to_reg_value_lookup easf_reducer_gain4_6tap_lookup[] = { + {EASF_SCALE_RATIO (3 ,10 ),0x4000 }, + {EASF_SCALE_RATIO (4 ,10 ),0x4000 }, + {EASF_SCALE_RATIO (5 ,10 ),0x4000 }, + {EASF_SCALE_RATIO (6 ,10 ),0x4000 }, + {EASF_SCALE_RATIO (7 ,10 ),0x4000 }, + {EASF_SCALE_RATIO (8 ,10 ),0x4000 }, + {EASF_SCALE_RATIO (9 ,10 ),0x4000 }, + {EASF_SCALE_RATIO (1 ,1 ),0x4000 }, + {-1 ,0x4000 }, +}; + +static const struct scale_ratio_to_reg_value_lookup easf_gain_ring6_6tap_lookup[] = { + {EASF_SCALE_RATIO (3 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (4 ,10 ),0x251F }, + {EASF_SCALE_RATIO (5 ,10 ),0x291F }, + {EASF_SCALE_RATIO (6 ,10 ),0xA51F }, + {EASF_SCALE_RATIO (7 ,10 ),0xA51F }, + {EASF_SCALE_RATIO (8 ,10 ),0xAA66 }, + {EASF_SCALE_RATIO (9 ,10 ),0xA51F }, + {EASF_SCALE_RATIO (1 ,1 ),0xA640 }, + {-1 ,0xA640 }, +}; + +static const struct scale_ratio_to_reg_value_lookup easf_gain_ring4_6tap_lookup[] = { + {EASF_SCALE_RATIO (3 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (4 ,10 ),0x9600 }, + {EASF_SCALE_RATIO (5 ,10 ),0xA460 }, + {EASF_SCALE_RATIO (6 ,10 ),0xA8E0 }, + {EASF_SCALE_RATIO (7 ,10 ),0xAC00 }, + {EASF_SCALE_RATIO (8 ,10 ),0xAD20 }, + {EASF_SCALE_RATIO (9 ,10 ),0xAFC0 }, + {EASF_SCALE_RATIO (1 ,1 ),0xB058 }, + {-1 ,0xB058 }, +}; + +static const struct scale_ratio_to_reg_value_lookup easf_reducer_gain6_4tap_lookup[] = { + {EASF_SCALE_RATIO (3 ,10 ),0x4100 }, + {EASF_SCALE_RATIO (4 ,10 ),0x4100 }, + {EASF_SCALE_RATIO (5 ,10 ),0x4100 }, + {EASF_SCALE_RATIO (6 ,10 ),0x4100 }, + {EASF_SCALE_RATIO (7 ,10 ),0x4100 }, + {EASF_SCALE_RATIO (8 ,10 ),0x4100 }, + {EASF_SCALE_RATIO (9 ,10 ),0x4100 }, + {EASF_SCALE_RATIO (1 ,1 ),0x4100 }, + {-1 ,0x4100 }, +}; + +static const struct scale_ratio_to_reg_value_lookup easf_reducer_gain4_4tap_lookup[] = { + {EASF_SCALE_RATIO (3 ,10 ),0x4000 }, + {EASF_SCALE_RATIO (4 ,10 ),0x4000 }, + {EASF_SCALE_RATIO (5 ,10 ),0x4000 }, + {EASF_SCALE_RATIO (6 ,10 ),0x4000 }, + {EASF_SCALE_RATIO (7 ,10 ),0x4000 }, + {EASF_SCALE_RATIO (8 ,10 ),0x4000 }, + {EASF_SCALE_RATIO (9 ,10 ),0x4000 }, + {EASF_SCALE_RATIO (1 ,1 ),0x4000 }, + {-1 ,0x4000 }, +}; + +static const struct scale_ratio_to_reg_value_lookup easf_gain_ring6_4tap_lookup[] = { + {EASF_SCALE_RATIO (3 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (4 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (5 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (6 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (7 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (8 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (9 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (1 ,1 ),0x0000 }, + {-1 ,0x0000 }, +}; + +static const struct scale_ratio_to_reg_value_lookup easf_gain_ring4_4tap_lookup[] = { + {EASF_SCALE_RATIO (3 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (4 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (5 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (6 ,10 ),0x9900 }, + {EASF_SCALE_RATIO (7 ,10 ),0xA100 }, + {EASF_SCALE_RATIO (8 ,10 ),0xA8C0 }, + {EASF_SCALE_RATIO (9 ,10 ),0xAB20 }, + {EASF_SCALE_RATIO (1 ,1 ),0xAC00 }, + {-1 ,0xAC00 }, +}; + +static const struct scale_ratio_to_reg_value_lookup easf_3tap_dntilt_uptilt_offset_lookup[] = { + {EASF_SCALE_RATIO (3 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (4 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (5 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (6 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (7 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (8 ,10 ),0x4100 }, + {EASF_SCALE_RATIO (9 ,10 ),0x9F00 }, + {EASF_SCALE_RATIO (1 ,1 ),0xA4C0 }, + {-1 ,0xA8D8 }, +}; + +static const struct scale_ratio_to_reg_value_lookup easf_3tap_uptilt_maxval_lookup[] = { + {EASF_SCALE_RATIO (3 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (4 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (5 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (6 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (7 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (8 ,10 ),0x4000 }, + {EASF_SCALE_RATIO (9 ,10 ),0x24FE }, + {EASF_SCALE_RATIO (1 ,1 ),0x2D64 }, + {-1 ,0x3ADB }, +}; + +static const struct scale_ratio_to_reg_value_lookup easf_3tap_dntilt_slope_lookup[] = { + {EASF_SCALE_RATIO (3 ,10 ),0x3800 }, + {EASF_SCALE_RATIO (4 ,10 ),0x3800 }, + {EASF_SCALE_RATIO (5 ,10 ),0x3800 }, + {EASF_SCALE_RATIO (6 ,10 ),0x3800 }, + {EASF_SCALE_RATIO (7 ,10 ),0x3800 }, + {EASF_SCALE_RATIO (8 ,10 ),0x3886 }, + {EASF_SCALE_RATIO (9 ,10 ),0x3940 }, + {EASF_SCALE_RATIO (1 ,1 ),0x3A4E }, + {-1 ,0x3B66 }, +}; + +static const struct scale_ratio_to_reg_value_lookup easf_3tap_uptilt1_slope_lookup[] = { + {EASF_SCALE_RATIO (3 ,10 ),0x3800 }, + {EASF_SCALE_RATIO (4 ,10 ),0x3800 }, + {EASF_SCALE_RATIO (5 ,10 ),0x3800 }, + {EASF_SCALE_RATIO (6 ,10 ),0x3800 }, + {EASF_SCALE_RATIO (7 ,10 ),0x3800 }, + {EASF_SCALE_RATIO (8 ,10 ),0x36F4 }, + {EASF_SCALE_RATIO (9 ,10 ),0x359C }, + {EASF_SCALE_RATIO (1 ,1 ),0x3360 }, + {-1 ,0x2F20 }, +}; + +static const struct scale_ratio_to_reg_value_lookup easf_3tap_uptilt2_slope_lookup[] = { + {EASF_SCALE_RATIO (3 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (4 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (5 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (6 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (7 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (8 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (9 ,10 ),0x359C }, + {EASF_SCALE_RATIO (1 ,1 ),0x31F0 }, + {-1 ,0x1F00 }, +}; + +static const struct scale_ratio_to_reg_value_lookup easf_3tap_uptilt2_offset_lookup[] = { + {EASF_SCALE_RATIO (3 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (4 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (5 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (6 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (7 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (8 ,10 ),0x0000 }, + {EASF_SCALE_RATIO (9 ,10 ),0x9F00 }, + {EASF_SCALE_RATIO (1 ,1 ),0xA400 }, + {-1 ,0x9E00 }, };static const uint16_t *spl_get_easf_filter_3tap_64p (struct spl_fixed31_32 ratio) { -if (ratio.value <spl_fixpt_from_fraction (3 ,10 ).value) +if (ratio.value <EASF_SCALE_RATIO (3 ,10 ))return easf_filter_3tap_64p_ratio_0_30_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (4 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (4 ,10 ))return easf_filter_3tap_64p_ratio_0_40_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (5 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (5 ,10 ))return easf_filter_3tap_64p_ratio_0_50_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (6 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (6 ,10 ))return easf_filter_3tap_64p_ratio_0_60_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (7 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (7 ,10 ))return easf_filter_3tap_64p_ratio_0_70_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (8 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (8 ,10 ))return easf_filter_3tap_64p_ratio_0_80_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (9 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (9 ,10 ))return easf_filter_3tap_64p_ratio_0_90_s1_12;else return easf_filter_3tap_64p_ratio_1_00_s1_12;
@@ -2214,19 +2218,19 @@ static const uint16_t *spl_get_easf_filter_3tap_64p(struct spl_fixed31_32 ratio)static const uint16_t *spl_get_easf_filter_4tap_64p (struct spl_fixed31_32 ratio) { -if (ratio.value <spl_fixpt_from_fraction (3 ,10 ).value) +if (ratio.value <EASF_SCALE_RATIO (3 ,10 ))return easf_filter_4tap_64p_ratio_0_30_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (4 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (4 ,10 ))return easf_filter_4tap_64p_ratio_0_40_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (5 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (5 ,10 ))return easf_filter_4tap_64p_ratio_0_50_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (6 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (6 ,10 ))return easf_filter_4tap_64p_ratio_0_60_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (7 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (7 ,10 ))return easf_filter_4tap_64p_ratio_0_70_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (8 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (8 ,10 ))return easf_filter_4tap_64p_ratio_0_80_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (9 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (9 ,10 ))return easf_filter_4tap_64p_ratio_0_90_s1_12;else return easf_filter_4tap_64p_ratio_1_00_s1_12;
@@ -2234,19 +2238,19 @@ static const uint16_t *spl_get_easf_filter_4tap_64p(struct spl_fixed31_32 ratio)static const uint16_t *spl_get_easf_filter_6tap_64p (struct spl_fixed31_32 ratio) { -if (ratio.value <spl_fixpt_from_fraction (3 ,10 ).value) +if (ratio.value <EASF_SCALE_RATIO (3 ,10 ))return easf_filter_6tap_64p_ratio_0_30_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (4 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (4 ,10 ))return easf_filter_6tap_64p_ratio_0_40_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (5 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (5 ,10 ))return easf_filter_6tap_64p_ratio_0_50_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (6 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (6 ,10 ))return easf_filter_6tap_64p_ratio_0_60_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (7 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (7 ,10 ))return easf_filter_6tap_64p_ratio_0_70_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (8 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (8 ,10 ))return easf_filter_6tap_64p_ratio_0_80_s1_12; -else if (ratio.value <spl_fixpt_from_fraction (9 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (9 ,10 ))return easf_filter_6tap_64p_ratio_0_90_s1_12;else return easf_filter_6tap_64p_ratio_1_00_s1_12;
@@ -2270,19 +2274,19 @@ const uint16_t *SPL_NAMESPACE(spl_dscl_get_easf_filter_coeffs_64p(static const uint16_t *spl_get_easf_filter_3tap_64p_s1_10 (struct spl_fixed31_32 ratio) { -if (ratio.value <spl_fixpt_from_fraction (3 ,10 ).value) +if (ratio.value <EASF_SCALE_RATIO (3 ,10 ))return easf_filter_3tap_64p_ratio_0_30; -else if (ratio.value <spl_fixpt_from_fraction (4 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (4 ,10 ))return easf_filter_3tap_64p_ratio_0_40; -else if (ratio.value <spl_fixpt_from_fraction (5 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (5 ,10 ))return easf_filter_3tap_64p_ratio_0_50; -else if (ratio.value <spl_fixpt_from_fraction (6 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (6 ,10 ))return easf_filter_3tap_64p_ratio_0_60; -else if (ratio.value <spl_fixpt_from_fraction (7 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (7 ,10 ))return easf_filter_3tap_64p_ratio_0_70; -else if (ratio.value <spl_fixpt_from_fraction (8 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (8 ,10 ))return easf_filter_3tap_64p_ratio_0_80; -else if (ratio.value <spl_fixpt_from_fraction (9 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (9 ,10 ))return easf_filter_3tap_64p_ratio_0_90;else return easf_filter_3tap_64p_ratio_1_00;
@@ -2290,19 +2294,19 @@ static const uint16_t *spl_get_easf_filter_3tap_64p_s1_10(struct spl_fixed31_32static const uint16_t *spl_get_easf_filter_4tap_64p_s1_10 (struct spl_fixed31_32 ratio) { -if (ratio.value <spl_fixpt_from_fraction (3 ,10 ).value) +if (ratio.value <EASF_SCALE_RATIO (3 ,10 ))return easf_filter_4tap_64p_ratio_0_30; -else if (ratio.value <spl_fixpt_from_fraction (4 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (4 ,10 ))return easf_filter_4tap_64p_ratio_0_40; -else if (ratio.value <spl_fixpt_from_fraction (5 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (5 ,10 ))return easf_filter_4tap_64p_ratio_0_50; -else if (ratio.value <spl_fixpt_from_fraction (6 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (6 ,10 ))return easf_filter_4tap_64p_ratio_0_60; -else if (ratio.value <spl_fixpt_from_fraction (7 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (7 ,10 ))return easf_filter_4tap_64p_ratio_0_70; -else if (ratio.value <spl_fixpt_from_fraction (8 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (8 ,10 ))return easf_filter_4tap_64p_ratio_0_80; -else if (ratio.value <spl_fixpt_from_fraction (9 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (9 ,10 ))return easf_filter_4tap_64p_ratio_0_90;else return easf_filter_4tap_64p_ratio_1_00;
@@ -2310,19 +2314,19 @@ static const uint16_t *spl_get_easf_filter_4tap_64p_s1_10(struct spl_fixed31_32static const uint16_t *spl_get_easf_filter_6tap_64p_s1_10 (struct spl_fixed31_32 ratio) { -if (ratio.value <spl_fixpt_from_fraction (3 ,10 ).value) +if (ratio.value <EASF_SCALE_RATIO (3 ,10 ))return easf_filter_6tap_64p_ratio_0_30; -else if (ratio.value <spl_fixpt_from_fraction (4 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (4 ,10 ))return easf_filter_6tap_64p_ratio_0_40; -else if (ratio.value <spl_fixpt_from_fraction (5 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (5 ,10 ))return easf_filter_6tap_64p_ratio_0_50; -else if (ratio.value <spl_fixpt_from_fraction (6 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (6 ,10 ))return easf_filter_6tap_64p_ratio_0_60; -else if (ratio.value <spl_fixpt_from_fraction (7 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (7 ,10 ))return easf_filter_6tap_64p_ratio_0_70; -else if (ratio.value <spl_fixpt_from_fraction (8 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (8 ,10 ))return easf_filter_6tap_64p_ratio_0_80; -else if (ratio.value <spl_fixpt_from_fraction (9 ,10 ).value) +else if (ratio.value <EASF_SCALE_RATIO (9 ,10 ))return easf_filter_6tap_64p_ratio_0_90;else return easf_filter_6tap_64p_ratio_1_00;
@@ -2381,12 +2385,12 @@ void SPL_NAMESPACE(spl_set_filters_data(struct dscl_prog_data *dscl_prog_data, }static uint32_t spl_easf_get_scale_ratio_to_reg_value (struct spl_fixed31_32 ratio, -struct scale_ratio_to_reg_value_lookup *lookup_table_base_ptr, +const struct scale_ratio_to_reg_value_lookup *lookup_table_base_ptr,unsigned int num_entries) {unsigned int count =0 ;uint32_t value =0 ; -struct scale_ratio_to_reg_value_lookup *lookup_table_index_ptr; +const struct scale_ratio_to_reg_value_lookup *lookup_table_index_ptr; lookup_table_index_ptr = (lookup_table_base_ptr + num_entries -1 ); value = lookup_table_index_ptr->reg_value;
@@ -2394,12 +2398,10 @@ static uint32_t spl_easf_get_scale_ratio_to_reg_value(struct spl_fixed31_32 ratiwhile (count < num_entries) { lookup_table_index_ptr = (lookup_table_base_ptr + count); -if (lookup_table_index_ptr->numer <0 ) +if (lookup_table_index_ptr->scale_ratio <0 )break ; -if (ratio.value <spl_fixpt_from_fraction ( - lookup_table_index_ptr->numer, - lookup_table_index_ptr->denom).value) { +if (ratio.value < lookup_table_index_ptr->scale_ratio) { value = lookup_table_index_ptr->reg_value;break ; }
drivers/gpu/drm/amd/display/dc/sspl/dc_spl_scl_easf_filters.h +1 -2
@@ -8,8 +8,7 @@#include "dc_spl_types.h" struct scale_ratio_to_reg_value_lookup { -int numer; -int denom; +long long scale_ratio;const uint32_t reg_value; };
Signature · 1 line
2.56.1
PATCH v2 10/30 drm/amd/display: Make DPP_SET_INPUT_TRANSFER_FUNC BLS compliant
In reply to George ZhangFrom: Rafal Ostrowski <[email protected]>
[Why]
- The DPP_SET_INPUT_TRANSFER_FUNC step carried dc, stream and plane_state, so the hwseq hooks read plane and stream state at execute time.
[How]
- Add hwss_resolve_set_input_transfer_func_params(). It copies the pixel format, the CM enable flags and the RMCM pool by value, and borrows the curve and LUT data from the plane state.
- Build the step from the resolved params in hwss_add_dpp_set_input_transfer_func(), hwss_build_fast_sequence() and dcn401_program_pipe_sequence(). The adder validates its arguments and the hook; the executor only dispatches.
- Pass the resolved params to set_blend_lut, set_shaper_3dlut and disable_rmcm_luts, and drop dc, stream and plane_state from them.
- Give set_mcm_luts and set_rmcm_luts their own argument structs, set_mcm_luts_params and set_rmcm_luts_params. The dispatcher fills them from the step params, so each hook sees only the fields it uses.
- set_mcm_luts() still reads dpp->ctx. It passes it to cm3_helper_translate_curve_to_hw_format(), which uses it only for the logger, so it cannot be dropped without changing that shared helper.
- Move MAX_RMCM_INST to hw_shared.h.
--- .../drm/amd/display/dc/core/dc_hw_sequencer.c | 125 ++++++++++-------- .../amd/display/dc/hwss/dce110/dce110_hwseq.c | 19 ++- .../amd/display/dc/hwss/dcn10/dcn10_hwseq.c | 15 +-- .../amd/display/dc/hwss/dcn20/dcn20_hwseq.c | 45 +++---- .../amd/display/dc/hwss/dcn20/dcn20_hwseq.h | 5 +- .../amd/display/dc/hwss/dcn30/dcn30_hwseq.c | 32 ++--- .../amd/display/dc/hwss/dcn30/dcn30_hwseq.h | 2 +- .../amd/display/dc/hwss/dcn32/dcn32_hwseq.c | 102 ++++++++------ .../amd/display/dc/hwss/dcn32/dcn32_hwseq.h | 5 +- .../amd/display/dc/hwss/dcn35/dcn35_hwseq.c | 3 +- .../amd/display/dc/hwss/dcn401/dcn401_hwseq.c | 74 ++++++----- .../amd/display/dc/hwss/dcn401/dcn401_hwseq.h | 5 +- .../amd/display/dc/hwss/dcn42/dcn42_hwseq.c | 56 ++++---- .../amd/display/dc/hwss/dcn42/dcn42_hwseq.h | 13 +- .../amd/display/dc/hwss/dcn60/dcn60_hwseq.c | 33 ++--- .../amd/display/dc/hwss/dcn60/dcn60_hwseq.h | 2 +- .../drm/amd/display/dc/hwss/hw_sequencer.h | 56 +++++++- .../display/dc/hwss/hw_sequencer_private.h | 17 +-- .../gpu/drm/amd/display/dc/inc/core_types.h | 2 - .../gpu/drm/amd/display/dc/inc/hw/hw_shared.h | 2 + 20 files changed, 348 insertions(+), 265 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c +72 -53
@@ -116,6 +116,52 @@ void hwss_dmub_fams2_update_config(union block_sequence_params *params)dc_dmub_srv_fams2_update_config (p->dmub_srv, &p->data); } +/* +* Resolve everything DPP_SET_INPUT_TRANSFER_FUNC needs from the pipe and plane, +* so the hwseq implementation never reads dc, stream or plane state. +*/ +void hwss_resolve_set_input_transfer_func_params (struct dc *dc, +struct pipe_ctx *pipe_ctx, +struct set_input_transfer_func_params *params) +{ +struct pipe_ctx *primary_dpp_pipe =resource_get_primary_dpp_pipe (pipe_ctx); +const struct dc_plane_state *plane_state = pipe_ctx->plane_state; + + *params = (struct set_input_transfer_func_params ) { + .hws = dc->hwseq, + .dpp = pipe_ctx->plane_res.dpp, + .hubp = pipe_ctx->plane_res.hubp, + .primary_hubp = primary_dpp_pipe ? + primary_dpp_pipe->plane_res.hubp : pipe_ctx->plane_res.hubp, + .mpc = dc->res_pool->mpc, + .rmcm = pipe_ctx->plane_res.rmcm, + .mpcc_id = pipe_ctx->plane_res.mpcc_inst, + .ipp = pipe_ctx->plane_res.ipp, + .always_use_regamma = dc->debug.always_use_regamma, + }; + +if (dc->res_pool->res_cap) { +int rmcm_count = dc->res_pool->res_cap->num_rmcm; + + params->rmcm_pool = dc->res_pool->rmcm; + params->rmcm_count = rmcm_count <MAX_RMCM_INST ? rmcm_count :MAX_RMCM_INST ; + } + +if (!plane_state) +return ; + + params->format = plane_state->format; + params->scaling_linearity = plane_state->scaling_linearity; + params->blend_enable = plane_state->cm.flags.bits.blend_enable !=0 ; + params->shaper_enable = plane_state->cm.flags.bits.shaper_enable !=0 ; + params->lut3d_enable = plane_state->cm.flags.bits.lut3d_enable !=0 ; + params->lut3d_dma_enable = plane_state->cm.flags.bits.lut3d_dma_enable !=0 ; + params->rmcm_enable = plane_state->cm.flags.bits.rmcm_enable !=0 ; + params->in_transfer_func = &plane_state->in_transfer_func; + params->gamma_correction = &plane_state->gamma_correction; + params->cm = &plane_state->cm; +} +#define MAX_NUM_MCACHE 8/* used as index in array of black_color_format */
@@ -1541,26 +1587,12 @@ void hwss_build_fast_sequence(struct dc *dc, block_sequence[*num_steps].func =HUBP_ENABLE_3DLUT_FL ; (*num_steps)++; } -if (hws->funcs.set_input_transfer_func && current_mpc_pipe->plane_state->update_bits.gamma_change) { -struct pipe_ctx *primary_dpp_pipe = -resource_get_primary_dpp_pipe (current_mpc_pipe); - - block_sequence[*num_steps].params.set_input_transfer_func_params = - (struct set_input_transfer_func_params ) { - .dc = dc, - .dpp = current_mpc_pipe->plane_res.dpp, - .hubp = current_mpc_pipe->plane_res.hubp, - .primary_hubp = primary_dpp_pipe ? - primary_dpp_pipe->plane_res.hubp : current_mpc_pipe->plane_res.hubp, - .ipp = current_mpc_pipe->plane_res.ipp, - .mpc = dc->res_pool->mpc, - .rmcm = current_mpc_pipe->plane_res.rmcm, - .mpcc_id = current_mpc_pipe->plane_res.mpcc_inst, - .stream = current_mpc_pipe->stream, - .plane_state = current_mpc_pipe->plane_state, - }; - block_sequence[*num_steps].func =DPP_SET_INPUT_TRANSFER_FUNC ; - (*num_steps)++; +if (current_mpc_pipe->plane_state->update_bits.gamma_change) { +struct set_input_transfer_func_params itf_params; + +hwss_resolve_set_input_transfer_func_params (dc, current_mpc_pipe, + &itf_params); +hwss_add_dpp_set_input_transfer_func (&seq_state, &itf_params); }if (current_mpc_pipe->plane_state->update_bits.hdr_mult) {
@@ -1737,7 +1769,7 @@ void hwss_execute_sequence(struct dc *dc, params->update_plane_addr_params.dcc);break ;case DPP_SET_INPUT_TRANSFER_FUNC : - hws->funcs.set_input_transfer_func (¶ms->set_input_transfer_func_params); +hwss_dpp_set_input_transfer_func (params);break ;case DPP_PROGRAM_GAMUT_REMAP :if (dc->hwss.program_gamut_remap)
@@ -2391,27 +2423,18 @@ void hwss_add_hubp_update_plane_addr(struct block_sequence_state *seq_state,/* * Helper function to add DPP set input transfer function to block sequence */ -void hwss_add_dpp_set_input_transfer_func (struct block_sequence_state *seq_state,struct dc *dc, -struct pipe_ctx *pipe_ctx) +void hwss_add_dpp_set_input_transfer_func (struct block_sequence_state *seq_state, +const struct set_input_transfer_func_params *params) { +if (!seq_state || !seq_state->steps || !seq_state->num_steps || !params || !params->hws || + !params->hws->funcs.set_input_transfer_func) +return ; +if (*seq_state->num_steps <MAX_HWSS_BLOCK_SEQUENCE_SIZE ) { -struct pipe_ctx *primary_dpp_pipe =resource_get_primary_dpp_pipe (pipe_ctx); +struct block_sequence *step = &seq_state->steps[*seq_state->num_steps]; - seq_state->steps[*seq_state->num_steps].params.set_input_transfer_func_params = - (struct set_input_transfer_func_params ) { - .dc = dc, - .dpp = pipe_ctx->plane_res.dpp, - .hubp = pipe_ctx->plane_res.hubp, - .primary_hubp = primary_dpp_pipe ? - primary_dpp_pipe->plane_res.hubp : pipe_ctx->plane_res.hubp, - .ipp = pipe_ctx->plane_res.ipp, - .mpc = dc->res_pool->mpc, - .rmcm = pipe_ctx->plane_res.rmcm, - .mpcc_id = pipe_ctx->plane_res.mpcc_inst, - .plane_state = pipe_ctx->plane_state, - .stream = pipe_ctx->stream, - }; - seq_state->steps[*seq_state->num_steps].func =DPP_SET_INPUT_TRANSFER_FUNC ; + step->params.set_input_transfer_func_params = *params; + step->func =DPP_SET_INPUT_TRANSFER_FUNC ; (*seq_state->num_steps)++; } }
@@ -4942,24 +4965,20 @@ void hwss_disable_audio_stream(struct dc *dc, union block_sequence_params *paramvoid hwss_set_input_transfer_func (struct dc *dc,struct pipe_ctx *pipe_ctx) {if (dc->hwseq->funcs.set_input_transfer_func) { -struct pipe_ctx *primary_dpp_pipe =resource_get_primary_dpp_pipe (pipe_ctx); +struct set_input_transfer_func_params params; - dc->hwseq->funcs.set_input_transfer_func (&(struct set_input_transfer_func_params ) { - .dc = dc, - .dpp = pipe_ctx->plane_res.dpp, - .hubp = pipe_ctx->plane_res.hubp, - .primary_hubp = primary_dpp_pipe ? - primary_dpp_pipe->plane_res.hubp : pipe_ctx->plane_res.hubp, - .ipp = pipe_ctx->plane_res.ipp, - .mpc = dc->res_pool->mpc, - .rmcm = pipe_ctx->plane_res.rmcm, - .mpcc_id = pipe_ctx->plane_res.mpcc_inst, - .plane_state = pipe_ctx->plane_state, - .stream = pipe_ctx->stream, - }); +hwss_resolve_set_input_transfer_func_params (dc, pipe_ctx, ¶ms); + dc->hwseq->funcs.set_input_transfer_func (¶ms); } } +void hwss_dpp_set_input_transfer_func (union block_sequence_params *params) +{ +struct set_input_transfer_func_params *itf_params = ¶ms->set_input_transfer_func_params; + + itf_params->hws->funcs.set_input_transfer_func (itf_params); +} +void hwss_prepare_bandwidth (struct dc *dc,union block_sequence_params *params) {if (dc && dc->hwss.prepare_bandwidth)
drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c +8 -11
@@ -261,11 +261,11 @@ static bool dce110_enable_display_power_gating( }static void dce110_prescale_params (struct ipp_prescale_params *prescale_params, -const struct dc_plane_state *plane_state) +enum surface_pixel_format format) { prescale_params->mode =IPP_PRESCALE_MODE_FIXED_UNSIGNED ; -switch (plane_state->format) { +switch (format) {case SURFACE_PIXEL_FORMAT_GRPH_RGB565 : prescale_params->scale =0x2082 ;break ;
@@ -293,22 +293,19 @@ static bool dce110_set_input_transfer_func(struct set_input_transfer_func_params *params) {struct input_pixel_processor *ipp = params->ipp; -struct dc_plane_state *plane_state = params->plane_state; -const struct dc_transfer_func *tf =NULL ; +const struct dc_transfer_func *tf = params->in_transfer_func;struct ipp_prescale_params prescale_params = {0 };bool result = true; -if (ipp ==NULL ) +if (ipp ==NULL || tf ==NULL )return false; - tf = &plane_state->in_transfer_func; - -dce110_prescale_params (&prescale_params, plane_state); +dce110_prescale_params (&prescale_params, params->format); ipp->funcs->ipp_program_prescale (ipp, &prescale_params); -if (!plane_state->gamma_correction.is_identity && -dce_use_lut (plane_state->format)) - ipp->funcs->ipp_program_input_lut (ipp, &plane_state->gamma_correction); +if (!params->gamma_correction->is_identity && +dce_use_lut (params->format)) + ipp->funcs->ipp_program_input_lut (ipp, params->gamma_correction);if (tf->type ==TF_TYPE_PREDEFINED ) {switch (tf->tf) {
drivers/gpu/drm/amd/display/dc/hwss/dcn10/dcn10_hwseq.c +6 -9
@@ -2119,19 +2119,16 @@ void dcn10_update_plane_addr(const struct dc *dc, struct pipe_ctx *pipe_ctx)bool dcn10_set_input_transfer_func (struct set_input_transfer_func_params *params) {struct dpp *dpp = params->dpp; -struct dc_plane_state *plane_state = params->plane_state; -const struct dc_transfer_func *tf =NULL ; +const struct dc_transfer_func *tf = params->in_transfer_func;bool result = true; -if (dpp ==NULL ) +if (dpp ==NULL || tf ==NULL )return false; - tf = &plane_state->in_transfer_func; - -if (!dpp->ctx->dc->debug.always_use_regamma - && !plane_state->gamma_correction.is_identity - &&dce_use_lut (plane_state->format)) - dpp->funcs->dpp_program_input_lut (dpp, &plane_state->gamma_correction); +if (!params->always_use_regamma + && !params->gamma_correction->is_identity + &&dce_use_lut (params->format)) + dpp->funcs->dpp_program_input_lut (dpp, params->gamma_correction);if (tf->type ==TF_TYPE_PREDEFINED ) {switch (tf->tf) {
drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c +22 -23
88 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.h +3 -2
@@ -31,9 +31,10 @@void dcn20_log_color_state (struct dc *dc,struct dc_log_buffer_ctx *log_ctx);bool dcn20_set_blend_lut ( -struct dpp *dpp,struct dc_plane_state *plane_state); +struct dpp *dpp,const struct dc_transfer_func *blend_func);bool dcn20_set_shaper_3dlut ( -struct dpp *dpp,struct dc_plane_state *plane_state); +struct dpp *dpp,const struct dc_transfer_func *shaper_func, +const struct dc_3dlut *lut3d_func);void dcn20_program_front_end_for_ctx (struct dc *dc,struct dc_state *context);
drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.c +16 -16
@@ -234,16 +234,16 @@ void dcn30_log_color_state(struct dc *dc, }bool dcn30_set_blend_lut ( -struct dpp *dpp,struct dc_plane_state *plane_state) +struct dpp *dpp,const struct dc_transfer_func *blend_func) {bool result = true;const struct pwl_params *blend_lut =NULL ; -if (plane_state->cm.blend_func.type ==TF_TYPE_HWPWL ) - blend_lut = &plane_state->cm.blend_func.pwl; -else if (plane_state->cm.blend_func.type ==TF_TYPE_DISTRIBUTED_POINTS ) { +if (blend_func->type ==TF_TYPE_HWPWL ) + blend_lut = &blend_func->pwl; +else if (blend_func->type ==TF_TYPE_DISTRIBUTED_POINTS ) { result =cm3_helper_translate_curve_to_degamma_hw_format ( - &plane_state->cm.blend_func, + blend_func, &dpp->regamma_params);if (!result)return result;
@@ -315,36 +315,36 @@ static bool dcn30_set_mpc_shaper_3dlut(struct dpp *dpp, struct mpc *mpc,bool dcn30_set_input_transfer_func (struct set_input_transfer_func_params *params) {struct dpp *dpp = params->dpp; -struct dce_hwseq *hws = params->dc->hwseq; -struct dc_plane_state *plane_state = params->plane_state; +struct dce_hwseq *hws = params->hws; +const struct dc_transfer_func *in_tf = params->in_transfer_func;enum dc_transfer_func_predefined tf;bool result = true;const struct pwl_params *pwl_params =NULL ; -if (dpp ==NULL || plane_state ==NULL ) +if (dpp ==NULL || in_tf ==NULL )return false; tf =TRANSFER_FUNCTION_UNITY ; -if (plane_state->in_transfer_func.type ==TF_TYPE_PREDEFINED ) - tf = plane_state->in_transfer_func.tf; +if (in_tf->type ==TF_TYPE_PREDEFINED ) + tf = in_tf->tf; dpp->funcs->dpp_set_pre_degam (dpp, tf); -if (plane_state->in_transfer_func.type ==TF_TYPE_HWPWL ) - pwl_params = &plane_state->in_transfer_func.pwl; -else if (plane_state->in_transfer_func.type ==TF_TYPE_DISTRIBUTED_POINTS && -cm3_helper_translate_curve_to_degamma_hw_format (&plane_state->in_transfer_func, +if (in_tf->type ==TF_TYPE_HWPWL ) + pwl_params = &in_tf->pwl; +else if (in_tf->type ==TF_TYPE_DISTRIBUTED_POINTS && +cm3_helper_translate_curve_to_degamma_hw_format (in_tf, &dpp->degamma_params)) pwl_params = &dpp->degamma_params; result = dpp->funcs->dpp_program_gamcor_lut (dpp, pwl_params);if (dpp->funcs->dpp_program_blnd_lut) - hws->funcs.set_blend_lut (dpp, plane_state); + hws->funcs.set_blend_lut (dpp, ¶ms->cm->blend_func);if (dpp->funcs->dpp_program_shaper_lut && dpp->funcs->dpp_program_3dlut) - hws->funcs.set_shaper_3dlut (dpp, plane_state); + hws->funcs.set_shaper_3dlut (dpp, ¶ms->cm->shaper_func, ¶ms->cm->lut3d_func);return result;
drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.h +1 -1
@@ -57,7 +57,7 @@ void dcn30_log_color_state(struct dc *dc, struct dc_log_buffer_ctx *log_ctx);bool dcn30_set_blend_lut (struct dpp *dpp, -struct dc_plane_state *plane_state); +const struct dc_transfer_func *blend_func);bool dcn30_set_input_transfer_func (struct set_input_transfer_func_params *params);
drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c +62 -40
159 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.h +1 -4
@@ -48,10 +48,7 @@ void dcn32_cab_for_ss_control(struct dc *dc, bool enable);void dcn32_commit_subvp_config (struct dc *dc,struct dc_state *context); -bool dcn32_set_mcm_luts (struct dc *dc,struct dpp *dpp,struct hubp *hubp, -struct hubp *primary_hubp,struct mpc *mpc,int mpcc_id, -struct dc_stream_state *stream, -struct dc_plane_state *plane_state); +bool dcn32_set_mcm_luts (const struct set_mcm_luts_params *params);bool dcn32_set_input_transfer_func (struct set_input_transfer_func_params *params);
drivers/gpu/drm/amd/display/dc/hwss/dcn35/dcn35_hwseq.c +2 -1
@@ -893,7 +893,8 @@ void dcn35_plane_atomic_disable(struct dc *dc, struct pipe_ctx *pipe_ctx)/* Clearing 3DLUT fast load writes to HUBP, so it must precede hubp_clk_cntl() below */ if (hws->funcs.disable_rmcm_luts) - hws->funcs.disable_rmcm_luts (dc, pipe_ctx->plane_res.rmcm, hubp, pipe_ctx->plane_res.mpcc_inst); + hws->funcs.disable_rmcm_luts (dc->res_pool->rmcm, dc->res_pool->res_cap->num_rmcm, + pipe_ctx->plane_res.rmcm, hubp, pipe_ctx->plane_res.mpcc_inst); dc->hwss.wait_for_mpcc_disconnect (dc, dc->res_pool, pipe_ctx);
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c +38 -36
161 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.h +1 -4
@@ -37,10 +37,7 @@ void dcn401_program_gamut_remap(struct program_gamut_remap_params *params);void dcn401_init_hw (struct dc *dc); -bool dcn401_set_mcm_luts (struct dc *dc,struct dpp *dpp,struct hubp *hubp, -struct hubp *primary_hubp,struct mpc *mpc,int mpcc_id, -struct dc_stream_state *stream, -struct dc_plane_state *plane_state); +bool dcn401_set_mcm_luts (const struct set_mcm_luts_params *params);bool dcn401_set_output_transfer_func (struct set_output_transfer_func_params *params);void dcn401_trigger_3dlut_dma_load (struct pipe_ctx *pipe_ctx); void dcn401_calculate_dccg_tmds_div_value(struct pipe_ctx *pipe_ctx,
drivers/gpu/drm/amd/display/dc/hwss/dcn42/dcn42_hwseq.c +29 -27
126 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hwss/dcn42/dcn42_hwseq.h +6 -7
@@ -15,17 +15,16 @@ void dcn42_program_cm_hist(struct pipe_ctx *pipe_ctx, const struct dc_plane_state *plane_state); -bool dcn42_set_mcm_luts (struct dc *dc,struct dpp *dpp,struct hubp *hubp, -struct hubp *primary_hubp,struct mpc *mpc,int mpcc_id, -struct dc_stream_state *stream, -struct dc_plane_state *plane_state); +bool dcn42_set_mcm_luts (const struct set_mcm_luts_params *params); -void dcn42_disable_rmcm_luts (struct dc *dc,struct rmcm *rmcm,struct hubp *hubp,int mpcc_id); -void dcn42_release_rmcm_from_mpcc (struct dc *dc,int mpcc_id,const struct rmcm *keep); +void dcn42_disable_rmcm_luts (struct rmcm **rmcm_pool,int rmcm_count, +struct rmcm *rmcm,struct hubp *hubp,int mpcc_id); +void dcn42_release_rmcm_from_mpcc (struct rmcm **rmcm_pool,int rmcm_count, +int mpcc_id,const struct rmcm *keep);void dcn42_disable_mcm_luts (struct mpc *mpc,int mpcc_id);void dcn42_trigger_3dlut_dma_load (struct pipe_ctx *pipe_ctx); -bool dcn42_set_rmcm_luts (struct set_input_transfer_func_params *params); +bool dcn42_set_rmcm_luts (const struct set_rmcm_luts_params *params);void dcn42_hardware_release (struct dc *dc);
drivers/gpu/drm/amd/display/dc/hwss/dcn60/dcn60_hwseq.c +17 -16
@@ -52,11 +52,12 @@#define FN (reg_name, field_name) \ hws->shifts->field_name, hws->masks->field_name -bool dcn60_set_rmcm_luts (struct set_input_transfer_func_params *params) +bool dcn60_set_rmcm_luts (const struct set_rmcm_luts_params *params) {struct dpp *dpp_base = params->dpp;struct hubp *hubp = params->hubp; -const struct dc_plane_cm *cm = ¶ms->plane_state->cm; +const struct dc_transfer_func *shaper_func = ¶ms->cm->shaper_func; +const struct dc_3dlut_dma *cm_lut3d_dma = ¶ms->cm->lut3d_dma;struct rmcm *rmcm = params->rmcm;int rmcm_inst;union rmcm_lut_params m_lut_params = {0 };
@@ -74,15 +75,15 @@ bool dcn60_set_rmcm_luts(struct set_input_transfer_func_params *params) rmcm_inst = rmcm->inst;/* Shaper */ - lut_enable = cm->flags.bits.shaper_enable !=0 ; + lut_enable = params->shaper_enable;if (lut_enable) {memset (&m_lut_params,0 ,sizeof (m_lut_params)); -if (cm->shaper_func.type ==TF_TYPE_HWPWL ) - m_lut_params.pwl = &cm->shaper_func.pwl; -else if (cm->shaper_func.type ==TF_TYPE_DISTRIBUTED_POINTS ) { +if (shaper_func->type ==TF_TYPE_HWPWL ) + m_lut_params.pwl = &shaper_func->pwl; +else if (shaper_func->type ==TF_TYPE_DISTRIBUTED_POINTS ) {ASSERT (false); - rval =cm_helper_translate_curve_to_hw_format (params->plane_state->ctx, - &cm->shaper_func, + rval =cm_helper_translate_curve_to_hw_format (dpp_base->ctx, + shaper_func, &dpp_base->shaper_params, true); m_lut_params.pwl = rval ? &dpp_base->shaper_params :NULL ;
@@ -106,13 +107,13 @@ bool dcn60_set_rmcm_luts(struct set_input_transfer_func_params *params)*/ /* 3DLUT */ - lut_enable = cm->flags.bits.lut3d_enable !=0 ; -if (lut_enable && cm->flags.bits.lut3d_dma_enable) { + lut_enable = params->lut3d_enable; +if (lut_enable && params->lut3d_dma_enable) {/* Fast (DMA) Load Mode */ if (rmcm->funcs->program_lut_mode) rmcm->funcs->program_lut_mode (rmcm,MCM_LUT_3DLUT , lut_enable, true, - cm->lut3d_dma.size, - cm->lut3d_dma.bias, cm->lut3d_dma.scale, + cm_lut3d_dma->size, + cm_lut3d_dma->bias, cm_lut3d_dma->scale, rmcm_inst);if (rmcm->funcs->program_lut_read_write_control)
@@ -123,13 +124,13 @@ bool dcn60_set_rmcm_luts(struct set_input_transfer_func_params *params)/* HUBP */ if (hubp->funcs->hubp_program_3dlut_fl_config) - hubp->funcs->hubp_program_3dlut_fl_config (hubp, &cm->lut3d_dma); + hubp->funcs->hubp_program_3dlut_fl_config (hubp, cm_lut3d_dma);if (hubp->funcs->hubp_program_3dlut_fl_crossbar) - hubp->funcs->hubp_program_3dlut_fl_crossbar (hubp, cm->lut3d_dma.format); + hubp->funcs->hubp_program_3dlut_fl_crossbar (hubp, cm_lut3d_dma->format);if (hubp->funcs->hubp_program_3dlut_fl_addr) - hubp->funcs->hubp_program_3dlut_fl_addr (hubp, &cm->lut3d_dma.addr); + hubp->funcs->hubp_program_3dlut_fl_addr (hubp, &cm_lut3d_dma->addr);if (hubp->funcs->hubp_enable_3dlut_fl) { hubp->funcs->hubp_enable_3dlut_fl (hubp, true);
@@ -165,7 +166,7 @@ bool dcn60_set_rmcm_luts(struct set_input_transfer_func_params *params)/* Connect to the MPCC only once the LUTs are loaded. Teardown is done by * disable_rmcm_luts, at plane teardown or when the plane switches back to MCM. */ -dcn42_release_rmcm_from_mpcc (params->dc, params->mpcc_id, rmcm); +dcn42_release_rmcm_from_mpcc (params->rmcm_pool, params->rmcm_count, params->mpcc_id, rmcm);if (rmcm->funcs->connect_mpcc) rmcm->funcs->connect_mpcc (rmcm, rmcm_inst, params->mpcc_id);
drivers/gpu/drm/amd/display/dc/hwss/dcn60/dcn60_hwseq.h +1 -1
@@ -31,6 +31,6 @@ void dcn60_program_perfmon(struct dc *dc, struct dc_state *context);bool dcn60_apply_idle_power_optimizations (struct dc *dc,bool enable);bool dcn60_dsc_pg_status (struct dce_hwseq *hws,unsigned int dsc_inst); -bool dcn60_set_rmcm_luts (struct set_input_transfer_func_params *params); +bool dcn60_set_rmcm_luts (const struct set_rmcm_luts_params *params);#endif /* __DC_HWSS_DCN60_H__ */
drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h +52 -4
81 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer_private.h +9 -8
@@ -74,6 +74,8 @@ struct tg_color;struct output_pixel_processor ;struct mpcc_blnd_cfg ;struct rmcm ; +struct dc_transfer_func ; +struct dc_3dlut ;struct hwseq_private_funcs {
@@ -193,16 +195,15 @@ struct hwseq_private_funcs {bool (*wait_for_blank_complete)(struct output_pixel_processor *opp);void (*dccg_init)(struct dce_hwseq *hws);bool (*set_blend_lut)(struct dpp *dpp, -struct dc_plane_state *plane_state); +const struct dc_transfer_func *blend_func);bool (*set_shaper_3dlut)(struct dpp *dpp, -struct dc_plane_state *plane_state); -bool (*set_mcm_luts)(struct dc *dc,struct dpp *dpp,struct hubp *hubp, -struct hubp *primary_hubp,struct mpc *mpc,int mpcc_id, -struct dc_stream_state *stream, -struct dc_plane_state *plane_state); -bool (*set_rmcm_luts)(struct set_input_transfer_func_params *params); +const struct dc_transfer_func *shaper_func, +const struct dc_3dlut *lut3d_func); +bool (*set_mcm_luts)(const struct set_mcm_luts_params *params); +bool (*set_rmcm_luts)(const struct set_rmcm_luts_params *params);void (*disable_mcm_luts)(struct mpc *mpc,int mpcc_id); -void (*disable_rmcm_luts)(struct dc *dc,struct rmcm *rmcm,struct hubp *hubp,int mpcc_id); +void (*disable_rmcm_luts)(struct rmcm **rmcm_pool,int rmcm_count, +struct rmcm *rmcm,struct hubp *hubp,int mpcc_id);void (*PLAT_58856_wa)(struct dc_state *context,struct pipe_ctx *pipe_ctx);void (*setup_hpo_hw_control)(const struct dce_hwseq *hws,bool enable);
drivers/gpu/drm/amd/display/dc/inc/core_types.h +0 -2
@@ -72,8 +72,6 @@ struct resource_context;struct clk_bw_params ;struct dc_mcache_params ; -#define MAX_RMCM_INST 2 -struct resource_funcs {enum engine_id (*get_preferred_eng_id_dpia)(unsigned int dpia_index);void (*destroy)(struct resource_pool **pool);
drivers/gpu/drm/amd/display/dc/inc/hw/hw_shared.h +2 -0
@@ -45,6 +45,8 @@#define MAX_PIPES 6#define MAX_PHANTOM_PIPES (MAX_PIPES / 2) +#define MAX_RMCM_INST 2 +#define MAX_DPIA 6#define MAX_CONNECTOR 6#define MAX_VIRTUAL_LINKS 4
Signature · 1 line
2.56.1
PATCH v2 11/30 drm/amd/display: Add pipe init to core2
In reply to George ZhangFrom: Tomasz Siemek <[email protected]>
[Why]
Dc1 expects some software pipe state after initialization.
[How]
Add pipe initialization to core2 init, driven by a stage-based build/run loop: core2_build_and_run() and core2_run_wrapped_hardware_init() now loop while the builder returns BLS_BUILD_MORE_STAGES, instead of running a single stage.
Export core2_run_sequence(), replacing core2_run_init_stage(), so the new loop can run each stage as it is built.
Add HUBBUB_INIT, HUBBUB_GLOBAL_TIMER_ENABLE and MPC_INIT block-sequence steps, and a global_timer_enable hook on every DCN hubbub, to program the new pipe-init state.
Rename init_hpo_hw_control() to setup_hpo_hw_control() to match.
Guard the DMUB feature_caps write against a NULL dmub_srv/dmub, since core init can now run before dmub_srv exists.
--- .../amd/display/dc/bls_builder/bls_builder.c | 2 +- .../amd/display/dc/bls_builder/bls_builder.h | 5 ++ .../dc/bls_builder/bls_builder_internal.h | 3 +- .../dc/bls_builder/dcn401_init_builder.c | 16 +++-- .../bls_builder/dcn401_init_builder_legacy.c | 2 +- .../display/dc/bls_executor/bls_executor.c | 42 ++++++++++- .../gpu/drm/amd/display/dc/core2/dc_core2.c | 43 +++++++---- .../gpu/drm/amd/display/dc/core2/dc_core2.h | 7 ++ .../drm/amd/display/dc/core2/dc_core2_init.c | 71 +++++++++---------- .../display/dc/hubbub/dcn10/dcn10_hubbub.c | 1 + .../display/dc/hubbub/dcn20/dcn20_hubbub.c | 1 + .../display/dc/hubbub/dcn201/dcn201_hubbub.c | 1 + .../display/dc/hubbub/dcn21/dcn21_hubbub.c | 1 + .../display/dc/hubbub/dcn30/dcn30_hubbub.c | 3 +- .../display/dc/hubbub/dcn301/dcn301_hubbub.c | 1 + .../display/dc/hubbub/dcn31/dcn31_hubbub.c | 3 +- .../display/dc/hubbub/dcn32/dcn32_hubbub.c | 3 +- .../display/dc/hubbub/dcn35/dcn35_hubbub.c | 3 +- .../display/dc/hubbub/dcn401/dcn401_hubbub.c | 3 +- .../display/dc/hubbub/dcn42/dcn42_hubbub.c | 3 +- .../display/dc/hubbub/dcn60/dcn60_hubbub.c | 1 + .../amd/display/dc/hwss/dcn401/dcn401_init.c | 2 +- .../drm/amd/display/dc/hwss/hw_sequencer.h | 29 ++++++++ .../display/dc/hwss/hw_sequencer_private.h | 5 -- .../gpu/drm/amd/display/dc/inc/hw/dchubbub.h | 1 + 25 files changed, 176 insertions(+), 76 deletions(-)
drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.c +1 -1
@@ -6,7 +6,7 @@#include "dm_services.h" #include "bls_builder/bls_builder_internal.h" -const struct bls_builder *dcn401_bls_builder_create ( +static const struct bls_builder *dcn401_bls_builder_create (enum bls_builder_name name) {switch (name) {
drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h +5 -0
@@ -18,6 +18,7 @@enum bls_builder_result {BLS_BUILD_SUCCESS , +BLS_BUILD_MORE_STAGES ,BLS_BUILD_ERROR_UNSUPPORTED_STATE_UPDATE ,BLS_BUILD_ERROR_RESOURCE_MAPPING , };
@@ -36,6 +37,10 @@ enum bls_builder_kind { BLS_BUILDER_IMPERATIVE, }; +/* +* Core builds and runs a builder at most this many times while it returns +* BLS_BUILD_MORE_STAGES; a builder still asking for more after that fails. +*/ #define BLS_BUILDER_INIT_MAX_STAGE_COUNT 4struct bls_builder_dpm {
drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_internal.h +1 -2
@@ -7,10 +7,9 @@#include "bls_builder/bls_builder.h" -const struct bls_builder *dcn401_bls_builder_create ( -enum bls_builder_name name);const struct bls_builder *dcn401_initialization_builder (void );const struct bls_builder *dcn401_legacy_initialization_builder (void );const struct bls_builder *dcn401_accelerated_mode_query_builder (void );const struct bls_builder *dcn401_non_seamless_commit_builder (void );const struct bls_builder *dcn401_seamless_update_builder (void ); +
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_init_builder.c +11 -5
@@ -19,7 +19,6 @@ enum dcn401_init_builder_stages {DCN401_INIT_BUILDER_STAGE1 ,DCN401_INIT_BUILDER_STAGE2 ,DCN401_INIT_BUILDER_DONE , -DCN401_INIT_BUILDER_STAGE_COUNT , }; static_assert(DCN401_INIT_BUILDER_DONE <= BLS_BUILDER_INIT_MAX_STAGE_COUNT,
@@ -507,11 +506,18 @@ static enum bls_builder_result dcn401_build_initialization(struct bls_builder_de params->head_num_steps =0 ; params->tail_num_steps =0 ; -if (initialization->stage >=DCN401_INIT_BUILDER_DONE ) +switch (initialization->stage) { +case DCN401_INIT_BUILDER_STAGE1 : { +enum bls_builder_result result =dcn401_build_stage1 (params); + +/* Stage 2 reads the DPM level counts stage 1 returns. */ +return result ==BLS_BUILD_SUCCESS ?BLS_BUILD_MORE_STAGES : result; + } +case DCN401_INIT_BUILDER_STAGE2 : +return dcn401_build_stage2 (params); +default :return BLS_BUILD_SUCCESS ; -if (initialization->stage ==DCN401_INIT_BUILDER_STAGE1 ) -return dcn401_build_stage1 (params); -return dcn401_build_stage2 (params); + } }const struct bls_builder *dcn401_initialization_builder (void )
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_init_builder_legacy.c +1 -1
@@ -177,7 +177,7 @@ static enum bls_builder_result dcn401_validate_dc1_hwseq(struct dc *dc)return BLS_BUILD_ERROR_RESOURCE_MAPPING ;if (!dc->debug.disable_clock_gate && !funcs->dcfclk_gating_control)return BLS_BUILD_ERROR_RESOURCE_MAPPING ; -if (!funcs->init_hpo_hw_control) +if (!funcs->setup_hpo_hw_control)return BLS_BUILD_ERROR_RESOURCE_MAPPING ;return BLS_BUILD_SUCCESS ;
drivers/gpu/drm/amd/display/dc/bls_executor/bls_executor.c +40 -2
72 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/core2/dc_core2.c +28 -15
67 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/core2/dc_core2.h +7 -0
@@ -9,6 +9,9 @@#include "inc/dc_core_interface.h" struct dc ; +struct bls_builder ; +struct block_sequence ; +struct workaround_manager ;struct dc_core2 {const struct dc2_funcs *legacy_funcs;
@@ -19,5 +22,9 @@ const struct dc2_funcs *core2_funcs(void);enum dc_status core2_commit_state_hw (struct dc *dc,struct dc_state *context);void core2_construct (struct dc *dc);void core2_destruct (struct dc *dc); +/* Applies workarounds to a built head sequence and executes it. */ +bool core2_run_sequence (struct dc *dc,const struct bls_builder *builder, +const struct workaround_manager *wam, +struct block_sequence *steps,unsigned int *num_steps);#endif /* DC_CORE2_H_ */
drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.c +33 -38
118 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/hubbub/dcn10/dcn10_hubbub.c +1 -0
@@ -923,6 +923,7 @@ static const struct hubbub_funcs hubbub1_funcs = { .is_allow_self_refresh_enabled = hubbub1_is_allow_self_refresh_enabled, .allow_self_refresh_control = hubbub1_allow_self_refresh_control, .verify_allow_pstate_change_high = hubbub1_verify_allow_pstate_change_high, + .global_timer_enable = dcn10_hubbub_global_timer_enable, }; void hubbub1_construct(struct hubbub *hubbub,
drivers/gpu/drm/amd/display/dc/hubbub/dcn20/dcn20_hubbub.c +1 -0
@@ -677,6 +677,7 @@ static const struct hubbub_funcs hubbub2_funcs = { .is_allow_self_refresh_enabled = hubbub1_is_allow_self_refresh_enabled, .allow_self_refresh_control = hubbub1_allow_self_refresh_control, .hubbub_read_state = hubbub2_read_state, + .global_timer_enable = dcn10_hubbub_global_timer_enable, }; void hubbub2_construct(struct dcn20_hubbub *hubbub,
drivers/gpu/drm/amd/display/dc/hubbub/dcn201/dcn201_hubbub.c +1 -0
@@ -87,6 +87,7 @@ static const struct hubbub_funcs hubbub201_funcs = { .get_dchub_ref_freq = hubbub2_get_dchub_ref_freq, .program_watermarks = hubbub201_program_watermarks, .hubbub_read_state = hubbub2_read_state, + .global_timer_enable = dcn10_hubbub_global_timer_enable, }; void hubbub201_construct(struct dcn20_hubbub *hubbub,
drivers/gpu/drm/amd/display/dc/hubbub/dcn21/dcn21_hubbub.c +1 -0
@@ -703,6 +703,7 @@ static const struct hubbub_funcs hubbub21_funcs = { .allow_self_refresh_control = hubbub1_allow_self_refresh_control, .apply_DEDCN21_147_wa = hubbub21_apply_DEDCN21_147_wa, .hubbub_read_state = hubbub2_read_state, + .global_timer_enable = dcn10_hubbub_global_timer_enable, }; void hubbub21_construct(struct dcn20_hubbub *hubbub,
drivers/gpu/drm/amd/display/dc/hubbub/dcn30/dcn30_hubbub.c +2 -1
@@ -469,7 +469,8 @@ static const struct hubbub_funcs hubbub30_funcs = { .force_pstate_change_control = hubbub3_force_pstate_change_control, .init_watermarks = hubbub3_init_watermarks, .hubbub_read_state = hubbub2_read_state, - .hubbub_read_reg_state = hubbub3_read_reg_state + .hubbub_read_reg_state = hubbub3_read_reg_state, + .global_timer_enable = dcn10_hubbub_global_timer_enable, }; void hubbub3_construct(struct dcn20_hubbub *hubbub3,
drivers/gpu/drm/amd/display/dc/hubbub/dcn301/dcn301_hubbub.c +1 -0
@@ -65,6 +65,7 @@ static const struct hubbub_funcs hubbub301_funcs = { .force_pstate_change_control = hubbub3_force_pstate_change_control, .init_watermarks = hubbub3_init_watermarks, .hubbub_read_state = hubbub2_read_state, + .global_timer_enable = dcn10_hubbub_global_timer_enable, }; void hubbub301_construct(struct dcn20_hubbub *hubbub3,
drivers/gpu/drm/amd/display/dc/hubbub/dcn31/dcn31_hubbub.c +2 -1
@@ -1072,7 +1072,8 @@ static const struct hubbub_funcs hubbub31_funcs = { .init_crb = dcn31_init_crb, .hubbub_read_state = hubbub2_read_state, .hubbub_read_reg_state = hubbub3_read_reg_state, - .dchvm_init = dcn21_dchvm_init + .dchvm_init = dcn21_dchvm_init, + .global_timer_enable = dcn10_hubbub_global_timer_enable, }; void hubbub31_construct(struct dcn20_hubbub *hubbub31,
drivers/gpu/drm/amd/display/dc/hubbub/dcn32/dcn32_hubbub.c +2 -1
@@ -1036,7 +1036,8 @@ static const struct hubbub_funcs hubbub32_funcs = { .force_usr_retraining_allow = hubbub32_force_usr_retraining_allow, .set_request_limit = hubbub32_set_request_limit, .get_mall_en = hubbub32_get_mall_en, - .hubbub_read_reg_state = hubbub3_read_reg_state + .hubbub_read_reg_state = hubbub3_read_reg_state, + .global_timer_enable = dcn10_hubbub_global_timer_enable, }; void hubbub32_construct(struct dcn20_hubbub *hubbub2,
drivers/gpu/drm/amd/display/dc/hubbub/dcn35/dcn35_hubbub.c +2 -1
@@ -643,7 +643,8 @@ static const struct hubbub_funcs hubbub35_funcs = { .force_usr_retraining_allow = hubbub32_force_usr_retraining_allow, .dchubbub_init = hubbub35_init, .hubbub_read_reg_state = hubbub3_read_reg_state, - .dchvm_init = dcn35_dchvm_init + .dchvm_init = dcn35_dchvm_init, + .global_timer_enable = dcn10_hubbub_global_timer_enable, }; void hubbub35_construct(struct dcn20_hubbub *hubbub2,
drivers/gpu/drm/amd/display/dc/hubbub/dcn401/dcn401_hubbub.c +2 -1
@@ -1255,7 +1255,8 @@ static const struct hubbub_funcs hubbub4_01_funcs = { .wait_for_det_update = dcn401_wait_for_det_update, .program_arbiter = dcn401_program_arbiter, .hubbub_read_reg_state = hubbub3_read_reg_state, - .get_mall_en = hubbub32_get_mall_en + .get_mall_en = hubbub32_get_mall_en, + .global_timer_enable = dcn10_hubbub_global_timer_enable, }; void hubbub401_construct(struct dcn20_hubbub *hubbub2,
drivers/gpu/drm/amd/display/dc/hubbub/dcn42/dcn42_hubbub.c +2 -1
@@ -554,7 +554,8 @@ static const struct hubbub_funcs hubbub42_funcs = { .program_compbuf_segments = dcn401_program_compbuf_segments, .wait_for_det_update = dcn401_wait_for_det_update, .program_arbiter = dcn42_program_arbiter, - .hubbub_read_reg_state = hubbub3_read_reg_state + .hubbub_read_reg_state = hubbub3_read_reg_state, + .global_timer_enable = dcn10_hubbub_global_timer_enable, }; void hubbub42_construct(struct dcn20_hubbub *hubbub2,
drivers/gpu/drm/amd/display/dc/hubbub/dcn60/dcn60_hubbub.c +1 -0
@@ -2060,6 +2060,7 @@ static const struct hubbub_funcs hubbub60_funcs = { hubbub60_reset_display_qos_profile, }, .set_sdpif_port_control = hubbub60_set_sdpif_port_control, + .global_timer_enable = dcn10_hubbub_global_timer_enable, }; void hubbub60_construct(struct dcn20_hubbub *hubbub2,
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_init.c +1 -1
@@ -151,7 +151,7 @@ static const struct hwseq_private_funcs dcn401_private_funcs = { .plane_atomic_power_down = dcn401_plane_atomic_power_down, .plane_atomic_power_down_sequence = dcn401_plane_atomic_power_down_sequence, .enable_power_gating_plane = dcn32_enable_power_gating_plane, - .init_hpo_hw_control = dcn401_setup_hpo_hw_control, + .setup_hpo_hw_control = dcn401_setup_hpo_hw_control, .init_odm_mem_power = dcn401_init_odm_mem_power, .power_down_vga_mem = dcn401_power_down_vga_mem, .dcfclk_gating_control = dcn401_dcfclk_gating_control,
drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h +29 -0
@@ -309,6 +309,25 @@ struct hubbub_init_crb_params {struct hubbub *hubbub; }; +struct hubbub_init_params { +struct hubbub *hubbub; +}; + +struct hubbub_global_timer_enable_params { +struct hubbub *hubbub; +bool enable; +uint32_t refdiv; +}; + +struct mpc_init_params { +struct mpc *mpc; +}; + +struct fpga_set_clk_params { +struct dc_context *ctx; +int freq_khz; +}; +struct hubbub_set_request_limit_params {struct hubbub *hubbub;unsigned int num_chans;
@@ -1668,6 +1687,10 @@ union block_sequence_params { dccg_set_root_clock_gating_params;struct hubbub_init_watermarks_params hubbub_init_watermarks_params;struct hubbub_init_crb_params hubbub_init_crb_params; +struct hubbub_init_params hubbub_init_params; +struct hubbub_global_timer_enable_params hubbub_global_timer_enable_params; +struct mpc_init_params mpc_init_params; +struct fpga_set_clk_params fpga_set_clk_params;struct hubbub_set_request_limit_params hubbub_set_request_limit_params;struct clk_mgr_initialize_min_clocks_params clk_mgr_initialize_min_clocks_params;
@@ -1973,6 +1996,12 @@ enum block_sequence_func {TG_DELAY_CURSOR_UNTIL_VUPDATE ,MPC_CURSOR_LOCK ,DMUB_HW_LOCK_MGR_CMD , +HUBBUB_INIT , +HUBBUB_GLOBAL_TIMER_ENABLE , +MPC_INIT , +FPGA_SET_DTBCLK , +FPGA_SET_DPREFCLK , +FPGA_SET_REFCLK ,/* This must be the last value in this enum, add new ones above */ HWSS_BLOCK_SEQUENCE_FUNC_COUNT };
drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer_private.h +0 -5
@@ -207,11 +207,6 @@ struct hwseq_private_funcs {void (*PLAT_58856_wa)(struct dc_state *context,struct pipe_ctx *pipe_ctx);void (*setup_hpo_hw_control)(const struct dce_hwseq *hws,bool enable); -/* -* Init-time only. setup_hpo_hw_control also drives the HPO toggle -* on every commit, so a DCN that leaves it unset keeps it unset. -*/ -void (*init_hpo_hw_control)(const struct dce_hwseq *hws,bool enable);void (*init_odm_mem_power)(struct dce_hwseq *hws);void (*power_down_vga_mem)(struct dce_hwseq *hws);void (*dcfclk_gating_control)(struct dce_hwseq *hws,bool enable);
drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h +1 -0
@@ -272,6 +272,7 @@ struct hubbub_funcs {void (*force_usr_retraining_allow)(struct hubbub *hubbub,bool allow);void (*set_request_limit)(struct hubbub *hubbub,int memory_channel_count,int words_per_channel);void (*dchubbub_init)(struct hubbub *hubbub); +void (*global_timer_enable)(struct hubbub *hubbub,bool enable,uint32_t refdiv);void (*get_mall_en)(struct hubbub *hubbub,unsigned int *mall_in_use);void (*program_det_segments)(struct hubbub *hubbub,int hubp_inst,unsigned det_buffer_size_seg);void (*program_compbuf_segments)(struct hubbub *hubbub,unsigned compbuf_size_seg,bool safe_to_increase);
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH v2 11/30] drm/amd/display: Add pipe init to core2
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] drm/amd/display: dcn401_private_funcs re-enables commit HPO toggle - [Medium] drm/amd/display…
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [Medium] drm/amd/display: dcn401_private_funcs re-enables commit HPO toggle
- [Medium] drm/amd/display: incomplete NULL dmub_srv handling in core2 wrapped init
- [Low] drm/amd/display: unimplemented FPGA_SET_* block sequence opcodes --
commit 1b7331c47125a1ce9d6e5eaf45bf45e4636568b5
Author: Tomasz Siemek <[email protected]>
drm/amd/display: Add pipe init to core2
This commit adds pipe state initialization and a stage-based build-and-run loop to core2 hardware initialization, adds HUBBUB and MPC init block sequence steps, and renames init_hpo_hw_control to setup_hpo_hw_control.
[ ... ]
Quoted 5 lines
drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.c +0
-0
drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.c static void core2_resolve_dmub_abi(struct dc *dc, · line 53
Quoted 9 lines
drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.c +2
-1@@ -45,7 +46,8 @@ static void core2_resolve_dmub_abi(struct dc *dc, dc2->dmub_abi = initialization->dmub_abi; dc2->dmub_abi_resolved = true; - dc->ctx->dmub_srv->dmub->feature_caps = initialization->dmub_abi.feature_caps; +if (dc->ctx->dmub_srv && dc->ctx->dmub_srv->dmub) + dc->ctx->dmub_srv->dmub->feature_caps = initialization->dmub_abi.feature_caps; dc->caps.dmub_caps.psr = initialization->dmub_abi.feature_caps.psr; dc->caps.dmub_caps.mclk_sw = initialization->dmub_abi.feature_caps.fw_assisted_mclk_switch_ver >0 ; dc->caps.dmub_caps.fams_ver = initialization->dmub_abi.feature_caps.fw_assisted_mclk_switch_ver;
[Severity: Medium]
Can core2_run_wrapped_hardware_init() reach core2_resolve_dmub_abi() or core2_init_pipe_state() when dc->ctx->dmub_srv or dc->ctx->dmub_srv->dmub is NULL?
Earlier in core2_run_wrapped_hardware_init(), dcn401_build_stage1() unconditionally emits DMUB_SEND_DMCUB_CMD2 steps that dc2_bls_step_supported() rejects when ctx->dmub_srv or ctx->dmub_srv->dmub is NULL, causing core2_run_sequence() to fail and abort initialization on stage 1. In addition, stage 2 postprocessing in dcn401_fill_initialization_output() unconditionally dereferences params->dc->ctx->dmub_srv->dmub->fw_version before core2_resolve_dmub_abi() is called.
[ ... ]
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_init.c static const struct hwseq_private_funcs dcn401_private_funcs = { · line 157
Quoted 13 lines
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_init.c +1
-1@@ -151,7 +151,7 @@ static const struct hwseq_private_funcs dcn401_private_funcs = { .plane_atomic_power_down = dcn401_plane_atomic_power_down, .plane_atomic_power_down_sequence = dcn401_plane_atomic_power_down_sequence, .enable_power_gating_plane = dcn32_enable_power_gating_plane, - .init_hpo_hw_control = dcn401_setup_hpo_hw_control, + .setup_hpo_hw_control = dcn401_setup_hpo_hw_control, .init_odm_mem_power = dcn401_init_odm_mem_power, .power_down_vga_mem = dcn401_power_down_vga_mem, .dcfclk_gating_control = dcn401_dcfclk_gating_control,
[Severity: Medium]
Does wiring dcn401_setup_hpo_hw_control into setup_hpo_hw_control instead of the init-only init_hpo_hw_control hook cause dce110_apply_ctx_to_hw() to disable HPO_IO_EN on DCN 4.01 commits?
On DCN 4.01, apply_ctx_to_hw uses dce110_apply_ctx_to_hw(), which calls dc->hwseq->funcs.setup_hpo_hw_control(dc->hwseq, is_hpo_acquired) whenever a commit transitions between HPO and non-HPO streams:
drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c:dce110_apply_ctx_to_hw() {
...
if (dc->hwseq->funcs.setup_hpo_hw_control && was_hpo_acquired != is_hpo_acquired) {
dc->hwseq->funcs.setup_hpo_hw_control(dc->hwseq, is_hpo_acquired);
}
...
}Commit a4758aa3d1d9 ("drm/amd/display: Always enable HPO for DCN4 dGPU") removed setup_hpo_hw_control from dcn401_private_funcs because disabling HPO on DCN4 dGPUs breaks DP EDID CTS tests. Once HPO_IO_EN is cleared by a DC1 commit, neither dp_retrain_link_dp_test() (which checks dc->hwss.setup_hpo_hw_control, left NULL in dcn401_funcs) nor DC2 commits via dcn401_non_seamless_builder re-enable it.
Quoted 4 lines
drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h +0
-0
[ ... ]
drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h enum block_sequence_func { · line 2007
Quoted 13 lines
drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h +6
-0@@ -1973,6 +1996,12 @@ enum block_sequence_func {TG_DELAY_CURSOR_UNTIL_VUPDATE ,MPC_CURSOR_LOCK ,DMUB_HW_LOCK_MGR_CMD , +HUBBUB_INIT , +HUBBUB_GLOBAL_TIMER_ENABLE , +MPC_INIT , +FPGA_SET_DTBCLK , +FPGA_SET_DPREFCLK , +FPGA_SET_REFCLK ,/* This must be the last value in this enum, add new ones above */ HWSS_BLOCK_SEQUENCE_FUNC_COUNT };
[Severity: Low]
Are FPGA_SET_DTBCLK, FPGA_SET_DPREFCLK, FPGA_SET_REFCLK, struct fpga_set_clk_params, and the dm_helpers.h include in bls_executor.c left over from another change? None of these opcodes are handled in dc2_bls_step_supported() or dc2_bls_execute(), and adding them to enum block_sequence_func increases MAX_HWSS_BLOCK_SEQUENCE_SIZE.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=11
PATCH v2 12/30 drm/amd/display: Fix HDMI FRL no_timeout behavior
In reply to George ZhangFrom: Ilya Bakoulin <[email protected]>
[Why/How]
Addresses a couple issues encountered while running compliance tests that assert the no_timeout flag:
- Handle a couple of additional cases where link rate is not updated properly during a no_timeout test sequence due to the link not being cycled on/off
- Increase polling rate while no_timeout is asserted to ensure we respond to updates in a reasonable amount of time (<10ms)
--- .../drm/amd/display/dc/link/link_dpms_v1.c | 1 + .../display/dc/link/protocols/link_hdmi_frl.c | 25 +++++++++++++------ .../display/dc/link/protocols/link_hdmi_frl.h | 1 + 3 files changed, 19 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/display/dc/link/link_dpms_v1.c +1 -0
@@ -2068,6 +2068,7 @@ static enum dc_status enable_link_hdmi_frl(struct pipe_ctx *pipe_ctx) frl_phy_clock_source_id =hdmi_frl_find_matching_phypll (stream->link);FRL_INFO ("FRL LINK TRAINING: LTS:P Start\n" ); +hdmi_frl_cycle_link_on_no_timeout_rate_change (stream->link);/* Setup FRL PHY, enable HDMI character clock and HPO link encoder */ core_dc->hwss.setup_hdmi_frl_link(stream->link, (pipe_ctx->stream_res.hpo_frl_stream_enc->id - ENGINE_ID_HPO_0),
drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c +17 -8
@@ -781,6 +781,20 @@ static enum link_result hdmi_frl_perform_link_training(struct ddc_service *ddc_sreturn result; } +/* disable_link_output is a no-op while in FLT_no_timeout mode, so if the FRL +* rate changed since the no_timeout training, cycle the link off here so that +* the subsequent PHY setup properly applies the new link rate. +*/ +void hdmi_frl_cycle_link_on_no_timeout_rate_change (struct dc_link *link) +{ +if (!link->frl_flags.no_timeout || + link->frl_flags.no_timeout_frl_link_rate == link->frl_link_settings.frl_link_rate) +return ; + + link->hpo_frl_link_enc->funcs->disable_link_encoder (link->hpo_frl_link_enc); + link->link_enc->funcs->disable_output (link->link_enc,SIGNAL_TYPE_HDMI_FRL ); +} +enum link_result hdmi_frl_perform_link_training_with_retries (struct dc_link *link) {
@@ -836,14 +850,7 @@ enum link_result hdmi_frl_perform_link_training_with_fallback(msleep (200 ); -/* If we're in a NO_TIMEOUT state and link rate changes, cycle the link on/off -* so that the new link rate is properly applied */ -if (link->frl_flags.no_timeout) { -if (link->frl_flags.no_timeout_frl_link_rate != link->frl_link_settings.frl_link_rate) { - link->hpo_frl_link_enc->funcs->disable_link_encoder (link->hpo_frl_link_enc); - link->link_enc->funcs->disable_output (link->link_enc,SIGNAL_TYPE_HDMI_FRL ); - } - } +hdmi_frl_cycle_link_on_no_timeout_rate_change (link); link->ctx->dc->hwss.setup_hdmi_frl_link (link,0 , frl_phy_clock_source_id);
@@ -1108,6 +1115,8 @@ void hdmi_frl_set_preferred_link_settings(struct dc *dc,/* Find proper clock source in HDMI FRL mode for phy used for DCCG */ frl_phy_clock_source_id =hdmi_frl_find_matching_phypll (link); +hdmi_frl_cycle_link_on_no_timeout_rate_change (link); + dc->hwss.setup_hdmi_frl_link (link, (pipe->stream_res.hpo_frl_stream_enc->id -ENGINE_ID_HPO_0 ), frl_phy_clock_source_id);
drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.h +1 -0
@@ -31,6 +31,7 @@ void hdmi_frl_LTS_clear_Update_flag(struct ddc_service *ddc_service);void hdmi_frl_poll_start (struct ddc_service *ddc_service);void hdmi_frl_LTS_clear_Link_Setting (struct ddc_service *ddc_service);void hdmi_frl_retrieve_link_cap (struct dc_link *link,struct dc_sink *sink); +void hdmi_frl_cycle_link_on_no_timeout_rate_change (struct dc_link *link);enum link_result hdmi_frl_perform_link_training_with_retries (struct dc_link *link); enum link_result hdmi_frl_perform_link_training_with_fallback(
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH v2 12/30] drm/amd/display: Fix HDMI FRL no_timeout behavior
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] drm/amd/display: missing no_timeout polling rate increase claimed in changelog - [Low]…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] drm/amd/display: missing no_timeout polling rate increase claimed in changelog
- [Low] drm/amd/display: missing Fixes trailer for commit c8d099259904 --
commit c6127408b449b7b1a69c9edf832e893b8033ab7e
Author: Ilya Bakoulin <[email protected]>
Quoted 11 lines
drm/amd/display: Fix HDMI FRL
no_timeoutbehavior[Why/How]
Addresses a couple issues encountered while running compliance tests that assert theno_timeoutflag:
- Handle a couple of additional cases where link rate is not updated properly during ano_timeouttest sequence due to the link not being cycled on/off
- Increase polling rate whileno_timeoutis asserted to ensure we respond to updates in a reasonable amount of time (<10ms)
Quoted 3 lines
Cc Chris Park <[email protected]>Signed-off-by Ilya Bakoulin <[email protected]>Signed-off-by George Zhang <[email protected]>
[Severity: Low]
Commit c8d099259904 ("drm/amd/display: Fix FFE test automation link rate change") added the no_timeout link-cycling logic in hdmi_frl_perform_link_training_with_fallback() but missed enable_link_hdmi_frl() and hdmi_frl_set_preferred_link_settings(). Should this include a Fixes: tag?
Quoted 11 lines
drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c +3
-0@@ -781,6 +781,20 @@ static enum link_result hdmi_frl_perform_link_training(struct ddc_service *ddc_sreturn result; } +/* disable_link_output is a no-op while in FLT_no_timeout mode, so if the FRL +* rate changed since the no_timeout training, cycle the link off here so that +* the subsequent PHY setup properly applies the new link rate.
drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c static enum link_result hdmi_frl_perform_link_training(struct ddc_service *ddc_s · line 796
Quoted 10 lines
drivers/gpu/drm/amd/display/dc/link/protocols/link_hdmi_frl.c +10
-0+*/ +void hdmi_frl_cycle_link_on_no_timeout_rate_change (struct dc_link *link) +{ +if (!link->frl_flags.no_timeout || + link->frl_flags.no_timeout_frl_link_rate == link->frl_link_settings.frl_link_rate) +return ; + + link->hpo_frl_link_enc->funcs->disable_link_encoder (link->hpo_frl_link_enc); + link->link_enc->funcs->disable_output (link->link_enc,SIGNAL_TYPE_HDMI_FRL ); +}
[Severity: Medium]
Was the polling rate change mentioned in the commit message omitted from this patch?
The commit message says this patch increases the polling rate while no_timeout is asserted to respond in under 10ms, but the diff only extracts and calls hdmi_frl_cycle_link_on_no_timeout_rate_change(). hdmi_frl_status_polling_work() in amdgpu_dm_connector.c still schedules dm->hdmi_frl_status_polling_work with the fixed 200ms dm->hdmi_frl_status_polling_delay_ms interval when link->frl_flags.no_timeout is true.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=12
PATCH v2 13/30 drm/amd/display: Re-enable HUBP/DPP Driver PG on DCN42
In reply to George ZhangFrom: Leo Chen <[email protected]>
[Why & How]
Power regression is resolved, disabling the HUBP/DPP driver PG is no longer needed as a workaround. Re-enabling HUBP/DPP driver PG on DCN42.
--- .../gpu/drm/amd/display/dc/resource/dcn42/dcn42_resource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/resource/dcn42/dcn42_resource.c +2 -2
@@ -745,8 +745,8 @@ static const struct dc_debug_options debug_defaults_drv = { .clock_trace = true, .disable_pplib_clock_request = false, .ignore_pg = false, - .disable_dpp_power_gate = true, - .disable_hubp_power_gate = true, + .disable_dpp_power_gate = false, + .disable_hubp_power_gate = false, .disable_optc_power_gate = true, .disable_dsc_power_gate = false, .disable_dio_power_gate = true,
Signature · 1 line
2.56.1
PATCH v2 14/30 drm/amd/display: Program DSC on one stream in DC2
In reply to George ZhangFrom: Tony Cheng <[email protected]>
[Why]
The DC2 commit on dcn401 rejects every stream with DSC. A DSC display falls back to the error path.
[How]
Accept a stream with DSC when each OPP head has a DSC and the pixel clock is above 48 MHz. At 48 MHz or less, DC1 keeps DSCCLK on the reference clock, and the commit does not emit that path. A stream without DSC must have no DSC on its OPP heads. Split the timing flag check into one check for interlace and one check for stereo.
The commit programs DSC as link_set_dsc_on_stream does, after the OTG output mux and before the link enable. For each OPP head it sets the DSCCLK DTO, the DSC config and the DSC enable. Then it sets the OPTC DSC config on the OTG master. The front end programs DSC again after the OPP format, as dcn32_update_dsc_on_stream does from dcn401_update_odm. The stream off disables the OPTC DSC config after the link disable. Then, for each OPP head, it disconnects and disables the DSC and sets DSCCLK to the reference clock.
The update programs DSC again when it adds a plane, with the same skip conditions as the OPP ODM steps. A new no_dsc skip condition removes the DSC steps from a pipe without DSC. The update rejects an ODM change on a kept DSC stream, because it does not disable the DSC of a dropped slice.
The builder prepares the DSC config with hwss_prepare_dsc_config_for_pipe. It does not emit the DSC read state. The DC2 Executor gets the cases for the seven DSC funcs.
--- .../bls_builder/bls_builder_private_types.h | 4 + .../bls_builder/dcn401_non_seamless_builder.c | 56 +++++ .../dc/bls_builder/dcn401_seamless_builder.c | 203 ++++++++++++++---- .../display/dc/bls_executor/bls_executor.c | 74 +++++++ 4 files changed, 299 insertions(+), 38 deletions(-)
drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_private_types.h +4 -0
@@ -121,6 +121,9 @@ struct dcn401_commit_step_meta {struct {bool connect; } link_enc_connect_dig_be_to_fe; +struct { +bool enable; + } tg_set_dsc_config;struct {bool enable; } dc_ip_request_cntl;
@@ -136,6 +139,7 @@ struct dcn401_commit_step_meta {bool no_manual_trigger;/* The OPP MPC tree has no plane yet. */ bool opp_tree_empty; +bool no_dsc;struct dcn401_pipe_deltas pipe_deltas;/* * Skip only when each delta named in pipe_deltas is true. Clear,
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c +56 -0
104 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +165 -38
289 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/bls_executor/bls_executor.c +74 -0
92 lines not on this page · raw message
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH v2 14/30] drm/amd/display: Program DSC on one stream in DC2
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] drm/amd/display: partial DSC sequence on config failure in dcn401_add_step() - [Medium]…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] drm/amd/display: partial DSC sequence on config failure in dcn401_add_step()
- [Medium] drm/amd/display: missing DSC resource check on kept streams in DC2 builder
--
commit b1940a96d693c6dd5b7ea3ce521afe04d2fe9fac
Author: Tony Cheng <[email protected]>
drm/amd/display: Program DSC on one stream in DC2
This commit adds DSC programming and state checks to the DCN401 DC2 non-seamless and seamless block sequence builders and executor.
Quoted 4 lines
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +0
-0
[ ... ]
Quoted 30 lines
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +26
-0@@ -921,6 +944,43 @@ static bool check_no_cursor(const struct dc *dc,return !new_state->streams[i]->cursor_attributes.address.quad_part; } +static bool dcn401_same_opp_heads (const struct dc_state *current_state, +const struct dc_state *new_state, +const struct dc_stream_state *stream) +{ +const struct pipe_ctx *cur =dcn401_otg_master (current_state, stream); +const struct pipe_ctx *new =dcn401_otg_master (new_state, stream); +struct pipe_ctx *cur_heads[MAX_PIPES ], *new_heads[MAX_PIPES ]; +int i, n; + +if (!cur || !new) +return false; + n =resource_get_opp_heads_for_otg_master (cur, + (struct resource_context *)¤t_state->res_ctx, + cur_heads); +if (n !=resource_get_opp_heads_for_otg_master (new, + (struct resource_context *)&new_state->res_ctx, + new_heads)) +return false; +for (i =0 ; i < n; i++) +if (!cur_heads[i]->stream_res.opp || + !new_heads[i]->stream_res.opp || + cur_heads[i]->stream_res.opp->inst != + new_heads[i]->stream_res.opp->inst) +return false; +return true; +}
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c static bool check_no_cursor(const struct dc *dc, · line 982
Quoted 10 lines
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +10
-0+ +static bool check_dsc_odm_kept (const struct dc *dc, +const struct dc_state *current_state, +const struct dc_state *new_state,unsigned int i) +{ + (void )dc; +return !new_state->streams[i]->timing.flags.DSC || +dcn401_same_opp_heads (current_state, new_state, + new_state->streams[i]); +}
[Severity: Medium]
Can a kept stream change its DSC instance or drop DSC without the update programming the new DSC block or disabling the old one?
dcn401_same_opp_heads(), dcn401_pipe_layout_unchanged(), and dcn401_eval_pipe_deltas() compare stream_res.opp->inst without checking DCN401_SAME_INST(cur->stream_res.dsc, new->stream_res.dsc), and check_dsc_odm_kept() only inspects new_state->streams[i]->timing.flags.DSC. For example, if the top plane of a two-plane MPC-blended DSC stream is removed so the bottom pipe becomes the OTG master on the same OTG and OPP with a different stream_res.dsc instance, deltas.hubp_dpp_already_enabled and deltas.odm_kept are both true, so bls_stream_update skips dsc[] and optc_dsc[] and never disconnects the old DSC or enables the new one.
[ ... ]
Quoted 19 lines
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +15
-0@@ -1848,6 +1945,22 @@ static void dcn401_odm_combine_params(struct pipe_ctx *otg_master, true); } +static void dcn401_dsc_config_params (struct pipe_ctx *otg_master, +bool enable,struct tg_set_dsc_config_params *p) +{ +struct dsc_optc_config optc; + + p->tg = otg_master->stream_res.tg; + p->dsc_mode =OPTC_DSC_DISABLED ; +if (!enable || !hwss_prepare_dsc_config_for_pipe (otg_master, +resource_get_odm_slice_count (otg_master),0 , &optc)) +return ; + p->dsc_mode = optc.is_pixel_format_444 ?OPTC_DSC_ENABLED_444 : +OPTC_DSC_ENABLED_NATIVE_SUBSAMPLED ; + p->bytes_per_pixel = optc.bytes_per_pixel; + p->slice_width = optc.slice_width; +}
[ ... ]
Quoted 17 lines
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +13
-0@@ -2200,6 +2313,39 @@ static void dcn401_add_step(struct block_sequence_state *sequence, p->opp_program_left_edge_extra_pixel_params.is_otg_master = !pipe->prev_odm_pipe;break ; +case DCCG_SET_DTO_DSCCLK : + p->dccg_set_dto_dscclk_params.dccg = dc->res_pool->dccg; + p->dccg_set_dto_dscclk_params.inst = pipe->stream_res.dsc->inst; + p->dccg_set_dto_dscclk_params.num_slices_h = + pipe->stream->timing.dsc_cfg.num_slices_h / +resource_get_odm_slice_count (pipe); +break ; +case DSC_SET_CONFIG : +if (!hwss_prepare_dsc_config_for_pipe (pipe, +resource_get_odm_slice_count (pipe),0 ,NULL )) { + (*sequence->num_steps)--; +return ; + }
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c static void dcn401_add_step(struct block_sequence_state *sequence, · line 2338
Quoted 10 lines
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +10
-0+ p->dsc_set_config_params.dsc = pipe->stream_res.dsc; +break ; +case DSC_ENABLE : + p->dsc_enable_params.dsc = pipe->stream_res.dsc; + p->dsc_enable_params.opp_inst = pipe->stream_res.opp->inst; +break ; +case TG_SET_DSC_CONFIG : +dcn401_dsc_config_params (pipe, m->tg_set_dsc_config.enable, + &p->tg_set_dsc_config_params); +break ;
[Severity: Medium]
Does a failure in hwss_prepare_dsc_config_for_pipe() emit a partial DSC sequence instead of aborting execution?
When hwss_prepare_dsc_config_for_pipe() fails in the DSC_SET_CONFIG case, decrementing *sequence->num_steps removes DSC_SET_CONFIG from the sequence (bypassing dc2_bls_step_supported()), while DCCG_SET_DTO_DSCCLK and DSC_ENABLE are still emitted and dcn401_dsc_config_params() populates p->tg with p->dsc_mode = OPTC_DSC_DISABLED. Executing that sequence enables DSC forwarding on the OPP head into an unconfigured DSC block while disabling DSC in OPTC, corrupting or hanging display output.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=14
PATCH v2 15/30 drm/amd/display: enable dcn42b hubp/dpp pg control from driver side
In reply to George ZhangFrom: Charlene Liu <[email protected]>
[why]
dcn42/dcn42b sharing same dmubfw source from same branch. driver side needs also in sync:
dcn42 re-enabled hubp/dpp pg, dcn42b needs update as well.
--- .../gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.c +2 -2
@@ -803,8 +803,8 @@ static const struct dc_debug_options debug_defaults_drv = { .clock_trace = true, .disable_pplib_clock_request = false, .ignore_pg = false, - .disable_dpp_power_gate = true, - .disable_hubp_power_gate = true, + .disable_dpp_power_gate = false, + .disable_hubp_power_gate = false, .disable_optc_power_gate = true, .disable_dsc_power_gate = false, .disable_dio_power_gate = true,
Signature · 1 line
2.56.1
PATCH v2 16/30 drm/amd/display: cover gamma 2.4 and 2.6 on the wide curve
In reply to George ZhangFrom: Harry Wentland <[email protected]>
cm3_helper_translate_curve_to_hw_format() puts PQ, gamma 2.2, and HLG on 32 regions from 2^-25 to 2^7. Gamma 2.4 and 2.6 used the other layout, 12 regions from 2^-12 to 2^0.
cm_helper_translate_curve_to_hw_format() has the same split, for PQ and gamma 2.2 only. DCN 2.0, 2.01, 2.1, 3.0, 3.01, 3.1, and 3.14 program the plane shaper through dcn20_set_shaper_3dlut(), which calls that helper. The same helper also programs stream output regamma on DCN 1.0, output gamma and the blend LUT on DCN 2.x, the DCN 3.0 writeback (DWB) path, and the stream shaper on DCN 3.0 and 3.2.
The inverse curve is the shaper, and its input is linear light from degamma. A 10-bit code v becomes (v/1023)^g. That is below 2^-12 for v = 1..31 at gamma 2.4 and v = 1..41 at gamma 2.6, so those codes come back as 0. On a gray ramp the round trip then misses the IGT bracket of 13. Gamma 2.4 needs a bracket of 33 and gamma 2.6 needs 41. Gamma 2.2 already uses the wide curve and its round trip is exact.
Use the 32-region curve for gamma 2.4 and 2.6 in both helpers. Its low end is 2^-25, which covers those dark codes. On DCN 4.0.1 the gamma 2.4 round trip is exact and gamma 2.6 is off by one 10-bit code, so the original bracket of 13 passes. Only the DCN 4.0.1 plane shaper path was tested; the DCN 1.x, 2.x and 3.x paths listed above were not.
--- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c | 4 +++- drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_cm_common.c +3 -1
@@ -355,7 +355,9 @@ bool cm_helper_translate_curve_to_hw_format(struct dc_context *ctx,memset (lut_params,0 ,sizeof (struct pwl_params ));memset (seg_distr,0 ,sizeof (seg_distr)); -if (output_tf->tf ==TRANSFER_FUNCTION_PQ || output_tf->tf ==TRANSFER_FUNCTION_GAMMA22 ) { +if (output_tf->tf ==TRANSFER_FUNCTION_PQ || output_tf->tf ==TRANSFER_FUNCTION_GAMMA22 || + output_tf->tf ==TRANSFER_FUNCTION_GAMMA24 || + output_tf->tf ==TRANSFER_FUNCTION_GAMMA26 ) {/* 32 segments * segments are from 2^-25 to 2^7 */
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c +2 -0
@@ -133,6 +133,8 @@ bool cm3_helper_translate_curve_to_hw_format(struct dc_context *ctx,memset (seg_distr,0 ,sizeof (seg_distr));if (output_tf->tf ==TRANSFER_FUNCTION_PQ || output_tf->tf ==TRANSFER_FUNCTION_GAMMA22 || + output_tf->tf ==TRANSFER_FUNCTION_GAMMA24 || + output_tf->tf ==TRANSFER_FUNCTION_GAMMA26 || output_tf->tf ==TRANSFER_FUNCTION_HLG ) {/* 32 segments * segments are from 2^-25 to 2^7
Signature · 1 line
2.56.1
PATCH v2 17/30 drm/amd/display: Revoke alternate channel P-State before pipe teardown
In reply to George ZhangFrom: Ivan Lipski <[email protected]>
[Why]
A modeset after stress testing can hang PMFW. The hang only happens when alternate channel P-State switching is in use.
Alternate channel P-State permission was sequenced the opposite way to UCLK/FCLK P-State: it could be enabled during prepare_bandwidth, before the new configuration was programmed, and was only disabled during optimize_bandwidth, after the old configuration had been torn down. PMFW could therefore start an alternate channel switch that depended on a display being disabled and never complete it.
The IndicatePstateStatus messages also did not follow the computed action. With no active planes, prepare_bandwidth decided to revoke UCLK/FCLK P-State but still told PMFW they were allowed, and the enable message could briefly re-allow a state the action was revoking.
[How]
Only allow alternate channel P-State when it is safe to lower, and revoke it as soon as the new state does not support it.
Only treat zero active planes as UCLK/FCLK P-State support when it is safe to lower, so prepare_bandwidth never grants it for a config that has not been programmed yet.
Derive allow_uclk, allow_fclk and alt_ch_enable once from the action and the current clocks. The IndicatePstateStatus messages no longer recount the active planes to allow UCLK/FCLK P-State on their own; the zero plane case is decided only by the action.
--- .../display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c +19 -16
@@ -1211,10 +1211,10 @@ static void dcn60_make_bandwidth_clocks_update_action(bool dcfclk_dpm_enabled =dcn60_is_ppclk_dpm_enabled (clk_mgr_internal,PPCLK_DCFCLK );bool uclk_pstate_supported = new_clocks->p_state_change_support - || (total_plane_count ==0 ); + || (total_plane_count ==0 && safe_to_lower);bool fclk_pstate_supported = new_clocks->fclk_p_state_change_support - || (total_plane_count ==0 ); + || (total_plane_count ==0 && safe_to_lower);memset (action,0 ,sizeof (*action));/* clock actions */
@@ -1282,9 +1282,10 @@ static void dcn60_make_bandwidth_clocks_update_action( }if (new_clocks->alt_ch_pstate_switch != clk_mgr_base->clks.alt_ch_pstate_switch) { - action->alt_ch.enable = new_clocks->alt_ch_pstate_switch; - action->alt_ch.disable = !new_clocks->alt_ch_pstate_switch +/* PMFW hangs if alt-ch is still allowed while pipes are torn down */ + action->alt_ch.enable = new_clocks->alt_ch_pstate_switch && safe_to_lower; + action->alt_ch.disable = !new_clocks->alt_ch_pstate_switch; action->alt_ch.send_message = action->alt_ch.enable || action->alt_ch.disable; }
@@ -1296,7 +1297,6 @@ static void dcn60_make_bandwidth_clocks_update_action(* @block_sequence: output array of block sequence steps * @action: action struct populated by dcn60_make_bandwidth_clocks_update_action * @clk_mgr_base: current clock manager state (read-only, used for original values) -* @context: dc state with active plane information * @new_clocks: requested clock values for message parameters * * Return: number of steps written to block_sequence
@@ -1305,11 +1305,16 @@ static unsigned int dcn60_build_bandwidth_clocks_block_sequence_with_action(struct dcn60_clk_mgr_block_sequence *block_sequence, struct dcn60_bandwidth_clocks_update_action *action, struct clk_mgr *clk_mgr_base, - struct dc_state *context, struct dc_clocks *new_clocks) { unsigned int num_steps = 0; -bool no_active_planes =clk_mgr_helper_get_active_plane_cnt (clk_mgr_base->ctx->dc, context) ==0 ; +const struct dc_clocks *cur = &clk_mgr_base->clks; +bool allow_uclk = action->uclk_pstate.enable + || (!action->uclk_pstate.disable && cur->p_state_change_support); +bool allow_fclk = action->fclk_pstate.enable + || (!action->fclk_pstate.disable && cur->fclk_p_state_change_support); +bool alt_ch_enable = action->alt_ch.enable + || (!action->alt_ch.disable && cur->alt_ch_pstate_switch);/* CLK_MGR60_INDICATE_PSTATE_STATUS — enable */ if ((action->uclk_pstate.enable && action->uclk_pstate.send_message)
@@ -1317,15 +1322,13 @@ static unsigned int dcn60_build_bandwidth_clocks_block_sequence_with_action( || (action->fams.enable && action->fams.send_message) || (action->alt_ch.enable && action->alt_ch.send_message)) { block_sequence[num_steps].params.indicate_pstate_status_params.allow_uclk = - action->uclk_pstate.enable - || clk_mgr_base->clks.p_state_change_support; + allow_uclk; block_sequence[num_steps].params.indicate_pstate_status_params.allow_fclk = - action->fclk_pstate.enable - || clk_mgr_base->clks.fclk_p_state_change_support; + allow_fclk; block_sequence[num_steps].params.indicate_pstate_status_params.drr_enable = new_clocks->fw_based_mclk_switching; block_sequence[num_steps].params.indicate_pstate_status_params.alt_ch_enable = - new_clocks->alt_ch_pstate_switch; + alt_ch_enable; block_sequence[num_steps].params.indicate_pstate_status_params.wait_resp = new_clocks->fw_based_mclk_switching; block_sequence[num_steps].func =CLK_MGR60_INDICATE_PSTATE_STATUS ;
@@ -1369,13 +1372,13 @@ static unsigned int dcn60_build_bandwidth_clocks_block_sequence_with_action( || (action->fams.disable && action->fams.send_message) || (action->alt_ch.disable && action->alt_ch.send_message)) { block_sequence[num_steps].params.indicate_pstate_status_params.allow_uclk = - new_clocks->p_state_change_support || no_active_planes; + allow_uclk; block_sequence[num_steps].params.indicate_pstate_status_params.allow_fclk = - new_clocks->fclk_p_state_change_support || no_active_planes; + allow_fclk; block_sequence[num_steps].params.indicate_pstate_status_params.drr_enable = new_clocks->fw_based_mclk_switching; block_sequence[num_steps].params.indicate_pstate_status_params.alt_ch_enable = - new_clocks->alt_ch_pstate_switch; + alt_ch_enable; block_sequence[num_steps].params.indicate_pstate_status_params.wait_resp = new_clocks->fw_based_mclk_switching; block_sequence[num_steps].func =CLK_MGR60_INDICATE_PSTATE_STATUS ;
@@ -1469,7 +1472,7 @@ static unsigned int dcn60_build_update_bandwidth_clocks_sequence( num_steps =dcn60_build_bandwidth_clocks_block_sequence_with_action ( clk_mgr60->block_sequence, &action, - clk_mgr_base, context, new_clocks); + clk_mgr_base, new_clocks);dcn60_update_bandwidth_clocks_state_with_action (clk_mgr_base, &action, new_clocks);
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH v2 17/30] drm/amd/display: Revoke alternate channel P-State before pipe teardown
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] drm/amd/display: alt_ch_pstate_switch not revoked in prepare_bandwidth() - [Medium]…
Thank you for your contribution! Sashiko AI review found 3 potential issues to consider:
- [Medium] drm/amd/display: alt_ch_pstate_switch not revoked in prepare_bandwidth()
- [Medium] drm/amd/display: UCLK/FCLK P-State left disabled in dcn60_update_clocks()
- [Low] drm/amd/display: missing Fixes: trailers for DCN6 P-State sequencing fix
--
commit 68003479a603655940aa4cfb42034d78591d357d
Author: Ivan Lipski <[email protected]>
Quoted 26 lines
drm/amd/display: Revoke alternate channel P-State before pipe teardown
[Why]
A modeset after stress testing can hang PMFW. The hang only happens when alternate channel P-State switching is in use.Alternate channel P-State permission was sequenced the opposite way to UCLK/FCLK P-State: it could be enabled during
prepare_bandwidth, before the new configuration was programmed, and was only disabled duringoptimize_bandwidth, after the old configuration had been torn down. PMFW could therefore start an alternate channel switch that depended on a display being disabled and never complete it.The IndicatePstateStatus messages also did not follow the computed action. With no active planes,
prepare_bandwidthdecided to revoke UCLK/FCLK P-State but still told PMFW they were allowed, and the enable message could briefly re-allow a state the action was revoking.[How]
Only allow alternate channel P-State when it is safe to lower, and revoke it as soon as the new state does not support it.Only treat zero active planes as UCLK/FCLK P-State support when it is safe to lower, so
prepare_bandwidthnever grants it for a config that has not been programmed yet.
Quoted 8 lines
Derive
allow_uclk,allow_fclkandalt_ch_enableonce from the action and the current clocks. The IndicatePstateStatus messages no longer recount the active planes to allow UCLK/FCLK P-State on their own; the zero plane case is decided only by the action.Cc Alvin Lee <[email protected]>Signed-off-by Ivan Lipski <[email protected]>Signed-off-by George Zhang <[email protected]>
[Severity: Low]
Should this bug fix include Fixes: tags for the commits that introduced the DCN6 P-State sequencing and IndicatePstateStatus handling?
Quoted 5 lines
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c +0
-0
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c static void dcn60_make_bandwidth_clocks_update_action( · line 1217
Quoted 9 lines
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c +2
-2@@ -1211,10 +1211,10 @@ static void dcn60_make_bandwidth_clocks_update_action(bool dcfclk_dpm_enabled =dcn60_is_ppclk_dpm_enabled (clk_mgr_internal,PPCLK_DCFCLK );bool uclk_pstate_supported = new_clocks->p_state_change_support - || (total_plane_count ==0 ); + || (total_plane_count ==0 && safe_to_lower);bool fclk_pstate_supported = new_clocks->fclk_p_state_change_support - || (total_plane_count ==0 ); + || (total_plane_count ==0 && safe_to_lower);
[Severity: Medium]
Can gating total_plane_count == 0 on safe_to_lower leave UCLK and FCLK P-State permanently disabled after a stream update on a stream that already has zero active planes?
When stream_count > 0 and total_plane_count == 0, DML21 sets all_streams_blanked = true and leaves new_clocks->p_state_change_support and fclk_p_state_change_support as false. During prepare_bandwidth (safe_to_lower == false), uclk_pstate_supported and fclk_pstate_supported now evaluate to false, so should_update_pstate_support() actively revokes UCLK and FCLK P-State in PMFW.
However, in dcn401_prepare_bandwidth(), dc->optimized_required is only set when context->bw_ctx.bw.dcn.clk.p_state_change_support is true or when watermarks, arbiter, or compbuf_size change:
drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c:dcn401_prepare_bandwidth() {
...
if (p_state_change_support) {
dc->optimized_required = true;
context->bw_ctx.bw.dcn.clk.p_state_change_support = false;
}
...
}When updating a stream that already had zero planes in dc->current_state, none of those change and dc->optimized_required stays false. dc_post_update_surfaces_to_stream() then skips optimize_bandwidth(), so update_clocks() never runs with safe_to_lower == true to re-enable UCLK and FCLK P-State, leaving memory and fabric clocks pinned at high DPM levels.
[ ... ]
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c static void dcn60_make_bandwidth_clocks_update_action( · line 1291
Quoted 13 lines
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c +3
-2@@ -1282,9 +1282,10 @@ static void dcn60_make_bandwidth_clocks_update_action( }if (new_clocks->alt_ch_pstate_switch != clk_mgr_base->clks.alt_ch_pstate_switch) { - action->alt_ch.enable = new_clocks->alt_ch_pstate_switch; - action->alt_ch.disable = !new_clocks->alt_ch_pstate_switch +/* PMFW hangs if alt-ch is still allowed while pipes are torn down */ + action->alt_ch.enable = new_clocks->alt_ch_pstate_switch && safe_to_lower; + action->alt_ch.disable = !new_clocks->alt_ch_pstate_switch; action->alt_ch.send_message = action->alt_ch.enable || action->alt_ch.disable; }
[Severity: Medium]
Does alt_ch_pstate_switch remain enabled in PMFW during prepare_bandwidth when transitioning between two configurations that both use alternate channel P-State switching?
dcn401_prepare_bandwidth() temporarily forces context->bw_ctx.bw.dcn.clk.p_state_change_support = false before calling update_clocks() and disabling FAMS2 in DMUB, but it does not clear context->bw_ctx.bw.dcn.clk.alt_ch_pstate_switch. If a modeset or full plane update tears down or reconfigures pipes while at least one plane in the new context still uses P_STATE_ALT, both clk_mgr_base->clks.alt_ch_pstate_switch and new_clocks->alt_ch_pstate_switch are true during prepare_bandwidth. action->alt_ch.disable is then not set, and alt_ch_enable remains true in the CLK_MGR60_INDICATE_PSTATE_STATUS message sent before FAMS2 is disabled and pipes are torn down.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=17
PATCH v2 18/30 drm/amd/display: block pr in mst right
In reply to George ZhangFrom: Peichen Huang <[email protected]>
[Why]
Should check mst link in stream signal not connector signal [How]
Use stream signal to check if it is a dp sst link. Also guard against a NULL link_enc when filling dpphy_inst in dp_pr_copy_settings().
--- .../dc/link/protocols/link_dp_panel_replay.c | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_panel_replay.c +9 -11
@@ -53,13 +53,11 @@ static void dp_pr_set_static_screen_param(struct dc_link *link) {struct dc_static_screen_params params = {0 };struct dc *dc = link->ctx->dc; -// only support DP sst for now -if (!dc_is_dp_sst_signal (link->connector_signal)) -return ;for (int i =0 ; i <MAX_PIPES ; i++) {if (dc->current_state->res_ctx.pipe_ctx[i].stream && - dc->current_state->res_ctx.pipe_ctx[i].stream->link == link) { + dc->current_state->res_ctx.pipe_ctx[i].stream->link == link && +dc_is_dp_sst_signal (dc->current_state->res_ctx.pipe_ctx[i].stream->signal)) {struct dc_stream_state *stream = dc->current_state->res_ctx.pipe_ctx[i].stream; unsigned int vsync_rate_hz = (unsigned int)div64_u64(div64_u64( (stream->timing.pix_clk_100hz * (u64)100),
@@ -109,6 +107,9 @@ static bool dp_setup_panel_replay(struct dc_link *link, const struct dc_stream_sif (!(link->replay_settings.config.replay_supported))return false; +if (!stream || !dc_is_dp_sst_signal (stream->signal)) +return false; + dc = link->ctx->dc;//not sure should keep or not
@@ -212,12 +213,10 @@ bool dp_pr_get_pr_panel_inst(const struct dc *dc,if (dc->config.frame_update_cmd_version2 == false)return dc_get_edp_link_panel_inst (dc, link, inst_out); -if (!dc_is_dp_sst_signal (link->connector_signal))/* only supoprt DP sst (eDP included) for now */ -return false; -for (unsigned int i =0 ; i <MAX_PIPES ; i++) {if (dc->current_state->res_ctx.pipe_ctx[i].stream && - dc->current_state->res_ctx.pipe_ctx[i].stream->link == link) { + dc->current_state->res_ctx.pipe_ctx[i].stream->link == link && +dc_is_dp_sst_signal (dc->current_state->res_ctx.pipe_ctx[i].stream->signal)) {/* *inst_out is equal to otg number */ if (dc->current_state->res_ctx.pipe_ctx[i].stream_res.tg) *inst_out = dc->current_state->res_ctx.pipe_ctx[i].stream_res.tg->inst;
@@ -287,9 +286,8 @@ bool dp_pr_copy_settings(struct dc_link *link, struct replay_context *replay_conif (dc->current_state->res_ctx.pipe_ctx[i].stream && dc->current_state->res_ctx.pipe_ctx[i].stream->link && dc->current_state->res_ctx.pipe_ctx[i].stream->link == link && -dc_is_dp_sst_signal (dc->current_state->res_ctx.pipe_ctx[i].stream->link->connector_signal)) { +dc_is_dp_sst_signal (dc->current_state->res_ctx.pipe_ctx[i].stream->signal)) { pipe_ctx = &dc->current_state->res_ctx.pipe_ctx[i]; -/* todo: need update for MST */ break ; } }
@@ -315,7 +313,7 @@ bool dp_pr_copy_settings(struct dc_link *link, struct replay_context *replay_conelse cmd.pr_copy_settings.data.otg_inst =0 ; - cmd.pr_copy_settings.data.dpphy_inst = link->link_enc->transmitter; + cmd.pr_copy_settings.data.dpphy_inst = link->link_enc ? (uint8_t )link->link_enc->transmitter :0 ; cmd.pr_copy_settings.data.line_time_in_ns = replay_context->line_time_in_ns; cmd.pr_copy_settings.data.flags.bitfields.fec_enable_status = (link->fec_state == dc_link_fec_enabled);
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH v2 18/30] drm/amd/display: block pr in mst right
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] drm/amd/display: unguarded link_enc dereference in dp_setup_panel_replay() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] drm/amd/display: unguarded link_enc dereference in dp_setup_panel_replay()
--
commit e59fe77bf19f365a90e441cbffda3fd425f69a9b
Author: Peichen Huang <[email protected]>
drm/amd/display: block pr in mst right
This commit checks the stream signal rather than the connector signal to verify that a link is DP SST for Panel Replay, and guards against a NULL link->link_enc in dp_pr_copy_settings().
Quoted 4 lines
drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_panel_replay.c +0
-0
[ ... ]
drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_panel_replay.c bool dp_pr_copy_settings(struct dc_link *link, struct replay_context *replay_con · line 319
Quoted 9 lines
drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_panel_replay.c +1
-1@@ -315,7 +313,7 @@ bool dp_pr_copy_settings(struct dc_link *link, struct replay_context *replay_conelse cmd.pr_copy_settings.data.otg_inst =0 ; - cmd.pr_copy_settings.data.dpphy_inst = link->link_enc->transmitter; + cmd.pr_copy_settings.data.dpphy_inst = link->link_enc ? (uint8_t )link->link_enc->transmitter :0 ; cmd.pr_copy_settings.data.line_time_in_ns = replay_context->line_time_in_ns; cmd.pr_copy_settings.data.flags.bitfields.fec_enable_status = (link->fec_state == dc_link_fec_enabled);
[Severity: Medium]
Can dp_setup_panel_replay() still dereference a NULL link->link_enc before calling dp_pr_copy_settings()?
When link->link_enc is NULL (for example on a USB4 DPIA link), the sole caller dp_setup_panel_replay() unconditionally dereferences link->link_enc before reaching this new check:
drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_panel_replay.c:dp_setup_panel_replay() {
...
replay_context.aux_inst = (enum channel_id) link_get_ddc_aux_inst(link);
replay_context.digbe_inst = link->link_enc->transmitter;
replay_context.digfe_inst = link->link_enc->preferred_engine;
...
link->replay_settings.replay_feature_enabled = dp_pr_copy_settings(link, &replay_context);
...
}Setting up Panel Replay on a link with a NULL link->link_enc will trigger a NULL pointer dereference in dp_setup_panel_replay().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=18
PATCH v2 19/30 drm/amd/display: Add a per-ASIC default for the DC2 selection
In reply to George ZhangFrom: Tomasz Siemek <[email protected]>
[Why]
The DC2 selection comes only from dc_init_data, so an ASIC cannot default to the DC2 path. The DC2 hardware init and the DC2 commit also cannot be selected separately.
[How]
- Add DC2_SELECTION_DEFAULT as the zero value of enum dc2_selection. api_shim_construct resolves DEFAULT per ASIC; all ASICs resolve to LEGACY, so zeroed dc_init_data keeps the current behavior.
- Add enum dc2_commit_method and struct dc2::commit_method. An explicit CORE2 selection keeps the DM's init method and uses the CORE2 commit, as before.
- Dispatch api_shim_commit_state_hw and api_shim_update_state_* on commit_method; hardware init and release stay on the selection.
--- .../amd/display/dc/dc_api_dispatch/api_shim.c | 30 +++++++++++++++---- .../amd/display/dc/dc_api_dispatch/api_shim.h | 1 + .../amd/display/dc/inc/dc_core_interface.h | 14 +++++++-- 3 files changed, 36 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.c +24 -6
@@ -10,11 +10,29 @@#include "core2/dc_core2.h" #include "inc/dc_core_interface.h" +static void api_shim_construct_per_asic (struct dc *dc) +{ +switch (dc->ctx->dce_version) { +default : +break ; + } +} +void api_shim_construct (struct dc *dc,const struct dc_init_data *init_params) { -/* DM override today; ASIC allow-list later. Owned only by this shim. */ -TO_DC2 (dc)->selection = init_params->dc2_selection; -TO_DC2 (dc)->init_method = init_params->dc2_init_method; +switch (init_params->dc2_selection) { +case DC2_SELECTION_DEFAULT : +api_shim_construct_per_asic (dc); +break ; +case DC2_SELECTION_CORE2 : +TO_DC2 (dc)->selection =DC2_SELECTION_CORE2 ; +TO_DC2 (dc)->init_method = init_params->dc2_init_method; +TO_DC2 (dc)->commit_method =DC2_COMMIT_METHOD_CORE2 ; +break ; +case DC2_SELECTION_LEGACY : +default : +break ; + } }void dc_hardware_init (struct dc *dc)
@@ -35,7 +53,7 @@ void dc_hardware_release(struct dc *dc)enum dc_status api_shim_commit_state_hw (struct dc *dc,struct dc_state *context) { -if (TO_DC2 (dc)->selection ==DC2_SELECTION_CORE2 ) +if (TO_DC2 (dc)->commit_method ==DC2_COMMIT_METHOD_CORE2 )return core2_funcs ()->commit_state_hw (dc, context);return legacy_commit_state_hw (dc, context); }
@@ -43,7 +61,7 @@ enum dc_status api_shim_commit_state_hw(struct dc *dc, struct dc_state *context)bool api_shim_update_state_supported (const struct dc_update_scratch_space *scratch) { -if (TO_DC2 (scratch->dc)->selection ==DC2_SELECTION_CORE2 ) +if (TO_DC2 (scratch->dc)->commit_method ==DC2_COMMIT_METHOD_CORE2 )return core2_funcs ()->update_state_supported (scratch);return true; }
@@ -51,7 +69,7 @@ bool api_shim_update_state_supported(void api_shim_update_state_execute (const struct dc_update_scratch_space *scratch) { -if (TO_DC2 (scratch->dc)->selection ==DC2_SELECTION_CORE2 ) +if (TO_DC2 (scratch->dc)->commit_method ==DC2_COMMIT_METHOD_CORE2 )core2_funcs ()->update_state_execute (scratch);else legacy_update_state_execute (scratch);
drivers/gpu/drm/amd/display/dc/dc_api_dispatch/api_shim.h +1 -0
@@ -16,6 +16,7 @@ struct dc2 {struct dc dc;enum dc2_selection selection;enum dc2_init_method init_method; +enum dc2_commit_method commit_method;/* Resolved by hardware init; later builds take it as dmub_abi. */ struct dmub_abi dmub_abi;bool dmub_abi_resolved;
drivers/gpu/drm/amd/display/dc/inc/dc_core_interface.h +11 -3
@@ -13,11 +13,13 @@ struct dc_state;struct dc_update_scratch_space ;/* -* Construction-time Core implementation selection. Zero is LEGACY so existing -* callers that leave dc uninitialized keep production behavior. +* Construction-time Core implementation selection. Zero is DEFAULT, which lets +* the ASIC choose; ASICs without a Core2 default resolve to LEGACY, so callers +* that leave dc_init_data zeroed keep production behavior. */ enum dc2_selection { -DC2_SELECTION_LEGACY =0 , +DC2_SELECTION_DEFAULT =0 , +DC2_SELECTION_LEGACY ,DC2_SELECTION_CORE2 , };
@@ -27,6 +29,12 @@ enum dc2_init_method { DC2_INIT_METHOD_WRAPPED, }; +/* Temporary: picks the commit_state_hw flow for bring-up testing. */ +enum dc2_commit_method { +DC2_COMMIT_METHOD_LEGACY =0 , +DC2_COMMIT_METHOD_CORE2 , +}; +enum dc2_hw_ownership {DC2_HW_OWNERSHIP_RELEASED =0 ,DC2_HW_OWNERSHIP_OWNED ,
Signature · 1 line
2.56.1
PATCH v2 20/30 drm/amd/display: Refactor Max VStartup calculations for DCN6
In reply to George ZhangFrom: Dillon Varone <[email protected]>
[WHY&HOW]
The limitation for alt-channel p-state was being applied incorrectly, such that VStartup could become "dynamic" based on the variable SVP0 and SVP1 sizes. This is not allowed, as VStartup should only depend on constants and the display timing.
This refactor pins the VStartup to depend on 2x the UCLK P-State latency, and only if alt-channel P-state is supported for the IP.
--- .../dml2_0/dml21/src/dml2_core/dml2_core_dcn6_calcs.h | 4 ++-- .../dml21/src/dml2_core/dml2_core_dcn6_calcs_dchub.c | 11 +++++++---- .../dml21/src/dml2_core/dml2_core_dcn6_calcs_dchub.h | 4 ++-- .../src/dml2_core/dml2_core_dcn6_funcs_initialize.c | 3 +++ .../src/dml2_core/dml2_core_dcn6_funcs_mode_support.c | 5 +++-- .../dml21/src/dml2_core/dml2_core_shared_types.h | 1 + 6 files changed, 18 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_calcs.h +2 -2
@@ -14,11 +14,11 @@struct dml2_core_dcn6_calcs {unsigned int (*calculate_max_vstartup)(bool ptoi_supported, +bool alt_channel_supported,unsigned int vblank_nom_default_us,const struct dml2_timing_cfg *timing, -enum dml2_uclk_pstate_change_strategy pstate_strategy,double write_back_delay_us, -unsigned int svp_lines); +double uclk_pstate_latency_us);void (*calculate_alternate_params)(struct dml2_core_calcs_calculate_alternate_params *p);void (*calculate_alternate_svp_lines)(struct dml2_core_calcs_calculate_alternate_svp_lines *p); void (*calculate_flip_schedule)(
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_calcs_dchub.c +7 -4
@@ -10,11 +10,11 @@unsigned int dcn6_calculate_max_vstartup (bool ptoi_supported, +bool alt_channel_supported,unsigned int vblank_nom_default_us,const struct dml2_timing_cfg *timing, -enum dml2_uclk_pstate_change_strategy pstate_strategy,double write_back_delay_us, -unsigned int svp_lines) +double uclk_pstate_latency_us) {unsigned int vblank_size =0 ;unsigned int max_vstartup_lines =0 ;
@@ -31,8 +31,11 @@ unsigned int dcn6_calculate_max_vstartup(else max_vstartup_lines = vblank_size - (unsigned int )math_max2 (1.0 ,math_ceil2 (write_back_delay_us / line_time_us,1.0 )); -if (pstate_strategy == dml2_uclk_pstate_change_strategy_force_alternate) - max_vstartup_lines = (unsigned int )math_min2 (max_vstartup_lines, svp_lines); +// alt-channel p-state requires limiting max_vstartup_lines to p-state x2 +if (alt_channel_supported) { + max_vstartup_lines = (unsigned int )math_min2 (max_vstartup_lines, +math_floor2 (uclk_pstate_latency_us *2.0 / line_time_us,1.0 )); + } max_vstartup_lines = (unsigned int )math_min2 (max_vstartup_lines, __DML2_CALCS_MAX_VSTARTUP__);
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_calcs_dchub.h +2 -2
@@ -8,11 +8,11 @@unsigned int dcn6_calculate_max_vstartup (bool ptoi_supported, +bool alt_channel_supported,unsigned int vblank_nom_default_us,const struct dml2_timing_cfg *timing, -enum dml2_uclk_pstate_change_strategy pstate_strategy,double write_back_delay_us, -unsigned int svp_lines); +double uclk_pstate_latency_us);void dcn6_calculate_alternate_params (struct dml2_core_calcs_calculate_alternate_params *p);void dcn6_calculate_alternate_svp_lines (struct dml2_core_calcs_calculate_alternate_svp_lines *p);void dcn6_calculate_alternate_lead_lines (struct dml2_core_calcs_calculate_alternate_lead_lines *p);
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_funcs_initialize.c +3 -0
@@ -156,6 +156,9 @@ bool dml2_core_dcn6_funcs_initialize(struct dml2_core_initialize_in_out *in_out)patch_ip_params_with_ip_caps (&core->clean_me_up.mode_lib.ip, in_out->ip_caps); core->clean_me_up.mode_lib.ip.imall_supported = false; + +if (in_out->project_id == dml2_project_dcn6x_soc_var_a) + core->clean_me_up.mode_lib.ip.alt_channel_supported = true; }memcpy (&core->clean_me_up.mode_lib.ip_caps, in_out->ip_caps,sizeof (struct dml2_ip_capabilities ));
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_funcs_mode_support.c +3 -2
@@ -2397,6 +2397,7 @@ void dcn6_ms_calculate_max_vstartup(struct dml2_core_internal_mode_support *outputs = states;const struct dml2_display_cfg *display_cfg = ctx->display_cfg;const struct dml2_core_ip_params *ip = ctx->ip; +const struct dml2_utm_soc_bb *soc_bb = ctx->soc_bb;unsigned int k, stream_index;const struct dml2_stream_parameters *stream;
@@ -2407,11 +2408,11 @@ void dcn6_ms_calculate_max_vstartup( stream = &display_cfg->stream_descriptors[stream_index]; outputs->MaximumVStartup[k] =get_calcs (ctx)->calculate_max_vstartup ( ip->ptoi_supported, + ip->alt_channel_supported, ip->vblank_nom_default_us, &stream->timing, - display_cfg->plane_descriptors[k].overrides.uclk_pstate_change_strategy, inputs->WritebackDelayTime[k], - inputs->svp0_dst_lines[stream_index] + inputs->svp1_dst_lines[stream_index]); + soc_bb->power_management_parameters.dram_clk_change_blackout_us); outputs->MaxVStartupLines[k] = outputs->MaximumVStartup[k]; }DML_LOG_VERBOSE ("DML::%s: k=%u, MaximumVStartup = %u\n" , __func__, k, outputs->MaximumVStartup[k]);
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_shared_types.h +1 -0
@@ -73,6 +73,7 @@ struct dml2_core_ip_params {unsigned int max_num_dp2p0_streams;bool dcc_supported;bool ptoi_supported; +bool alt_channel_supported;double writeback_max_hscl_ratio;double writeback_max_vscl_ratio;double writeback_min_hscl_ratio;
Signature · 1 line
2.56.1
PATCH v2 21/30 drm/amd/display: Improve P-state admissability logic
In reply to George ZhangFrom: Dillon Varone <[email protected]>
[WHY&HOW]
P-State admissability logic failed to account for time leftover by a VStartup constrained to be smaller than VBlank. In this case, the difference between VBlank and VStartup should be considered as usable for latency hiding. Also clamp the ideal P-state disallow time per stream to the P-state allow delay divided by the number of streams when updating the worksheet for admissibility.
--- .../src/dml2_core/dml2_core_dcn6_calcs.h | 2 ++ .../dml2_core/dml2_core_dcn6_calcs_dchub.c | 8 +++++++- .../dml2_core/dml2_core_dcn6_calcs_dchub.h | 2 ++ .../dml2_core_dcn6_funcs_mode_support.c | 8 ++++++++ .../dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c | 20 ++++++++++++++++--- .../src/inc/dml2_internal_shared_types.h | 1 + 6 files changed, 37 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_calcs.h +2 -0
@@ -73,6 +73,8 @@ struct dml2_core_dcn6_calcs {int num_active_planes, const unsigned int v_blank_start[DML2_MAX_PLANES], const unsigned int v_blank_end[DML2_MAX_PLANES], + const unsigned int v_startup[DML2_MAX_PLANES], + const unsigned int v_total[DML2_MAX_PLANES], const double otg_vline_time_us[DML2_MAX_PLANES], const double det_fill_delay_us[DML2_MAX_PLANES], const double reserved_vblank_us[DML2_MAX_PLANES],
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_calcs_dchub.c +7 -1
@@ -1715,6 +1715,8 @@ void dcn6_calculate_pstate_schedule_windows(int num_active_planes, const unsigned int v_blank_start[DML2_MAX_PLANES], const unsigned int v_blank_end[DML2_MAX_PLANES], + const unsigned int v_startup[DML2_MAX_PLANES], + const unsigned int v_total[DML2_MAX_PLANES], const double otg_vline_time_us[DML2_MAX_PLANES], const double det_fill_delay_us[DML2_MAX_PLANES], const double reserved_vblank_us[DML2_MAX_PLANES],
@@ -1728,6 +1730,7 @@ void dcn6_calculate_pstate_schedule_windows(int det_fill_delay_otg_vlines;int blackout_otg_vlines;int reserved_vblank_otg_vlines; +int unallocated_vblank_otg_vlines;/** * Calculate allow start and end for pstate in vactive:
@@ -1742,10 +1745,13 @@ void dcn6_calculate_pstate_schedule_windows( blackout_otg_vlines = (int )(math_ceil (blackout_us / otg_vline_time_us[k])); det_fill_delay_otg_vlines = (int )(math_ceil (det_fill_delay_us[k] / otg_vline_time_us[k])); reserved_vblank_otg_vlines = (int )(math_ceil (reserved_vblank_us[k] / otg_vline_time_us[k])); + unallocated_vblank_otg_vlines = v_total[k] - v_blank_start[k] + v_blank_end[k] - v_startup[k];/* for vactive only, make relative to vblank end */ allow_start_otg_vlines = det_fill_delay_otg_vlines; - allow_end_otg_vlines = v_blank_start[k] - v_blank_end[k] - (blackout_otg_vlines - reserved_vblank_otg_vlines); + allow_end_otg_vlines = v_blank_start[k] - v_blank_end[k] + + unallocated_vblank_otg_vlines - + (blackout_otg_vlines - reserved_vblank_otg_vlines);/* Convert them back to time since the start of a frame */ allow_start_us[k] = allow_start_otg_vlines * otg_vline_time_us[k];
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_calcs_dchub.h +2 -0
@@ -74,6 +74,8 @@ void dcn6_calculate_pstate_schedule_windows(int num_active_planes, const unsigned int v_blank_start[DML2_MAX_PLANES], const unsigned int v_blank_end[DML2_MAX_PLANES], + const unsigned int v_startup[DML2_MAX_PLANES], + const unsigned int v_total[DML2_MAX_PLANES], const double otg_vline_time_us[DML2_MAX_PLANES], const double det_fill_delay_us[DML2_MAX_PLANES], const double reserved_vblank_us[DML2_MAX_PLANES],
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_funcs_mode_support.c +8 -0
@@ -3846,6 +3846,7 @@ void dcn6_ms_calculate_pstate_schedule_windows(struct dml2_core_calcs_mode_support_locals *dummies = ctx->dummies;unsigned int *v_blank_start = dummies->dummy_integer_array[0 ];unsigned int *v_blank_end = dummies->dummy_integer_array[1 ]; +unsigned int *v_total = dummies->dummy_integer_array[2 ];double *otg_vline_time_us = dummies->dummy_double_array[0 ];double *reserved_vblank_us = dummies->dummy_double_array[1 ];const struct dml2_plane_parameters *plane =NULL ;
@@ -3858,6 +3859,7 @@ void dcn6_ms_calculate_pstate_schedule_windows( stream = &display_cfg->stream_descriptors[plane->stream_index]; v_blank_start[k] = stream->timing.v_blank_end + stream->timing.v_active; v_blank_end[k] = stream->timing.v_blank_end; + v_total[k] = stream->timing.v_total; otg_vline_time_us[k] = (double )stream->timing.h_total / stream->timing.pixel_clock_khz *1000.0 ; reserved_vblank_us[k] = plane->overrides.reserved_vblank_time_ns /1000.0 ; }
@@ -3868,6 +3870,8 @@ void dcn6_ms_calculate_pstate_schedule_windows( display_cfg->num_planes, v_blank_start, v_blank_end, + inputs->MaxVStartupLines, + v_total, otg_vline_time_us, inputs->pstate_vactive_det_fill_delay_us[dml2_pstate_type_fclk], reserved_vblank_us,
@@ -3883,6 +3887,8 @@ void dcn6_ms_calculate_pstate_schedule_windows( display_cfg->num_planes, v_blank_start, v_blank_end, + inputs->MaxVStartupLines, + v_total, otg_vline_time_us, inputs->pstate_vactive_det_fill_delay_us[dml2_pstate_type_ppt], reserved_vblank_us,
@@ -3900,6 +3906,8 @@ void dcn6_ms_calculate_pstate_schedule_windows( display_cfg->num_planes, v_blank_start, v_blank_end, + inputs->MaxVStartupLines, + v_total, otg_vline_time_us, inputs->pstate_vactive_det_fill_delay_us[dml2_pstate_type_temp_read], reserved_vblank_us,
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c +17 -3
@@ -403,7 +403,7 @@ static bool dcn6_is_pstate_schedulable( }static bool dcn6_update_worksheet_for_pstate_admissibility (struct dml2_optimization_worksheet *worksheet, -struct dml2_pstate_meta *per_stream_pstate_meta, +struct dml2_stage_optimizer_fclk_ppt_temp_read_pstate_optimize_locals *l,enum dml2_pstate_type pstate_type) {const double vblank_ratio =0.8 ;
@@ -426,6 +426,8 @@ static bool dcn6_update_worksheet_for_pstate_admissibility(struct dml2_optimizatlong reserved_vblank_time_ns;bool unvalidated_changes = false; +struct dml2_pstate_meta *per_stream_pstate_meta = l->per_stream_pstate_meta; +const struct dml2_display_cfg *display_config = worksheet->orig_dispcfg;/* Two possible locations to obtain the extra time required to pass admissibility * 1. Allocate some time from the reserved vblank
@@ -456,6 +458,8 @@ static bool dcn6_update_worksheet_for_pstate_admissibility(struct dml2_optimizat (1.0 / (2.0 -math_pow (2.0 , (float )(2 - display_config->num_streams)))); } + ideal_disallow_time_us =math_min2 (ideal_disallow_time_us, l->pstate_allow_delay_us / (double )display_config->num_streams); + extra_time_required_us =0.0 ; delta_max_det_fill_delay_us =0.0 ; delta_reserved_vblank_time_us =0.0 ;
@@ -599,6 +603,13 @@ static int dcn6_get_required_vactive_det_fill_delay_us(return max_vactive_det_fill_delay_us; } +static int dcn6_get_vstartup_lines ( +const struct dml2_validation_result *validation_res, +int stream_idx) +{ +return validation_res->mode_support.cfg_support_info.stream_support_info[stream_idx].max_vstartup_lines; +} +static bool dcn6_all_timings_support_vactive (struct dml2_pmo_stage_optimizer *stage,const struct dml2_display_cfg *display_config,unsigned int mask)
@@ -769,6 +780,7 @@ static void dcn6_build_pstate_meta_per_stream(const struct dml2_display_cfg *dis/* scheduling params should be built based on the worst case for allow_time:disallow_time */ /* vactive */ + stream_pstate_meta->method_vactive.vstartup_lines =dcn6_get_vstartup_lines (&worksheet->validation_result, stream_index); stream_pstate_meta->method_vactive.vactive_latency_hiding_us = (double )dcn6_get_vactive_latency_hiding (&worksheet->validation_result, stream_plane_mask);if (stream_pstate_meta->method_vactive.vactive_latency_hiding_us < watermark_us) {
@@ -836,11 +848,12 @@ static void dcn6_build_pstate_meta_per_stream(const struct dml2_display_cfg *disif (stream_pstate_meta->method_vactive.max_vactive_det_fill_delay_us >0.0 ) { stream_pstate_meta->method_vactive.common.allow_start_otg_vline = timing->v_blank_end + stream_pstate_meta->method_vactive.max_vactive_det_fill_delay_otg_vlines; + stream_pstate_meta->method_vactive.common.allow_end_otg_vline = stream_pstate_meta->vblank_start + stream_pstate_meta->nom_vtotal - stream_descriptor->timing.v_active - - stream_descriptor->timing.vblank_nom - + stream_pstate_meta->method_vactive.vstartup_lines - stream_pstate_meta->blackout_otg_vlines + stream_pstate_meta->method_vactive.reserved_blank_required_vlines; }else {
@@ -1782,7 +1795,8 @@ static bool dml2_pmo_dcn6_stage_optimizer_fclk_ppt_temp_read_pstate_optimize_nex/* always update the worksheet with latest requirements */ if (dcn6_update_worksheet_for_pstate_admissibility (worksheet, - l->per_stream_pstate_meta, worksheet->fclk_ppt_temp_read_pstate.pstate_type_list[i])) { + l, + worksheet->fclk_ppt_temp_read_pstate.pstate_type_list[i])) { modified = true;DML_LOG_VERBOSE ("fclk_ppt_temp_read pstate not admissible with current worksheet, adjusting the reserved vblank time\n" ); }
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/inc/dml2_internal_shared_types.h +1 -0
@@ -462,6 +462,7 @@ struct dml2_pstate_meta {double reserved_vblank_required_us;int max_vactive_det_fill_delay_otg_vlines;int reserved_blank_required_vlines; +int vstartup_lines;struct dml2_pstate_per_method_common_meta common; } method_vactive;struct {
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH v2 21/30] drm/amd/display: Improve P-state admissability logic
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] drm/amd/display: vblank_nom not replaced in dcn6_build_pstate_meta_per_stream() - [Medium]…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] drm/amd/display: vblank_nom not replaced in dcn6_build_pstate_meta_per_stream()
- [Medium] drm/amd/display: v_total vs vblank_nom mismatch in DCN6 pstate admissibility
--
commit 0206c2992e2de04f212b5f64a6b0b9d2d0262f39
Author: Dillon Varone <[email protected]>
drm/amd/display: Improve P-state admissability logic
This commit updates DCN6 P-state schedule window and admissibility calculations to include unallocated VBlank lines when VStartup is smaller than VBlank, and clamps the per-stream ideal P-state disallow time to the allow delay divided by the number of streams.
Quoted 26 lines
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_calcs_dchub.c +4
-0@@ -1715,6 +1715,8 @@ void dcn6_calculate_pstate_schedule_windows(int num_active_planes, const unsigned int v_blank_start[DML2_MAX_PLANES], const unsigned int v_blank_end[DML2_MAX_PLANES], + const unsigned int v_startup[DML2_MAX_PLANES], + const unsigned int v_total[DML2_MAX_PLANES], const double otg_vline_time_us[DML2_MAX_PLANES], const double det_fill_delay_us[DML2_MAX_PLANES], const double reserved_vblank_us[DML2_MAX_PLANES],@@ -1728,6 +1730,7 @@ void dcn6_calculate_pstate_schedule_windows(int det_fill_delay_otg_vlines;int blackout_otg_vlines;int reserved_vblank_otg_vlines; +int unallocated_vblank_otg_vlines;/** * Calculate allow start and end for pstate in vactive: @@ -1742,10 +1745,13 @@ void dcn6_calculate_pstate_schedule_windows( blackout_otg_vlines = (int )(math_ceil (blackout_us / otg_vline_time_us[k])); det_fill_delay_otg_vlines = (int )(math_ceil (det_fill_delay_us[k] / otg_vline_time_us[k])); reserved_vblank_otg_vlines = (int )(math_ceil (reserved_vblank_us[k] / otg_vline_time_us[k])); + unallocated_vblank_otg_vlines = v_total[k] - v_blank_start[k] + v_blank_end[k] - v_startup[k];
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_calcs_dchub.c void dcn6_calculate_pstate_schedule_windows( · line 1757
Quoted 10 lines
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn6_calcs_dchub.c +3
-1/* for vactive only, make relative to vblank end */ allow_start_otg_vlines = det_fill_delay_otg_vlines; - allow_end_otg_vlines = v_blank_start[k] - v_blank_end[k] - (blackout_otg_vlines - reserved_vblank_otg_vlines); + allow_end_otg_vlines = v_blank_start[k] - v_blank_end[k] + + unallocated_vblank_otg_vlines - + (blackout_otg_vlines - reserved_vblank_otg_vlines);/* Convert them back to time since the start of a frame */ allow_start_us[k] = allow_start_otg_vlines * otg_vline_time_us[k];
[Severity: Medium]
Does adding unallocated_vblank_otg_vlines (computed from v_total) to allow_end_otg_vlines cause dcn6_calculate_pstate_schedule_admissibility() to under-calculate disallow_window_us when v_total - v_active exceeds vblank_nom?
dcn6_ms_check_pstate_schedule_admissibility() computes frame_time_us[k] via dml2_core_utils_get_frame_time_us(), which uses vblank_nom + v_active rather than v_total:
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_utils.c:dml2_core_utils_get_frame_time_us() {
double otg_vline_time_us = (double)stream->timing.h_total / (double)stream->timing.pixel_clock_khz * 1000.0;
double non_vtotal = stream->timing.vblank_nom + stream->timing.v_active;
double frame_time_us = non_vtotal * otg_vline_time_us;When dcn6_calculate_pstate_schedule_admissibility() computes disallow_window_us[cur_id] = group_frame_time_us - allow_window_us[cur_id], subtracting a v_total-based allow_window_us from a (vblank_nom + v_active) frame time double-subtracts (v_total - v_active - vblank_nom) lines. On timings whose VBlank exceeds vblank_nom, this reduces or zeroes disallow_window_us and lets non-admissible P-state schedules pass mode support validation.
[ ... ]
Quoted 4 lines
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c +0
-0
[ ... ]
Quoted 4 lines
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c +0
-0@@ -836,11 +848,12 @@ static void dcn6_build_pstate_meta_per_stream(const struct dml2_display_cfg *disif (stream_pstate_meta->method_vactive.max_vactive_det_fill_delay_us >0.0 ) { stream_pstate_meta->method_vactive.common.allow_start_otg_vline = timing->v_blank_end + stream_pstate_meta->method_vactive.max_vactive_det_fill_delay_otg_vlines;
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c static void dcn6_build_pstate_meta_per_stream(const struct dml2_display_cfg *dis · line 859
Quoted 10 lines
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c +2
-1+ stream_pstate_meta->method_vactive.common.allow_end_otg_vline = stream_pstate_meta->vblank_start + stream_pstate_meta->nom_vtotal - stream_descriptor->timing.v_active - - stream_descriptor->timing.vblank_nom - + stream_pstate_meta->method_vactive.vstartup_lines - stream_pstate_meta->blackout_otg_vlines + stream_pstate_meta->method_vactive.reserved_blank_required_vlines; }else {
[Severity: Medium]
Should the max allow delay enforcement immediately above in dcn6_build_pstate_meta_per_stream() also subtract stream_pstate_meta->method_vactive.vstartup_lines instead of stream_descriptor->timing.vblank_nom?
drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c:dcn6_build_pstate_meta_per_stream() {
...
/* consider max allow delay enforcement */
if (stream_pstate_meta->method_vactive.max_vactive_det_fill_delay_otg_vlines > 0) {
stream_pstate_meta->method_vactive.max_vactive_det_fill_delay_otg_vlines = (int)math_min2(
(double)stream_pstate_meta->method_vactive.max_vactive_det_fill_delay_otg_vlines,
math_max2(0.0,
stream_pstate_meta->max_allow_delay_otg_vlines +
stream_pstate_meta->method_vactive.reserved_blank_required_vlines -
(int)stream_descriptor->timing.vblank_nom -
stream_pstate_meta->blackout_otg_vlines));
} else {
stream_pstate_meta->method_vactive.max_vactive_det_fill_delay_otg_vlines = (int)math_max2(0.0,
stream_pstate_meta->max_allow_delay_otg_vlines +
stream_pstate_meta->method_vactive.reserved_blank_required_vlines -
(int)stream_descriptor->timing.vblank_nom -
stream_pstate_meta->blackout_otg_vlines);
}
...
}When vstartup_lines < vblank_nom, subtracting vblank_nom underestimates max_vactive_det_fill_delay_otg_vlines by (vblank_nom - vstartup_lines) and can clamp max_vactive_det_fill_delay_us to 0.0, which skips the allow window calculation above and leaves allow_start_otg_vline and allow_end_otg_vline at 0. Similarly, dcn6_update_worksheet_for_pstate_admissibility() still computes vblank_time_us from timing.vblank_nom rather than vstartup_lines when bounding delta_reserved_vblank_time_us, which can reserve more VBlank time than fits in VStartup.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=21
PATCH v2 22/30 drm/amd/display: Flip every DPP pipe of the stream in DC2
In reply to George ZhangFrom: Tony Cheng <[email protected]>
dcn401_check_flip accepted one plane on one OPP head and one DPP pipe, so MPO and ODM flips on Core2 failed. The flip steps already run per DPP pipe in DC1's order, so the check now accepts any pipe layout whose planes all carry an address-only update. A plane without an address update stays rejected, because the address step does not skip it as DC1 does.
--- .../dc/bls_builder/dcn401_seamless_builder.c | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +22 -17
@@ -1055,32 +1055,37 @@ static bool check_no_stream_update_flags(const struct dc *dc, }/* -* Any other plane update bit adds a step to the flip. DC1 hands an -* offloaded flip to HWFQ. With triple-buffer flips, the pipe lock is not -* a TG_LOCK leaf. +* Any other plane update bit adds a step to the flip. A plane without an +* address update would still get HUBP_UPDATE_PLANE_ADDR, which DC1 skips, +* so every plane of the stream flips. DC1 hands an offloaded flip to HWFQ. +* With triple-buffer flips, the pipe lock is not a TG_LOCK leaf. */ -static bool check_one_address_only_plane (const struct dc *dc, +static bool check_address_only_planes (const struct dc *dc,const struct dc_state *current_state,const struct dc_state *new_state,unsigned int i) {struct pipe_ctx *dpp_pipes[MAX_PIPES ];const struct dc_plane_state *plane; +int j, n; (void )dc; (void )current_state; -if (new_state->stream_status[i].plane_count !=1 || -resource_get_opp_heads_for_stream (new_state->streams[i], - (struct resource_context *)&new_state->res_ctx, - dpp_pipes) !=1 || -resource_get_dpp_pipes_for_stream (new_state->streams[i], +if (!new_state->stream_status[i].plane_count) +return false; + n =resource_get_dpp_pipes_for_stream (new_state->streams[i], (struct resource_context *)&new_state->res_ctx, - dpp_pipes) !=1 || - !dpp_pipes[0 ]->plane_state || - !dpp_pipes[0 ]->plane_res.hubp) + dpp_pipes); +if (n <=0 )return false; - plane = dpp_pipes[0 ]->plane_state; -return dc_check_address_only_update (plane->update_bits) && - !plane->triplebuffer_flips; +for (j =0 ; j < n; j++) { + plane = dpp_pipes[j]->plane_state; +if (!plane || !dpp_pipes[j]->plane_res.hubp) +return false; +if (!dc_check_address_only_update (plane->update_bits) || + plane->triplebuffer_flips) +return false; + } +return true; } static bool dcn401_pipe_on_either(const struct dc_state *current_state,
@@ -1156,8 +1161,8 @@ static enum bls_builder_result dcn401_check_flip(const struct dc *dc,CHECK_UPDATE (no_subvp,"subvp is set" );CHECK_UPDATE (no_dmub_work,"psr, replay, abm or hwfq needs dmub" );CHECK_UPDATE (no_stream_update_flags,"stream update flags are set" ); -CHECK_UPDATE (one_address_only_plane, -"stream has odm, or not one plane with an address-only update" ); +CHECK_UPDATE (address_only_planes, +"a plane of the stream has no address-only update" );CHECK_CONDITION (triple_buffer,"triple buffer is disabled" );CHECK_UPDATE (no_immediate_dcc_flip,"immediate flip of a dcc surface" );CHECK_UPDATE (no_mcm_luts,"an mcm lut is enabled" );
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH v2 22/30] drm/amd/display: Flip every DPP pipe of the stream in DC2
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] drm/amd/display: missing OTG GSL lock on MPO immediate flips in dcn401_check_flip() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] drm/amd/display: missing OTG GSL lock on MPO immediate flips in dcn401_check_flip()
--
commit ab01c877e59048c17db59a44352ba247bd2d538f
Author: Tony Cheng <[email protected]>
drm/amd/display: Flip every DPP pipe of the stream in DC2
This commit widens dcn401_check_flip() to accept address-only flips on streams with multiple planes or ODM slices by checking every DPP pipe of the stream instead of requiring a single plane on a single OPP head and DPP pipe.
Quoted 58 lines
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +20
-15@@ -1055,32 +1055,37 @@ static bool check_no_stream_update_flags(const struct dc *dc, }/* -* Any other plane update bit adds a step to the flip. DC1 hands an -* offloaded flip to HWFQ. With triple-buffer flips, the pipe lock is not -* a TG_LOCK leaf. +* Any other plane update bit adds a step to the flip. A plane without an +* address update would still get HUBP_UPDATE_PLANE_ADDR, which DC1 skips, +* so every plane of the stream flips. DC1 hands an offloaded flip to HWFQ. +* With triple-buffer flips, the pipe lock is not a TG_LOCK leaf. */ -static bool check_one_address_only_plane (const struct dc *dc, +static bool check_address_only_planes (const struct dc *dc,const struct dc_state *current_state,const struct dc_state *new_state,unsigned int i) {struct pipe_ctx *dpp_pipes[MAX_PIPES ];const struct dc_plane_state *plane; +int j, n; (void )dc; (void )current_state; -if (new_state->stream_status[i].plane_count !=1 || -resource_get_opp_heads_for_stream (new_state->streams[i], - (struct resource_context *)&new_state->res_ctx, - dpp_pipes) !=1 || -resource_get_dpp_pipes_for_stream (new_state->streams[i], +if (!new_state->stream_status[i].plane_count) +return false; + n =resource_get_dpp_pipes_for_stream (new_state->streams[i], (struct resource_context *)&new_state->res_ctx, - dpp_pipes) !=1 || - !dpp_pipes[0 ]->plane_state || - !dpp_pipes[0 ]->plane_res.hubp) + dpp_pipes); +if (n <=0 )return false; - plane = dpp_pipes[0 ]->plane_state; -return dc_check_address_only_update (plane->update_bits) && - !plane->triplebuffer_flips; +for (j =0 ; j < n; j++) { + plane = dpp_pipes[j]->plane_state; +if (!plane || !dpp_pipes[j]->plane_res.hubp) +return false; +if (!dc_check_address_only_update (plane->update_bits) || + plane->triplebuffer_flips) +return false; + } +return true; } static bool dcn401_pipe_on_either(const struct dc_state *current_state,
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c static enum bls_builder_result dcn401_check_flip(const struct dc *dc, · line 1168
Quoted 10 lines
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +2
-2@@ -1156,8 +1161,8 @@ static enum bls_builder_result dcn401_check_flip(const struct dc *dc,CHECK_UPDATE (no_subvp,"subvp is set" );CHECK_UPDATE (no_dmub_work,"psr, replay, abm or hwfq needs dmub" );CHECK_UPDATE (no_stream_update_flags,"stream update flags are set" ); -CHECK_UPDATE (one_address_only_plane, -"stream has odm, or not one plane with an address-only update" ); +CHECK_UPDATE (address_only_planes, +"a plane of the stream has no address-only update" );CHECK_CONDITION (triple_buffer,"triple buffer is disabled" );CHECK_UPDATE (no_immediate_dcc_flip,"immediate flip of a dcc surface" );CHECK_UPDATE (no_mcm_luts,"an mcm lut is enabled" );
[Severity: Medium]
Does dcn401_check_flip() allow immediate flips on multi-plane (MPO) streams without programming the OTG GSL lock?
When an OTG master has pipe->bottom_pipe != NULL and flip_immediate is true, DC1 sets up a GSL group as a lock and waits for pending flips before TG_LOCK:
drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c:dcn20_build_pipe_control_lock_sequence() {
if (flip_immediate && lock) {
temp_pipe = pipe;
while (temp_pipe) {
if (temp_pipe->plane_state && temp_pipe->plane_state->flip_immediate)
params->hubps_to_wait_for_flip[hubp_count++] = temp_pipe->plane_res.hubp;
temp_pipe = temp_pipe->bottom_pipe;
}
}
...
if (lock && (pipe->bottom_pipe != NULL || !flip_immediate))
if ((flip_immediate && pipe->stream_res.gsl_group == 0) ||
(!flip_immediate && pipe->stream_res.gsl_group > 0)) {
params->gsl_lock = true;
dcn20_build_gsl_group_as_lock(dc, pipe, flip_immediate,
¶ms->gsl, ¶ms->gsl_source_select);
}
}In DC2, program_flip still emits HUBP_SET_FLIP_CONTROL_GSL with flip_immediate = true on each HUBP, while the lock table only emits TG_LOCK and omits HUBP_WAIT_FLIP_PENDING, TG_SET_GSL, and TG_SET_GSL_SOURCE_SELECT, leaving immediate flips across MPO pipes without OTG GSL synchronization.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=22
PATCH v2 23/30 drm/amd/display: Report a DC2 BLS step overflow behind a debug option
In reply to George ZhangFrom: Tony Cheng <[email protected]>
[Why]
The dcn401 DC2 builders bound each sequence with a hand-counted static_assert that every table change must update. The builder already stops writing at the bound, and the commit rejects the longer sequence.
[How]
Drop the static_asserts. With dc->debug.dc2_bls_report_step_overflow set, the builder logs an error and breaks to the debugger at the first step past the bound.
--- .../bls_builder/dcn401_non_seamless_builder.c | 31 ------------- .../dc/bls_builder/dcn401_seamless_builder.c | 45 +++---------------- drivers/gpu/drm/amd/display/dc/dc.h | 2 + 3 files changed, 9 insertions(+), 69 deletions(-)
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c +0 -31
@@ -391,37 +391,6 @@ static const struct dcn401_commit_step postamble[] = { .meta.clk_mgr_update_clocks_for_state.safe_to_lower = true }, }; -/* Bounds on what build adds for one stream in either state. */ -static_assert (ARRAY_SIZE (prepare_bandwidth) + -ARRAY_SIZE (lock) + -DCN401_MAX_OPP_HEADS *ARRAY_SIZE (blank) + -DCN401_MAX_DPP_PIPES *ARRAY_SIZE (dcn401_disconnect) + -ARRAY_SIZE (unlock) + -DCN401_MAX_DPP_PIPES *ARRAY_SIZE (dcn401_power_down) + -ARRAY_SIZE (stream_off) + -ARRAY_SIZE (optc_dsc_off) + -DCN401_MAX_OPP_HEADS *ARRAY_SIZE (dsc_off) + -ARRAY_SIZE (otg_off) + -ARRAY_SIZE (postamble) <= -DC2_BLS_MAX_STEPS , -"dcn401 commit stream-off head exceeds DC2_BLS_MAX_STEPS" ); -static_assert (ARRAY_SIZE (prepare_bandwidth) + -ARRAY_SIZE (stream_timing) + -ARRAY_SIZE (opp_clock) + -ARRAY_SIZE (crtc) + -2 *ARRAY_SIZE (optc_dsc) + -ARRAY_SIZE (output) + -ARRAY_SIZE (front_end_lock) + -ARRAY_SIZE (front_end) + -DCN401_MAX_OPP_HEADS * ( -ARRAY_SIZE (odm) + -2 *ARRAY_SIZE (blank) + -2 *ARRAY_SIZE (dsc) + -ARRAY_SIZE (front_end_odm)) + -ARRAY_SIZE (postamble) <= -DC2_BLS_MAX_STEPS , -"dcn401 commit enable head exceeds DC2_BLS_MAX_STEPS" ); -static const struct dcn401_sub_sequence bls_head[] = { { .flags =DCN401_NEW_STATE , .steps = prepare_bandwidth,
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +7 -38
63 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/dc.h +2 -0
@@ -1349,6 +1349,8 @@ struct dc_debug_options {bool disable_dynamic_expansion_for_test_pattern;bool psr_phy_force_phy_power_down_up_level_2;bool dmub_send_az_pme_restore; +/* Log and break when a DC2 builder emits more than DC2_BLS_MAX_STEPS. */ +bool dc2_bls_report_step_overflow;uint32_t dml21_custom_derate_num_dpms;uint32_t dml21_custom_derate_at_dpm[DML2_MAX_NUM_DPM_LVL ];bool override_utm_client_qc_profile;
Signature · 1 line
2.56.1
PATCH v2 24/30 drm/amd/display: VRR Support on Direct MST Sinks
In reply to George ZhangFrom: Fangzhi Zuo <[email protected]>
[Why]
MST leaf connectors need their own downstream VRR capability check. Inferring support from root-link capabilities can expose VRR on unsupported leaves and miss valid HDMI VRR capability behind an MST branch.
Direct MST sink connections are supported when the downstream leaf reports the required capability. MST paths through a hub or dock also depend on the branch device's VRR rendering capability.
[How]
Read the leaf AUX downstream port data and combine IGNORE_MSA with the leaf refresh range when determining VRR capability. Attach the inherited VRR property to MST connectors and add leaf-AUX and non-MST isolation KUnit coverage.
--- .../display/amdgpu_dm/amdgpu_dm_connector.c | 44 +++++- .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 3 +- .../tests/amdgpu_dm_connector_test.c | 130 ++++++++++++++++++ .../tests/amdgpu_dm_mst_types_test.c | 2 + 4 files changed, 176 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c +42 -2
@@ -3872,6 +3872,7 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,const struct edid *edid;bool force_hdmi_vrr = false;bool freesync_capable = false; +bool mst_ignore_msa = false;enum adaptive_sync_type as_type =ADAPTIVE_SYNC_TYPE_NONE ;if (!connector->state) {
@@ -3883,6 +3884,11 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, amdgpu_dm_connector->dc_sink : amdgpu_dm_connector->dc_em_sink; +if (sink && sink->sink_signal ==SIGNAL_TYPE_DISPLAY_PORT_MST ) { + amdgpu_dm_connector->as_type =ADAPTIVE_SYNC_TYPE_NONE ; + amdgpu_dm_connector->pack_sdp_v1_3 = false; + } +drm_edid_connector_update (connector, drm_edid);if (!drm_edid || !sink) {
@@ -3917,7 +3923,40 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, connector->display_info.monitor_range.max_vfreq == 0))parse_edid_displayid_vrr (connector, edid); -if (edid && (sink->sink_signal ==SIGNAL_TYPE_DISPLAY_PORT || +if (edid && sink->sink_signal ==SIGNAL_TYPE_DISPLAY_PORT_MST && + amdgpu_dm_connector->mst_output_port) { +struct drm_dp_aux *aux = &amdgpu_dm_connector->mst_output_port->aux; +u8 port_count =0 ; +int msa_ret; + + has_vsdb =get_amd_vsdb (amdgpu_dm_connector, &vsdb_info) !=0 ; + amdgpu_dm_connector->vsdb_info = vsdb_info; +if (has_vsdb && vsdb_info.freesync_supported) { + amdgpu_dm_connector->min_vfreq = vsdb_info.min_refresh_rate_hz; + amdgpu_dm_connector->max_vfreq = vsdb_info.max_refresh_rate_hz; + }else { + amdgpu_dm_connector->min_vfreq = + connector->display_info.monitor_range.min_vfreq; + amdgpu_dm_connector->max_vfreq = + connector->display_info.monitor_range.max_vfreq; + } + +/* Read IGNORE_MSA from the downstream MST receiver. */ + msa_ret =drm_dp_dpcd_readb (aux,DP_DOWN_STREAM_PORT_COUNT , &port_count); + mst_ignore_msa = msa_ret ==1 && + (port_count &DP_MSA_TIMING_PAR_IGNORED ); + freesync_capable = mst_ignore_msa && + amdgpu_dm_connector->min_vfreq >0 && + amdgpu_dm_connector->max_vfreq > amdgpu_dm_connector->min_vfreq && + amdgpu_dm_connector->max_vfreq - amdgpu_dm_connector->min_vfreq >10 ; + +drm_info (connector->dev, +"VRR: MST leaf %s port=%u msa_ret=%d ignore_msa=%d range=%d-%dHz capable=%d\n" , + connector->name, amdgpu_dm_connector->mst_output_port->port_num, + msa_ret, mst_ignore_msa, + amdgpu_dm_connector->min_vfreq, amdgpu_dm_connector->max_vfreq, + freesync_capable); + }else if (edid && (sink->sink_signal ==SIGNAL_TYPE_DISPLAY_PORT || sink->sink_signal ==SIGNAL_TYPE_EDP )) {if (amdgpu_dm_connector->dc_link && amdgpu_dm_connector->dc_link->dpcd_caps.allow_invalid_MSA_timing_param) {
@@ -4019,7 +4058,8 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, } } -if (amdgpu_dm_connector->dc_link) +if (amdgpu_dm_connector->dc_link && + sink->sink_signal !=SIGNAL_TYPE_DISPLAY_PORT_MST ) as_type =dm_get_adaptive_sync_support_type (amdgpu_dm_connector->dc_link);if (as_type ==FREESYNC_TYPE_PCON_IN_WHITELIST ) {
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +2 -1
@@ -715,7 +715,8 @@ dm_dp_add_mst_connector(struct drm_dp_mst_topology_mgr *mgr, connector->vrr_capable_property = master->base.vrr_capable_property;if (connector->vrr_capable_property) -drm_connector_attach_vrr_capable_property (connector); +drm_object_attach_property (&connector->base, + connector->vrr_capable_property,0 ); drm_object_attach_property( &connector->base,
drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c +130 -0
154 lines not on this page · raw message
drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_mst_types_test.c +2 -0
@@ -1476,6 +1476,8 @@ static void dm_mst_test_add_mst_connector_inherits_props(struct kunit *test)KUNIT_EXPECT_PTR_EQ (test, connector->colorspace_property, ctx.master->base.colorspace_property);KUNIT_EXPECT_TRUE (test,dm_mst_test_has_prop (connector, connector->max_bpc_property)); +KUNIT_EXPECT_TRUE (test, +dm_mst_test_has_prop (connector, connector->vrr_capable_property));KUNIT_EXPECT_TRUE (test,dm_mst_test_has_prop (connector, connector->colorspace_property));dm_dp_mst_connector_destroy (connector);
Signature · 1 line
2.56.1
PATCH v2 25/30 drm/amd/display: Program YCbCr output in DC2
In reply to George ZhangFrom: Tony Cheng <[email protected]>
[Why]
The DC2 commit on dcn401 rejects every stream that is not RGB in sRGB. A YCbCr display falls back to the error path.
[How]
Remove the RGB sRGB stream check. Two steps had fixed RGB sRGB values. Make them follow the stream, as DC1 does:
- The DPG blank takes the black of the output color space from color_space_to_black_color, as dcn20_blank_pixel_data does.
- Every pixel rate divider step takes its divider from the timing. The divider is 2 for 4:2:0 and 4 for other encodings. This is the value that dcn401_enable_stream_timing sets for the virtual signal. dccg401_set_pixel_rate_div accepts only 2 and 4. Thus the divide by one from dcn401_enable_stream does not change the register. Remove the step meta that held a fixed divider.
- The builder calculates the divider itself. The build includes the dcn401 hwseq only with DC_FP, and it includes the builder without DC_FP.
The FMT, the dynamic expansion, the left edge extra pixel and the output CSC already follow the stream, as in DC1.
--- .../bls_builder/bls_builder_private_types.h | 3 -- .../bls_builder/dcn401_non_seamless_builder.c | 7 ++-- .../dc/bls_builder/dcn401_seamless_builder.c | 33 ++++++++++--------- 3 files changed, 20 insertions(+), 23 deletions(-)
drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_private_types.h +0 -3
@@ -115,9 +115,6 @@ struct dcn401_commit_step_meta {struct {enum streamclk_source src; } dccg_set_dtbclk_p_src; -struct { -enum pixel_rate_div k1; - } dccg_set_pixel_rate_div;struct {bool connect; } link_enc_connect_dig_be_to_fe;
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c +2 -5
@@ -282,8 +282,7 @@ static const struct dcn401_commit_step stream_timing[] = { { .func = OPP_PROGRAM_FMT }, { .func = OPP_SET_DYN_EXPANSION }, - { .func = DCCG_SET_PIXEL_RATE_DIV, - .meta.dccg_set_pixel_rate_div.k1 = PIXEL_RATE_DIV_BY_4 }, + { .func = DCCG_SET_PIXEL_RATE_DIV }, { .func = OPTC_SET_ODM_COMBINE }, { .func = DCCG_SET_DTBCLK_P_SRC, .meta.dccg_set_dtbclk_p_src.src = DPREFCLK },
@@ -330,9 +329,7 @@ static const struct dcn401_commit_step optc_dsc[] = {static const struct dcn401_commit_step output[] = { { .func =DIO_LINK_ENC_ENABLE_DP_OUTPUT }, { .func =DCCG_ENABLE_SYMCLK_SE }, -/* dcn401_enable_stream divides by one unless the signal is HDMI or DVI. */ - { .func =DCCG_SET_PIXEL_RATE_DIV , - .meta.dccg_set_pixel_rate_div.k1 =PIXEL_RATE_DIV_BY_1 }, + { .func =DCCG_SET_PIXEL_RATE_DIV }, { .func =DIO_LINK_ENC_CONNECT_DIG_BE_TO_FE , .meta.link_enc_connect_dig_be_to_fe.connect = true }, { .func =TG_SET_EARLY_CONTROL },
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +18 -15
@@ -204,17 +204,6 @@ static bool check_no_stereo(const struct dc *dc,TIMING_3D_FORMAT_NONE ; } -/* The DPG black and the pixel rate divider are fixed for RGB. */ -static bool check_rgb_srgb (const struct dc *dc, -const struct dc_state *state,unsigned int i) -{ -const struct dc_stream_state *stream = state->streams[i]; - - (void )dc; -return stream->timing.pixel_encoding ==PIXEL_ENCODING_RGB && - stream->output_color_space ==COLOR_SPACE_SRGB ; -} -static bool check_no_drr (const struct dc *dc,const struct dc_state *state,unsigned int i) {
@@ -462,7 +451,6 @@ static enum bls_builder_result dcn401_check_one_stream(const struct dc *dc,CHECK_STREAM_CONDITION (no_stereo,"timing is stereo" );CHECK_STREAM_CONDITION (dsc_pixel_clock,"dsc pixel clock is 48 MHz or less" ); -CHECK_STREAM_CONDITION (rgb_srgb,"stream is not RGB sRGB" );CHECK_STREAM_CONDITION (no_drr,"DRR is set" );CHECK_STREAM_CONDITION (no_boot_dpms_writeback,"seamless boot, dpms, or writeback is set" );
@@ -1870,8 +1858,8 @@ static uint32_t dcn401_early_cntl(const struct pipe_ctx *pipe) }/* -* dcn20_blank_pixel_data: sRGB black over the ODM slice of this OPP head, -* or the video on unblank. +* dcn20_blank_pixel_data: the black of the output color space over the ODM +* slice of this OPP head, or the video on unblank. */ static void dcn401_opp_blank_params(const struct dc *dc, struct pipe_ctx *pipe, bool unblank,
@@ -1885,6 +1873,8 @@ static void dcn401_opp_blank_params(const struct dc *dc,CONTROLLER_DP_TEST_PATTERN_SOLID_COLOR ; p->color_space =CONTROLLER_DP_COLOR_SPACE_UDEFINED ; p->color_depth = timing->display_color_depth; +color_space_to_black_color (dc, pipe->stream->output_color_space, + &p->solid_color); p->use_solid_color = true; p->width = slice.width; p->height = slice.height;
@@ -2074,6 +2064,19 @@ static enum dc_cm_lut_size dcn401_lut_mode_size( CM_LUT_SIZE_999 :CM_LUT_SIZE_171717 ; } +/* +* The divider dcn401_enable_stream_timing sets for the virtual signal. The +* divide by one dcn401_enable_stream passes later is a no-op, because +* dccg401_set_pixel_rate_div accepts only 2 and 4. The hwseq is built only +* with DC_FP; the builder is built without it. +*/ +static enum pixel_rate_div dcn401_pixel_rate_div ( +const struct pipe_ctx *pipe) +{ +return pipe->stream->timing.pixel_encoding ==PIXEL_ENCODING_YCBCR420 ? +PIXEL_RATE_DIV_BY_2 :PIXEL_RATE_DIV_BY_4 ; +} +/* Writes one entry; build sized every sequence before adding to it. */ static void dcn401_add_step(struct block_sequence_state *sequence, const struct dcn401_commit_step_args *args,
@@ -2365,7 +2368,7 @@ static void dcn401_add_step(struct block_sequence_state *sequence, p->dccg_set_pixel_rate_div_params.otg_inst = pipe->stream_res.tg->inst; p->dccg_set_pixel_rate_div_params.k1 = - m->dccg_set_pixel_rate_div.k1; +dcn401_pixel_rate_div (pipe); p->dccg_set_pixel_rate_div_params.k2 =PIXEL_RATE_DIV_NA ;break ;case CLK_SRC_PROGRAM_PIX_CLK :
Signature · 1 line
2.56.1
PATCH v2 26/30 drm/amd/display: Skip a stream with no OTG master in DC2
In reply to George ZhangFrom: Tony Cheng <[email protected]>
[Why]resource_get_otg_master_for_stream can return NULL, and the dcn401 OTG master walker passes the result on.
[How]
Skip the stream when it has no OTG master.
--- .../drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +2 -0
@@ -2866,6 +2866,8 @@ static void dcn401_add_per_otg_master(struct block_sequence_state *sequence,continue ; args.pipe =resource_get_otg_master_for_stream ( &state->res_ctx, state->streams[i]); +if (!args.pipe) +continue ;dcn401_add_steps (sequence, &args, steps, count); } }
Signature · 1 line
2.56.1
PATCH v2 27/30 drm/amd/display: Sync OTG timing in the DC2 non-seamless commit
In reply to George ZhangFrom: Tony Cheng <[email protected]>
[Why]
When a commit enables a second stream with the same timing, DC calls dc_trigger_sync. The new OTG resets to the OTG that shows a plane, so the two OTGs start at the same position. DC runs the sync again after optimize_bandwidth, because the clock update can move the OTGs. The dcn401 DC2 non-seamless builder does neither, so the second OTG starts without a reset.
[How]
Add the BLS functions that DC uses for the sync: enable the reset trigger, wait for the reset and disable the reset trigger. The executor wait polls for a limited number of frames and returns whether the reset occurred. The builder lets the sequence continue on a missed reset.
The walker finds the OTG to reset to for each OTG master: the first OTG master with the same timing that shows a plane, else the first one. The builder adds the sync for each new OTG master that has an OTG to reset to, after the stream enable and again after the postamble.
DC raises the DPG height while the OTGs reset only as a workaround, so the workaround manager adds the DPG height steps around each run of reset trigger steps from the target state.
--- .../bls_builder/bls_builder_private_types.h | 2 + .../dc/bls_builder/dcn401_builder_internal.h | 2 + .../bls_builder/dcn401_non_seamless_builder.c | 43 ++++++ .../dc/bls_builder/dcn401_seamless_builder.c | 57 ++++++++ .../display/dc/bls_executor/bls_executor.c | 59 +++++++++ .../gpu/drm/amd/display/dc/core2/dc_core2.c | 6 +- .../gpu/drm/amd/display/dc/core2/dc_core2.h | 1 + .../drm/amd/display/dc/core2/dc_core2_init.c | 2 +- .../drm/amd/display/dc/hwss/hw_sequencer.h | 31 +++++ .../workaround_manager/workaround_manager.c | 122 +++++++++++++++++- 10 files changed, 316 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder_private_types.h +2 -0
@@ -137,6 +137,8 @@ struct dcn401_commit_step_meta {/* The OPP MPC tree has no plane yet. */ bool opp_tree_empty;bool no_dsc; +/* The OTG master of the pipe has no OTG to reset to. */ +bool no_timing_sync_source;struct dcn401_pipe_deltas pipe_deltas;/* * Skip only when each delta named in pipe_deltas is true. Clear,
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h +2 -0
@@ -129,6 +129,8 @@ struct dcn401_commit_step_args {bool hardware_remapped;/* update_flags: a stream change or a non-address plane change. */ bool pipe_configs_changed; +/* The new state OTG master that pipe resets its timing to, or NULL. */ +const struct pipe_ctx *timing_sync_source; };/*
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c +43 -0
67 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +57 -0
93 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/bls_executor/bls_executor.c +59 -0
77 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/core2/dc_core2.c +4 -2
@@ -58,6 +58,7 @@ void core2_destruct(struct dc *dc)bool core2_run_sequence (struct dc *dc,const struct bls_builder *builder,const struct workaround_manager *wam, +const struct dc_state *target,struct block_sequence *steps,unsigned int *num_steps) {struct workaround_context wa_ctx = {0 };
@@ -67,6 +68,7 @@ bool core2_run_sequence(struct dc *dc, sequence.steps = steps; sequence.num_steps = num_steps; wa_ctx.current_state = dc->current_state; + wa_ctx.target = target; wa_ctx.builder_name = builder->name; wa_ctx.dcn_version = dc->ctx->dce_version; wa_ctx.bug_wa = &dc->work_arounds;
@@ -109,7 +111,7 @@ static bool core2_query_accelerated_mode(struct dc *dc)if (builder->build.declarative (params) !=BLS_BUILD_SUCCESS || params->tail_num_steps || - !core2_run_sequence (dc, builder, wam, + !core2_run_sequence (dc, builder, wam,NULL , params->head_sequence, ¶ms->head_num_steps)) accelerated_mode = false;
@@ -202,7 +204,7 @@ static enum dc_status core2_build_and_run(struct dc *dc, status =DC_NOT_SUPPORTED ; goto out; } -if (!core2_run_sequence (dc, builder, wam, +if (!core2_run_sequence (dc, builder, wam, new_state, params->head_sequence, ¶ms->head_num_steps)) goto out;
drivers/gpu/drm/amd/display/dc/core2/dc_core2.h +1 -0
@@ -25,6 +25,7 @@ void core2_destruct(struct dc *dc);/* Applies workarounds to a built head sequence and executes it. */ bool core2_run_sequence (struct dc *dc,const struct bls_builder *builder,const struct workaround_manager *wam, +const struct dc_state *target,struct block_sequence *steps,unsigned int *num_steps);#endif /* DC_CORE2_H_ */
drivers/gpu/drm/amd/display/dc/core2/dc_core2_init.c +1 -1
@@ -293,7 +293,7 @@ static void core2_run_wrapped_hardware_init(struct dc *dc)if (build_result !=BLS_BUILD_SUCCESS && build_result !=BLS_BUILD_MORE_STAGES ) goto out; -if (!core2_run_sequence (dc, builder, wam, +if (!core2_run_sequence (dc, builder, wam,NULL , params->head_sequence, ¶ms->head_num_steps)) goto out;if (builder->postprocess)
drivers/gpu/drm/amd/display/dc/hwss/hw_sequencer.h +31 -0
@@ -416,6 +416,27 @@ struct tg_wait_odm_doublebuffer_pending_clear_params {struct timing_generator *tg; }; +struct tg_enable_reset_trigger_params { +struct timing_generator *tg; +int source_tg_inst; +}; + +struct tg_wait_for_reset_trigger_params { +struct timing_generator *tg; +unsigned int frames; +bool continue_on_error; +}; + +struct tg_disable_reset_trigger_params { +struct timing_generator *tg; +}; + +struct opp_program_dpg_dimensions_params { +struct output_pixel_processor *opp; +uint32_t width; +uint32_t height; +}; +struct tg_program_stereo_params {struct timing_generator *tg;const struct dc_crtc_timing *timing;
@@ -1710,6 +1731,12 @@ union block_sequence_params {struct tg_disable_crtc_params tg_disable_crtc_params;struct tg_wait_odm_doublebuffer_pending_clear_params tg_wait_odm_doublebuffer_pending_clear_params; +struct tg_enable_reset_trigger_params tg_enable_reset_trigger_params; +struct tg_wait_for_reset_trigger_params + tg_wait_for_reset_trigger_params; +struct tg_disable_reset_trigger_params tg_disable_reset_trigger_params; +struct opp_program_dpg_dimensions_params + opp_program_dpg_dimensions_params;struct tg_program_stereo_params tg_program_stereo_params;struct opp_program_stereo_params opp_program_stereo_params;struct opp_wait_for_blank_complete_params
@@ -2002,6 +2029,10 @@ enum block_sequence_func {FPGA_SET_DTBCLK ,FPGA_SET_DPREFCLK ,FPGA_SET_REFCLK , +TG_ENABLE_RESET_TRIGGER , +TG_WAIT_FOR_RESET_TRIGGER , +TG_DISABLE_RESET_TRIGGER , +OPP_PROGRAM_DPG_DIMENSIONS ,/* This must be the last value in this enum, add new ones above */ HWSS_BLOCK_SEQUENCE_FUNC_COUNT };
drivers/gpu/drm/amd/display/dc/workaround_manager/workaround_manager.c +116 -6
135 lines not on this page · raw message
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH v2 27/30] drm/amd/display: Sync OTG timing in the DC2 non-seamless commit
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] drm/amd/display: missed OTG sync in dcn401_timing_sync_source() - [Medium] drm/amd/display: data…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] drm/amd/display: missed OTG sync in dcn401_timing_sync_source()
- [Medium] drm/amd/display: data race on static buffers in wa_dpg_height_apply()
--
commit 38a0b1198247f1d2010554b1b7b6370ab3f8b13a
Author: Tony Cheng <[email protected]>
drm/amd/display: Sync OTG timing in the DC2 non-seamless commit
This commit adds OTG timing synchronization steps to the DCN401 DC2 non-seamless commit builder and registers a workaround to raise the DPG height around the OTG reset trigger steps.
Quoted 4 lines
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +0
-0
[ ... ]
Quoted 29 lines
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +25
-0@@ -2853,6 +2871,42 @@ static bool dcn401_walks_stream(const struct dcn401_commit_step_args *args, args->new_state, stream); } +/* +* The OTG master that pipe resets to, chosen as program_timing_sync does: +* the first OTG master with the same timing that shows a plane, else the +* first one. NULL when that is pipe. +*/ +static const struct pipe_ctx *dcn401_timing_sync_source ( +const struct dcn401_commit_step_args *args, +const struct pipe_ctx *pipe) +{ +const struct dc_state_update_flags *flags = args->update_flags; +const struct pipe_ctx *source =NULL ; +const struct pipe_ctx *member; +unsigned int i; + +if (args->dc->debug.disable_timing_sync) +return NULL ; +for (i =0 ; i < args->dc->res_pool->pipe_count; i++) { + member = &args->new_state->res_ctx.pipe_ctx[i]; +if (!member->stream || member->top_pipe || + member->prev_odm_pipe || + !resource_are_streams_timing_synchronizable ( + member->stream, pipe->stream)) +continue ; +if (flags->cur_pipes[i].has_plane && + flags->new_pipes[i].has_plane) {
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c static bool dcn401_walks_stream(const struct dcn401_commit_step_args *args, · line 2908
Quoted 10 lines
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +10
-0+ source = member; +break ; + } +if (!source) + source = member; + } +if (!source || source->pipe_idx == pipe->pipe_idx) +return NULL ; +return source; +}
[Severity: Medium]
Can dcn401_timing_sync_source() skip OTG timing synchronization when a kept stream had no plane in current_state?
Because dcn401_timing_sync_source() only prioritizes an OTG master when both flags->cur_pipes[i].has_plane and flags->new_pipes[i].has_plane are set, it falls back to the lowest matching pipe_idx when a kept stream had no plane in current_state. If a newly enabled stream with the same timing is allocated on a lower pipe_idx (e.g. pipe 0) than the kept stream (e.g. pipe 1), dcn401_timing_sync_source() picks pipe 0 as source and returns NULL for pipe 0 because source->pipe_idx == pipe->pipe_idx. Meanwhile, when bls_sync is expanded, dcn401_walks_stream() skips all kept streams (!dcn401_stream_kept()), so neither stream emits TG_ENABLE_RESET_TRIGGER and the two OTGs remain out of phase.
In addition, if that kept stream gains a plane during the commit, dcn401_add_stream_update() enables its plane and unblanks its OPP before bls_postamble, yet the second bls_sync pass still checks flags->cur_pipes[i].has_plane && flags->new_pipes[i].has_plane and fails to select the newly unblanked kept stream as the timing sync source.
Quoted 19 lines
drivers/gpu/drm/amd/display/dc/workaround_manager/workaround_manager.c +2
-5@@ -4,19 +4,129 @@*/ #include "dm_services.h" +#include "core_types.h" #include "workaround_manager/workaround_manager.h" -static const struct workaround_manager dc2_wam_empty = { - .registry =NULL , - .count =0 , -}; -/* BSS, not the stack: 64 block_sequence entries exceed the kernel frame limit. */ static struct block_sequence dc2_wam_saved_steps[DC2_BLS_MAX_STEPS ]; +static struct block_sequence dc2_wam_input_steps[DC2_BLS_MAX_STEPS ];
[ ... ]
Quoted 20 lines
drivers/gpu/drm/amd/display/dc/workaround_manager/workaround_manager.c +20
-0+static enum workaround_manager_result wa_dpg_height_apply ( +struct block_sequence_state *bls, +const struct workaround_context *ctx) +{ +struct block_sequence *in = dc2_wam_input_steps; +unsigned int num = *bls->num_steps; +unsigned int n =0 ; +unsigned int i =0 ; +unsigned int j =0 ; + +memmove (in, bls->steps, num *sizeof (in[0 ])); +for (i =0 ; i < num; i = j) { +for (j = i +1 ; j < num && in[j].func == in[i].func; j++) + ; +if (in[i].func ==TG_ENABLE_RESET_TRIGGER && + !wa_dpg_height_add (bls->steps, &n, ctx->target, + &in[i], j - i, true)) +return WAM_SIZE_EXCEEDED ; +if (n + j - i >DC2_BLS_MAX_STEPS ) +return WAM_SIZE_EXCEEDED ;
drivers/gpu/drm/amd/display/dc/workaround_manager/workaround_manager.c line 113
Quoted 10 lines
drivers/gpu/drm/amd/display/dc/workaround_manager/workaround_manager.c +10
-0+memmove (&bls->steps[n], &in[i], (j - i) *sizeof (in[0 ])); + n += j - i; +if (in[i].func ==TG_DISABLE_RESET_TRIGGER && + !wa_dpg_height_add (bls->steps, &n, ctx->target, + &in[i], j - i, false)) +return WAM_SIZE_EXCEEDED ; + } + *bls->num_steps = n; +return WAM_OK ; +}
[Severity: Medium]
Can concurrent calls to workaround_manager_apply() race on the static dc2_wam_input_steps and dc2_wam_saved_steps arrays?
dc2_wam_input_steps and dc2_wam_saved_steps are file-scope static buffers shared across all struct dc instances without a lock. If two threads run core2_run_sequence() concurrently (for example, modesets on two AMD GPUs, each serialized only by its own per-device adev->dm.dc_lock), they will overwrite dc2_wam_input_steps and dc2_wam_saved_steps while rebuilding or restoring bls->steps, corrupting the block_sequence array passed to dc2_bls_execute().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=27
PATCH v2 28/30 drm/amd/display: Move shared dcn401 builder code to its own file
In reply to George ZhangFrom: Tony Cheng <[email protected]>
[Why]
The dcn401 DC2 seamless builder file also holds the code that the non-seamless builder uses, so a change to that code reads as a change to the seamless update.
[How]
Move the support checks, the pipe removal tables and the step walkers to dcn401_builder_internal.c, unchanged. Export the two helpers both files call. Add the file to the build lists.
--- drivers/gpu/drm/amd/display/dc/Makefile | 1 + .../dc/bls_builder/dcn401_builder_internal.c | 1817 +++++++++++++++++ .../dc/bls_builder/dcn401_builder_internal.h | 6 + .../dc/bls_builder/dcn401_seamless_builder.c | 1792 ---------------- 4 files changed, 1824 insertions(+), 1792 deletions(-) create mode 100644 drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.c
drivers/gpu/drm/amd/display/dc/Makefile +1 -0
@@ -85,6 +85,7 @@ FILES += core2/dc_core2.o FILES += core2/dc_core2_init.o FILES += core2/dc_core2_legacy_init.o FILES += bls_builder/bls_builder.o +FILES += bls_builder/dcn401_builder_internal.o FILES += bls_builder/dcn401_seamless_builder.o FILES += bls_builder/dcn401_init_builder.o FILES += bls_builder/dcn401_init_builder_legacy.o
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.c new file +1817 -0
1,817 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h +6 -0
@@ -83,6 +83,12 @@ const struct pipe_ctx *dcn401_otg_master(const struct dc_state *state,/* The index of stream in state, or -1. */ int dcn401_stream_index (const struct dc_state *state,const struct dc_stream_state *stream); +bool dcn401_pipe_on_stream (const struct pipe_ctx *pipe, +const struct dc_stream_state *stream); +/* stream has the same OPP heads in both states. */ +bool dcn401_same_opp_heads (const struct dc_state *current_state, +const struct dc_state *new_state, +const struct dc_stream_state *stream);/*
drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c +0 -1792
1,164 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.56.1
Part of the diff is not shown here. View the raw message.
PATCH v2 29/30 drm/amd/display: Allow disabling CRC capture when the stream is gone
In reply to George ZhangFrom: James Lin <[email protected]>
[Why]
Stopping CRC capture while the CRTC has no stream (e.g. after DPMS off) makes amdgpu_dm_crtc_configure_crc_source() return -EINVAL. That aborts amdgpu_dm_crtc_set_crc_source() before it clears crc_src and resets crc_skip_count. The stale crc_src makes the CRC handler capture again as soon as the next stream is enabled, and with crc_skip_count still >= 2 the first (all-zero) CRC of the fresh CRC engine is reported to userspace. This shows up as intermittent failures of igt@kms_pipe_crc_basic@disable-crc-after-crtc
(CRC mismatch, 0x59b7 != 0x0).
[How]
Only return -EINVAL for a missing stream when enabling, where programming is deferred to stream enable. When disabling there is nothing to program, so return success and let the caller drop its vblank reference, clear crc_src and reset the skip count. Also clear the positive remaining-jiffies value returned by wait_for_completion_interruptible_timeout() so a successful wait for a pending commit isn't returned to the caller as a non-zero result.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c | 12 ++++++++++-- .../amd/display/amdgpu_dm/tests/amdgpu_dm_crc_test.c | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c +10 -2
@@ -577,9 +577,13 @@ int amdgpu_dm_crtc_configure_crc_source(struct drm_crtc *crtc,int ret =0 ;enum crc_poly_mode crc_poly_mode =CRC_POLY_MODE_16 ; -/* Configuration will be deferred to stream enable. */ +/* +* Enabling is deferred to stream enable. Disabling with no stream (e.g. +* DPMS off) has nothing to program, but must still succeed so the caller +* clears crc_src and the skip count. +*/ if (!stream_state) -return -EINVAL ; +return enable ? -EINVAL :0 ;mutex_lock (&adev->dm.dc_lock);
@@ -696,6 +700,10 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name) ret = -ETIMEDOUT ; goto cleanup; } + +/* Wait succeeded; don't leak the remaining jiffies. */ +if (ret >0 ) + ret =0 ; } enable =amdgpu_dm_is_valid_crc_source (source);
drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crc_test.c +2 -2
@@ -581,7 +581,7 @@ static void dm_test_crtc_set_crc_source_none_no_stream(struct kunit *test) ret =amdgpu_dm_crtc_set_crc_source (&acrtc->base,"none" ); -KUNIT_EXPECT_EQ (test, ret, -EINVAL ); +KUNIT_EXPECT_EQ (test, ret,0 );KUNIT_EXPECT_EQ (test, acrtc->dm_irq_params.crc_src,AMDGPU_DM_PIPE_CRC_SOURCE_NONE );KUNIT_EXPECT_EQ (test, dm_state->crc_skip_count,0 );
@@ -618,7 +618,7 @@ static void dm_test_crtc_set_crc_source_none_commit(struct kunit *test) ret =amdgpu_dm_crtc_set_crc_source (&acrtc->base,"none" ); -KUNIT_EXPECT_EQ (test, ret, -EINVAL ); +KUNIT_EXPECT_EQ (test, ret,0 );KUNIT_EXPECT_EQ (test, dm_state->crc_skip_count,0 ); }
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH v2 29/30] drm/amd/display: Allow disabling CRC capture when the stream is gone
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] drm/amd/display: -ERESTARTSYS leak in amdgpu_dm_crtc_set_crc_source() - [Low] drm/amd/display…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] drm/amd/display: -ERESTARTSYS leak in amdgpu_dm_crtc_set_crc_source()
- [Low] drm/amd/display: missing Fixes trailers for CRC disable and wait fixes
--
commit 2f86e15468fe1d63c83a78c1c2e170de1de07582
Author: James Lin <[email protected]>
Quoted 22 lines
drm/amd/display: Allow disabling CRC capture when the stream is gone
[Why]
Stopping CRC capture while the CRTC has no stream (e.g. after DPMS off) makesamdgpu_dm_crtc_configure_crc_source()return-EINVAL. That abortsamdgpu_dm_crtc_set_crc_source()before it clearscrc_srcand resetscrc_skip_count. The stalecrc_srcmakes the CRC handler capture again as soon as the next stream is enabled, and withcrc_skip_countstill >= 2 the first (all-zero) CRC of the fresh CRC engine is reported to userspace. This shows up as intermittent failures of igt@kms_pipe_crc_basic@disable-crc-after-crtc
(CRC mismatch,0x59b7!=0x0).[How]
Only return-EINVALfor a missing stream when enabling, where programming is deferred to stream enable. When disabling there is nothing to program, so return success and let the caller drop its vblank reference, clearcrc_srcand reset the skip count. Also clear the positive remaining-jiffies value returned bywait_for_completion_interruptible_timeout()so a successful wait for a pending commit isn't returned to the caller as a non-zero result.
Quoted 2 lines
Signed-off-by James Lin <[email protected]>Signed-off-by George Zhang <[email protected]>
[Severity: Low]
Should this bug fix include Fixes tags for the commits that introduced the -EINVAL return on disable without a stream and the unreset wait return value?
Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c +0
-0
[ ... ]
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name) · line 709
Quoted 11 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c +4
-0@@ -696,6 +700,10 @@ int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name) ret = -ETIMEDOUT ; goto cleanup; } + +/* Wait succeeded; don't leak the remaining jiffies. */ +if (ret >0 ) + ret =0 ; } enable =amdgpu_dm_is_valid_crc_source (source);
[Severity: Medium]
Does amdgpu_dm_crtc_set_crc_source() still leak -ERESTARTSYS in ret when wait_for_completion_interruptible_timeout() is interrupted by a signal?
Because the check above only jumps to cleanup when ret < 0 && ret != -ERESTARTSYS, a signal interruption falls through with ret == -ERESTARTSYS. Any path that does not overwrite ret via drm_crtc_vblank_get() (such as disabling CRC capture or switching between active sources) completes the state update and then returns -ERESTARTSYS. Falling through before commit->hw_done completes also races with amdgpu_dm_atomic_commit_tail() reading acrtc->dm_irq_params.crc_src and calling amdgpu_dm_crtc_configure_crc_source().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=29
PATCH v2 30/30 drm/amd/display: Promote DC to 3.2.410
In reply to George ZhangFrom: Taimur Hassan <[email protected]>
This version brings along the following updates:
- Harden AUX handling: clamp the AUX reply length as unsigned, keep the DPCD read result signed in the MST ISR, and copy only the status byte on a DMUB AUX write status retry, with a test for the reply copy
- Cast the clamped rate conversion
- Make BLS sequences compliant: split HWSS_CURSOR_LOCK into flat BLS operations and make DPP_SET_INPUT_TRANSFER_FUNC BLS compliant
- Account for downspread and DFS in clock validation and read the max LSDMA bandwidth from DMU
- Precompute EASF lookup thresholds
- Add pipe init to core2
- Fix HDMI FRL no_timeout behavior
- Re-enable driver-controlled HUBP/DPP power gating on DCN42 and DCN42b
- DC2: program DSC on one stream, program YCbCr output, flip every DPP pipe of the stream, skip streams with no OTG master, and sync OTG timing in the non-seamless commit
- DC2: add a per-ASIC default for DC2 selection and report BLS step overflow behind a debug option
- Disable Replay and PSR across GPU reset and correctly block Panel Replay on MST
- Cover gamma 2.4 and 2.6 on the wide curve
- Improve P-state admissibility logic and revoke alternate channel P-State before pipe teardown
- Refactor Max VStartup calculations for DCN6
- Add VRR support on direct MST sinks
- Move shared dcn401 builder code to its own file
--- drivers/gpu/drm/amd/display/dc/dc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dc.h +1 -1
@@ -69,7 +69,7 @@ struct dcn_dsc_reg_state;struct dcn_optc_reg_state ;struct dcn_dccg_reg_state ; -#define DC_VER "3.2.409" +#define DC_VER "3.2.410"/** * MAX_SURFACES - representative of the upper bound of surfaces that can be piped to a single CRTC
Signature · 1 line
2.56.1
[email protected]
AI reviewRe: [PATCH v2 30/30] drm/amd/display: Promote DC to 3.2.410
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] drm/amd/display: DC 3.2.410 promotion changelog mismatch with series commits --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] drm/amd/display: DC 3.2.410 promotion changelog mismatch with series commits
--
commit d44c142751175f69f49e5d3c3e1947c837955596
Author: Taimur Hassan <[email protected]>
drm/amd/display: Promote DC to 3.2.410
This commit bumps the Display Core version macro DC_VER to 3.2.410 and summarizes the changes included in the promotion series.
Quoted 2 lines
- Disable Replay and PSR across GPU reset and correctly block Panel Replay on MST
[Severity: Low]
Does this changelog summary match the commits in the 3.2.410 promotion series? The series includes commit "drm/amd/display: block pr in mst right", but has no commit disabling Replay and PSR across GPU reset, and the summary omits commit "drm/amd/display: Allow disabling CRC capture when the stream is gone".
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=30