From: Tony Cheng <[email protected]>

[Why]
The DC2 non-seamless commit builder disables every current stream and
enables every new stream. A commit that removes one of two streams
blanks the other stream, or fails when that stream shows a plane.

[How]
Do not program a stream that is in both states on the same pipes with
the same planes and blocks. The checks, the step walkers and the Core2
software state skip that stream.

Signed-off-by: Tony Cheng <[email protected]>
Signed-off-by: James Lin <[email protected]>
---
 .../amd/display/dc/bls_builder/bls_builder.h  |  8 +++++
 .../dc/bls_builder/dcn401_builder_internal.h  | 10 ++----
 .../bls_builder/dcn401_non_seamless_builder.c | 31 ++++++++++++-------
 .../dc/bls_builder/dcn401_seamless_builder.c  | 15 +++++++--
 .../gpu/drm/amd/display/dc/core2/dc_core2.c   | 16 +++++++---
 5 files changed, 52 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h 
b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
index 879ff188264d..f899c27ea836 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/bls_builder.h
@@ -133,3 +133,11 @@ struct bls_builder {
 
 const struct bls_builder *bls_builder_create(struct dc *dc,
                enum bls_builder_name name);
+
+/*
+ * stream is in both states on the same pipes, each with the same plane
+ * and blocks. DCN_DECL_NON_SEAMLESS_COMMIT leaves such a stream alone.
+ */
+bool dcn401_stream_unchanged(const struct dc_state *current_state,
+               const struct dc_state *new_state,
+               const struct dc_stream_state *stream);
diff --git 
a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h 
b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h
index 35ad8982db9a..2d832017f613 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_builder_internal.h
@@ -74,13 +74,6 @@ 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);
-/*
- * stream is in both states on the same pipes, each with the same plane
- * and blocks.
- */
-bool dcn401_stream_unchanged(const struct dc_state *current_state,
-               const struct dc_state *new_state,
-               const struct dc_stream_state *stream);
 
 
 /* What both builders need of the dc, before either state. */
