]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amd/display: Re-implement minimal transition deferral
authorJoshua Aberback <joshua.aberback@amd.com>
Fri, 12 Dec 2025 09:23:03 +0000 (04:23 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Sat, 10 Jan 2026 19:21:52 +0000 (14:21 -0500)
[Why]
The update v3 path got refactored into new functions, which happened just
before the previous implementation was submitted, which resulted in the
optimizations not executing. This commit re-implements the same logic in
the new codepath.

Reviewed-by: Aric Cyr <aric.cyr@amd.com>
Signed-off-by: Joshua Aberback <joshua.aberback@amd.com>
Signed-off-by: Matthew Stewart <matthew.stewart2@amd.com>
Tested-by: Dan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc.c

index 57f6a4c8afffd6dcbac16188bff7181d2cb870a3..aba5ad2a7a335f38e988793221dc363b6dd869a4 100644 (file)
@@ -7246,6 +7246,14 @@ static bool update_planes_and_stream_prepare_v3_intermediate_seamless(
        );
 }
 
+static void transition_countdown_init(struct dc *dc)
+{
+       dc->check_config.transition_countdown_to_steady_state =
+                       dc->debug.num_fast_flips_to_steady_state_override ?
+                       dc->debug.num_fast_flips_to_steady_state_override :
+                       NUM_FAST_FLIPS_TO_STEADY_STATE;
+}
+
 static bool update_planes_and_stream_prepare_v3(
                struct dc_update_scratch_space *scratch
 )
@@ -7305,9 +7313,17 @@ static bool update_planes_and_stream_prepare_v3(
        );
        if (seamless) {
                scratch->flow = UPDATE_V3_FLOW_NEW_CONTEXT_SEAMLESS;
+               if (scratch->dc->check_config.deferred_transition_state)
+                       /* reset countdown as steady state not reached */
+                       transition_countdown_init(scratch->dc);
                return true;
        }
 
+       if (!scratch->dc->debug.disable_deferred_minimal_transitions) {
+               scratch->dc->check_config.deferred_transition_state = true;
+               transition_countdown_init(scratch->dc);
+       }
+
        scratch->intermediate_context = create_minimal_transition_state(
                scratch->dc,
                scratch->new_context,
@@ -7351,7 +7367,8 @@ static bool update_planes_and_stream_prepare_v3(
 static void update_planes_and_stream_execute_v3_commit(
                const struct dc_update_scratch_space *scratch,
                bool intermediate_update,
-               bool intermediate_context
+               bool intermediate_context,
+               bool use_stream_update
 )
 {
        commit_planes_for_stream(
@@ -7359,7 +7376,7 @@ static void update_planes_and_stream_execute_v3_commit(
                        intermediate_update ? scratch->intermediate_updates : scratch->surface_updates,
                        intermediate_update ? scratch->intermediate_count : scratch->surface_count,
                        scratch->stream,
-                       intermediate_context ? NULL : scratch->stream_update,
+                       use_stream_update ? scratch->stream_update : NULL,
                        intermediate_context ? UPDATE_TYPE_FULL : scratch->update_type,
                        // `dc->current_state` only used in `NO_NEW_CONTEXT`, where it is equal to `new_context`
                        intermediate_context ? scratch->intermediate_context : scratch->new_context
@@ -7385,15 +7402,16 @@ static void update_planes_and_stream_execute_v3(
 
        case UPDATE_V3_FLOW_NO_NEW_CONTEXT_CONTEXT_FULL:
        case UPDATE_V3_FLOW_NEW_CONTEXT_SEAMLESS:
-               update_planes_and_stream_execute_v3_commit(scratch, false, false);
+               update_planes_and_stream_execute_v3_commit(scratch, false, false, true);
                break;
 
        case UPDATE_V3_FLOW_NEW_CONTEXT_MINIMAL_NEW:
-               update_planes_and_stream_execute_v3_commit(scratch, false, true);
+               update_planes_and_stream_execute_v3_commit(scratch, false, true,
+                               scratch->dc->check_config.deferred_transition_state);
                break;
 
        case UPDATE_V3_FLOW_NEW_CONTEXT_MINIMAL_CURRENT:
-               update_planes_and_stream_execute_v3_commit(scratch, true, true);
+               update_planes_and_stream_execute_v3_commit(scratch, true, true, false);
                break;
 
        case UPDATE_V3_FLOW_INVALID:
@@ -7402,13 +7420,6 @@ static void update_planes_and_stream_execute_v3(
        }
 }
 
-static void update_planes_and_stream_cleanup_v3_new_context(
-               struct dc_update_scratch_space *scratch
-)
-{
-       swap_and_release_current_context(scratch->dc, scratch->new_context, scratch->stream);
-}
-
 static void update_planes_and_stream_cleanup_v3_release_minimal(
                struct dc_update_scratch_space *scratch,
                bool backup
@@ -7439,17 +7450,23 @@ static bool update_planes_and_stream_cleanup_v3(
        switch (scratch->flow) {
        case UPDATE_V3_FLOW_NO_NEW_CONTEXT_CONTEXT_FAST:
        case UPDATE_V3_FLOW_NO_NEW_CONTEXT_CONTEXT_FULL:
-               // No cleanup required
+               if (scratch->dc->check_config.transition_countdown_to_steady_state)
+                       scratch->dc->check_config.transition_countdown_to_steady_state--;
                break;
 
        case UPDATE_V3_FLOW_NEW_CONTEXT_SEAMLESS:
-               update_planes_and_stream_cleanup_v3_new_context(scratch);
+               swap_and_release_current_context(scratch->dc, scratch->new_context, scratch->stream);
                break;
 
        case UPDATE_V3_FLOW_NEW_CONTEXT_MINIMAL_NEW:
                update_planes_and_stream_cleanup_v3_intermediate(scratch, false);
-               scratch->flow = UPDATE_V3_FLOW_NEW_CONTEXT_SEAMLESS;
-               return true;
+               if (scratch->dc->check_config.deferred_transition_state) {
+                       dc_state_release(scratch->new_context);
+               } else {
+                       scratch->flow = UPDATE_V3_FLOW_NEW_CONTEXT_SEAMLESS;
+                       return true;
+               }
+               break;
 
        case UPDATE_V3_FLOW_NEW_CONTEXT_MINIMAL_CURRENT:
                update_planes_and_stream_cleanup_v3_intermediate(scratch, true);