drm/amd/display: update pipe selection policy to check head pipe
authorYihan Zhu <Yihan.Zhu@amd.com>
Wed, 30 Oct 2024 20:20:21 +0000 (16:20 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 20 Nov 2024 14:38:19 +0000 (09:38 -0500)
[Why]
No check on head pipe during the dml to dc hw mapping will allow illegal
pipe usage. This will result in a wrong pipe topology to cause mpcc tree
totally mess up then cause a display hang.

[How]
Avoid to use the pipe is head in all check and avoid ODM slice during
preferred pipe check.

Cc: stable@vger.kernel.org
Reviewed-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Signed-off-by: Yihan Zhu <Yihan.Zhu@amd.com>
Signed-off-by: Hamza Mahfooz <hamza.mahfooz@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/dml2/dml2_dc_resource_mgmt.c

index 6eccf02..1ed21c1 100644 (file)
@@ -258,12 +258,25 @@ static unsigned int find_preferred_pipe_candidates(const struct dc_state *existi
         * However this condition comes with a caveat. We need to ignore pipes that will
         * require a change in OPP but still have the same stream id. For example during
         * an MPC to ODM transiton.
+        *
+        * Adding check to avoid pipe select on the head pipe by utilizing dc resource
+        * helper function resource_get_primary_dpp_pipe and comparing the pipe index.
         */
        if (existing_state) {
                for (i = 0; i < pipe_count; i++) {
                        if (existing_state->res_ctx.pipe_ctx[i].stream && existing_state->res_ctx.pipe_ctx[i].stream->stream_id == stream_id) {
+                               struct pipe_ctx *head_pipe =
+                                       resource_is_pipe_type(&existing_state->res_ctx.pipe_ctx[i], DPP_PIPE) ?
+                                               resource_get_primary_dpp_pipe(&existing_state->res_ctx.pipe_ctx[i]) :
+                                                       NULL;
+
+                               // we should always respect the head pipe from selection
+                               if (head_pipe && head_pipe->pipe_idx == i)
+                                       continue;
                                if (existing_state->res_ctx.pipe_ctx[i].plane_res.hubp &&
-                                       existing_state->res_ctx.pipe_ctx[i].plane_res.hubp->opp_id != i)
+                                       existing_state->res_ctx.pipe_ctx[i].plane_res.hubp->opp_id != i &&
+                                               (existing_state->res_ctx.pipe_ctx[i].prev_odm_pipe ||
+                                               existing_state->res_ctx.pipe_ctx[i].next_odm_pipe))
                                        continue;
 
                                preferred_pipe_candidates[num_preferred_candidates++] = i;
@@ -292,6 +305,14 @@ static unsigned int find_last_resort_pipe_candidates(const struct dc_state *exis
         */
        if (existing_state) {
                for (i  = 0; i < pipe_count; i++) {
+                       struct pipe_ctx *head_pipe =
+                               resource_is_pipe_type(&existing_state->res_ctx.pipe_ctx[i], DPP_PIPE) ?
+                                       resource_get_primary_dpp_pipe(&existing_state->res_ctx.pipe_ctx[i]) :
+                                               NULL;
+
+                       // we should always respect the head pipe from selection
+                       if (head_pipe && head_pipe->pipe_idx == i)
+                               continue;
                        if ((existing_state->res_ctx.pipe_ctx[i].plane_res.hubp &&
                                existing_state->res_ctx.pipe_ctx[i].plane_res.hubp->opp_id != i) ||
                                existing_state->res_ctx.pipe_ctx[i].stream_res.tg)