@@ -92,7 +85,8 @@ enum bls_builder_result dcn401_check_stream_support(const 
struct dc *dc,
 
 /*
  * pipe is NULL only for the bandwidth and p-state steps. The walkers
- * expand only stream when it is set.
+ * expand only stream when it is set, else each stream that is not
+ * unchanged.
  */
 struct dcn401_commit_step_args {
        struct dc *dc;
diff --git 
a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c 
b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
index bfbe2e0e7eb2..dcd1c8a50429 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_non_seamless_builder.c
@@ -10,10 +10,11 @@
 #include "state_facts/state_facts.h"
 
 /*
- * DCN_DECL_NON_SEAMLESS_COMMIT for virtual streams without planes. It
- * disables every current stream, each with one or two planes, one per DPP
- * pipe, then enables every new stream, each with no plane. Planes are
- * added later by DCN_DECL_SEAMLESS_UPDATE, not by this commit. Each
+ * DCN_DECL_NON_SEAMLESS_COMMIT for virtual streams. It disables every
+ * current stream, each with one or two planes, one per DPP pipe, then
+ * enables every new stream, each with no plane. A stream that is
+ * unchanged keeps its pipes and planes, and the commit programs none of
+ * them. Planes are added later by DCN_DECL_SEAMLESS_UPDATE. Each
  * stream is in ODM bypass, 2:1 or 3:1, with one OPP head and at most one
  * DPP pipe per slice.
  *
@@ -120,19 +121,23 @@ static enum bls_builder_result dcn401_check_new_stream(
 
 static enum bls_builder_result dcn401_check_commit_state_support(
                const struct dc *dc, const struct dc_state *current_state,
-               const struct dc_state *new_state)
+               const struct dc_state *new_state, bool is_current)
 {
-       const struct dc_state *state = dcn401_checked_state(current_state,
-                       new_state);
+       const struct dc_state *state = is_current ? current_state : new_state;
        enum bls_builder_result result;
        unsigned int i;
 
-       result = dcn401_check_stream_support(dc, current_state, new_state);
+       result = dcn401_check_stream_support(dc, is_current ? state : NULL,
+                       is_current ? NULL : state);
        for (i = 0; result == BLS_BUILD_SUCCESS && i < state->stream_count;
-                       i++)
-               result = current_state ?
+                       i++) {
+               if (dcn401_stream_unchanged(current_state, new_state,
+                               state->streams[i]))
+                       continue;
+               result = is_current ?
                                dcn401_check_current_stream(dc, state, i) :
                                dcn401_check_new_stream(dc, state, i);
+       }
        return result;
 }
 
@@ -175,10 +180,12 @@ static enum bls_builder_result 
dcn401_check_non_seamless_commit_support(
                return result;
        CHECK_CONDITION(stream_config_update, "stream config update is set");
 
-       result = dcn401_check_commit_state_support(dc, current_state, NULL);
+       result = dcn401_check_commit_state_support(dc, current_state,
+                       new_state, true);
        if (result != BLS_BUILD_SUCCESS)
                return result;
-       result = dcn401_check_commit_state_support(dc, NULL, new_state);
+       result = dcn401_check_commit_state_support(dc, current_state,
+                       new_state, false);
        if (result != BLS_BUILD_SUCCESS)
                return result;
 
diff --git 
a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c 
b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
index 178598f18517..3f0285763d52 100644
--- a/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
+++ b/drivers/gpu/drm/amd/display/dc/bls_builder/dcn401_seamless_builder.c
@@ -2152,6 +2152,15 @@ static void dcn401_add_steps(struct block_sequence_state 
*sequence,
        }
 }
 
+static bool dcn401_walks_stream(const struct dcn401_commit_step_args *args,
+               const struct dc_stream_state *stream)
+{
+       if (args->stream)
+               return stream == args->stream;
+       return !dcn401_stream_unchanged(args->current_state, args->new_state,
+                       stream);
+}
+
 static void dcn401_add_per_otg_master(struct block_sequence_state *sequence,
                const struct dcn401_commit_step_args *state_args,
                struct dc_state *state,
@@ -2161,7 +2170,7 @@ static void dcn401_add_per_otg_master(struct 
block_sequence_state *sequence,
        unsigned int i;
 
        for (i = 0; i < state->stream_count; i++) {
-               if (args.stream && state->streams[i] != args.stream)
+               if (!dcn401_walks_stream(&args, state->streams[i]))
                        continue;
                args.pipe = resource_get_otg_master_for_stream(
                                &state->res_ctx, state->streams[i]);
@@ -2180,7 +2189,7 @@ static void dcn401_add_per_opp_head(struct 
block_sequence_state *sequence,
        int j, n;
 
        for (i = 0; i < state->stream_count; i++) {
-               if (args.stream && state->streams[i] != args.stream)
+               if (!dcn401_walks_stream(&args, state->streams[i]))
                        continue;
                n = resource_get_opp_heads_for_stream(state->streams[i],
                                &state->res_ctx, opp_heads);
@@ -2202,7 +2211,7 @@ static void dcn401_add_per_dpp_pipe(struct 
block_sequence_state *sequence,
        int j, n;
 
        for (i = 0; i < state->stream_count; i++) {
-               if (args.stream && state->streams[i] != args.stream)
+               if (!dcn401_walks_stream(&args, state->streams[i]))
                        continue;
                n = resource_get_dpp_pipes_for_stream(state->streams[i],
                                &state->res_ctx, dpp_pipes);
diff --git a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c 
b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
index 90bcf02ded00..ce2b14bb7a5a 100644
--- a/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
+++ b/drivers/gpu/drm/amd/display/dc/core2/dc_core2.c
@@ -245,12 +245,18 @@ enum dc_status core2_commit_state_hw(struct dc *dc, 
struct dc_state *context)
 
        core2_commit_prepare_done(dc, context);
        for (i = 0; i < current_state->stream_count; i++)
-               core2_commit_disable_done(dc, 
resource_get_otg_master_for_stream(
-                               &current_state->res_ctx,
-                               current_state->streams[i]));
+               if (!dcn401_stream_unchanged(current_state, context,
+                               current_state->streams[i]))
+                       core2_commit_disable_done(dc,
+                                       resource_get_otg_master_for_stream(
+                                       &current_state->res_ctx,
+                                       current_state->streams[i]));
        for (i = 0; i < context->stream_count; i++)
-               core2_commit_enable_done(resource_get_otg_master_for_stream(
-                               &context->res_ctx, context->streams[i]));
+               if (!dcn401_stream_unchanged(current_state, context,
+                               context->streams[i]))
+                       core2_commit_enable_done(
+                                       resource_get_otg_master_for_stream(
+                                       &context->res_ctx, 
context->streams[i]));
        return DC_OK;
 }
 
-- 
2.43.0

Reply via email to