From: Clay King clayking@amd.com
[ Upstream commit ca74cc428f2b9d0170c56b473dbcfd7fa01daf2d ]
[Why] When transitioning between topologies such as multi-display to single display ODM 2:1, pipes might not be freed before use.
[How] In dc_commit_streams, commit an additional, minimal transition if original transition is not seamless to ensure pipes are freed.
Reviewed-by: Alvin Lee alvin.lee2@amd.com Signed-off-by: Clay King clayking@amd.com Signed-off-by: Wayne Lin wayne.lin@amd.com Tested-by: Daniel Wheeler daniel.wheeler@amd.com Signed-off-by: Alex Deucher alexander.deucher@amd.com Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES
Summary - Fixes a real, user-visible bug where non‑seamless topology transitions can reuse pipes before they are freed, causing underflow/corruption or visible glitches. - Small, localized change that mirrors an already‑used mitigation in other DC update paths. - No new features or ABI changes; guarded by existing hwss hook; low regression risk if prerequisites are present.
What the commit does - In dc_commit_streams, after building the new context and validating it, it inserts a guard: - If hwss indicates the pipe‑topology transition is not seamless, perform an intermediate “minimal transition” commit before committing the target state. - This frees up pipes cleanly and makes the final transition seamless.
Why it matters - Without this, transitions like multi‑display → single‑display ODM 2:1 can leave pipes allocated and immediately reuse them, which risks corruption/glitches. - The “minimal transition” sequence is the established way to safely reconfigure pipes to a minimal configuration before the final state.
Code context and references - Current dc_commit_streams validates the new state then commits it directly: - Validation: drivers/gpu/drm/amd/display/dc/core/dc.c:2177 - Commit: drivers/gpu/drm/amd/display/dc/core/dc.c:2183 - It only special‑cases ODM 2:1 exit before validation: - ODM 2:1 handling: drivers/gpu/drm/amd/display/dc/core/dc.c:2155-2169 - The proposed patch adds a seamlessness check between validation and commit: - Calls hwss.is_pipe_topology_transition_seamless(dc, current_state, context), and if false, performs commit_minimal_transition_state(dc, context). - This aligns dc_commit_streams with update_planes paths, which already perform the same seamlessness guard and minimal transition: - Seamless check and minimal transition in update path: drivers/gpu/drm/amd/display/dc/core/dc.c:4957-4961 - The seamlessness predicate hook was introduced earlier and implemented for DCN32: - Hook declaration: drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h:410+ - Implementation example: drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c (function dcn32_is_pipe_topology_transition_seamless)
Stability and regression risk - Change is confined to the AMD DC commit path and only triggers when the hwss hook reports a non‑seamless transition. - Uses an existing, widely used helper (commit_minimal_transition_state) that already has many refinements: - E.g., skipping forced ODM during minimal transition to keep it seamless (b04c21abe21ff), and generic non‑seamless detection and handling (d2dea1f140385, related v3 sequence work). - No architectural changes; behavior mirrors already‑trusted logic in plane/stream update. - Potential minor performance impact (an extra, minimal intermediate commit) only when necessary; functional correctness/glitch avoidance outweighs this.
Prerequisites and backport considerations - Requires the hwss.is_pipe_topology_transition_seamless hook and its implementation (added by “drm/amd/display: add seamless pipe topology transition check”). Stable trees lacking this will need that prerequisite backported first. - In some branches dc_validate_with_context signature differs: - In this tree it takes a `bool fast_validate` (drivers/gpu/drm/amd/display/dc/dc.h:1570-1574). - The patch snippet shows a newer enum mode (DC_VALIDATE_MODE_AND_PROGRAMMING). When backporting, keep using the existing boolean call pattern. - commit_minimal_transition_state return type varies by branch (bool vs enum in the snippet). In this tree it returns bool (drivers/gpu/drm/amd/display/dc/core/dc.c:4551). Adapt the return check accordingly during backport.
Conclusion - This is a targeted bug fix that prevents visible glitches and underflow by ensuring a seamless intermediate transition in dc_commit_streams. It aligns commit behavior with other DC update paths and is guarded by a capability hook. With prerequisites present, it is a strong candidate for stable backport.
drivers/gpu/drm/amd/display/dc/core/dc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index bb189f6773397..bc364792d9d31 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -2413,6 +2413,18 @@ enum dc_status dc_commit_streams(struct dc *dc, struct dc_commit_streams_params goto fail; }
+ /* + * If not already seamless, make transition seamless by inserting intermediate minimal transition + */ + if (dc->hwss.is_pipe_topology_transition_seamless && + !dc->hwss.is_pipe_topology_transition_seamless(dc, dc->current_state, context)) { + res = commit_minimal_transition_state(dc, context); + if (res != DC_OK) { + BREAK_TO_DEBUGGER(); + goto fail; + } + } + res = dc_commit_state_no_check(dc, context);
for (i = 0; i < params->stream_count; i++) {