drm/amd/display: fix incorrect odm change detection logic
authorWenjing Liu <wenjing.liu@amd.com>
Thu, 14 Sep 2023 16:42:50 +0000 (12:42 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 26 Sep 2023 21:00:22 +0000 (17:00 -0400)
[why]
The current ODM change detection only compares first two ODM slices.
If there are 4 ODM slices and the change is within the last two slices, the
logic fails to detect ODM change and cause us to skip ODM programming
unexpectedly.

[how]
Add a is ODM topology changed resource interface to check any ODM
topology changes with a more generic method.

Reviewed-by: Dillon Varone <dillon.varone@amd.com>
Acked-by: Wayne Lin <wayne.lin@amd.com>
Signed-off-by: Wenjing Liu <wenjing.liu@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc_resource.c
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
drivers/gpu/drm/amd/display/dc/inc/resource.h

index 5a6f458b2942287501b9296c97a0d28409cf4172..628b902a4cec1c63886a9571590dcab8073656e5 100644 (file)
@@ -1927,6 +1927,29 @@ bool resource_is_pipe_topology_changed(const struct dc_state *state_a,
        return false;
 }
 
+bool resource_is_odm_topology_changed(const struct pipe_ctx *otg_master_a,
+               const struct pipe_ctx *otg_master_b)
+{
+       const struct pipe_ctx *opp_head_a = otg_master_a;
+       const struct pipe_ctx *opp_head_b = otg_master_b;
+
+       if (!resource_is_pipe_type(otg_master_a, OTG_MASTER) ||
+                       !resource_is_pipe_type(otg_master_b, OTG_MASTER))
+               return true;
+
+       while (opp_head_a && opp_head_b) {
+               if (opp_head_a->stream_res.opp != opp_head_b->stream_res.opp)
+                       return true;
+               if ((opp_head_a->next_odm_pipe && !opp_head_b->next_odm_pipe) ||
+                               (!opp_head_a->next_odm_pipe && opp_head_b->next_odm_pipe))
+                       return true;
+               opp_head_a = opp_head_a->next_odm_pipe;
+               opp_head_b = opp_head_b->next_odm_pipe;
+       }
+
+       return false;
+}
+
 /*
  * Sample log:
  *    pipe topology update
index 321fa01a33b0a7f907f0da56dc53f35cc9fe4815..21b94adab575d308ded0eb9f9967d2c4324c5d7f 100644 (file)
@@ -1433,13 +1433,9 @@ static void dcn20_detect_pipe_changes(struct pipe_ctx *old_pipe, struct pipe_ctx
        }
 
        /* Detect top pipe only changes */
-       if (!new_pipe->top_pipe && !new_pipe->prev_odm_pipe) {
+       if (resource_is_pipe_type(new_pipe, OTG_MASTER)) {
                /* Detect odm changes */
-               if ((old_pipe->next_odm_pipe && new_pipe->next_odm_pipe
-                       && old_pipe->next_odm_pipe->pipe_idx != new_pipe->next_odm_pipe->pipe_idx)
-                               || (!old_pipe->next_odm_pipe && new_pipe->next_odm_pipe)
-                               || (old_pipe->next_odm_pipe && !new_pipe->next_odm_pipe)
-                               || old_pipe->stream_res.opp != new_pipe->stream_res.opp)
+               if (resource_is_odm_topology_changed(new_pipe, old_pipe))
                        new_pipe->update_flags.bits.odm = 1;
 
                /* Detect global sync changes */
index 170d6ab81aef28372690e165b24a7743ec3e06e3..00230a7fbe25df7f78fdfe12d16dfb410d597fa0 100644 (file)
@@ -447,6 +447,16 @@ int resource_get_odm_slice_index(const struct pipe_ctx *opp_head);
 bool resource_is_pipe_topology_changed(const struct dc_state *state_a,
                const struct dc_state *state_b);
 
+/*
+ * determine if the two OTG master pipes have the same ODM topology
+ * return
+ * false - if pipes passed in are not OTG masters or ODM topology is
+ * changed.
+ * true - otherwise
+ */
+bool resource_is_odm_topology_changed(const struct pipe_ctx *otg_master_a,
+               const struct pipe_ctx *otg_master_b);
+
 /* log the pipe topology update in state */
 void resource_log_pipe_topology_update(struct dc *dc, struct dc_state *state);