Merge tag '6.6-rc-smb3-client-fixes-part2' of git://git.samba.org/sfrench/cifs-2.6
[sfrench/cifs-2.6.git] / drivers / gpu / drm / amd / display / dc / core / dc.c
index 566d7045b2dea80a6670b4af8cb253c1e455f1ca..3a9077b60029ba9626301d204c35443290664ba9 100644 (file)
@@ -2073,12 +2073,12 @@ enum dc_status dc_commit_streams(struct dc *dc,
                }
        }
 
-       /* Check for case where we are going from odm 2:1 to max
-        *  pipe scenario.  For these cases, we will call
-        *  commit_minimal_transition_state() to exit out of odm 2:1
-        *  first before processing new streams
+       /* ODM Combine 2:1 power optimization is only applied for single stream
+        * scenario, it uses extra pipes than needed to reduce power consumption
+        * We need to switch off this feature to make room for new streams.
         */
-       if (stream_count == dc->res_pool->pipe_count) {
+       if (stream_count > dc->current_state->stream_count &&
+                       dc->current_state->stream_count == 1) {
                for (i = 0; i < dc->res_pool->pipe_count; i++) {
                        pipe = &dc->current_state->res_ctx.pipe_ctx[i];
                        if (pipe->next_odm_pipe)
@@ -3501,6 +3501,45 @@ static void commit_planes_for_stream_fast(struct dc *dc,
                top_pipe_to_program->stream->update_flags.raw = 0;
 }
 
+static void wait_for_outstanding_hw_updates(struct dc *dc, const struct dc_state *dc_context)
+{
+/*
+ * This function calls HWSS to wait for any potentially double buffered
+ * operations to complete. It should be invoked as a pre-amble prior
+ * to full update programming before asserting any HW locks.
+ */
+       int pipe_idx;
+       int opp_inst;
+       int opp_count = dc->res_pool->pipe_count;
+       struct hubp *hubp;
+       int mpcc_inst;
+       const struct pipe_ctx *pipe_ctx;
+
+       for (pipe_idx = 0; pipe_idx < dc->res_pool->pipe_count; pipe_idx++) {
+               pipe_ctx = &dc_context->res_ctx.pipe_ctx[pipe_idx];
+
+               if (!pipe_ctx->stream)
+                       continue;
+
+               if (pipe_ctx->stream_res.tg->funcs->wait_drr_doublebuffer_pending_clear)
+                       pipe_ctx->stream_res.tg->funcs->wait_drr_doublebuffer_pending_clear(pipe_ctx->stream_res.tg);
+
+               hubp = pipe_ctx->plane_res.hubp;
+               if (!hubp)
+                       continue;
+
+               mpcc_inst = hubp->inst;
+               // MPCC inst is equal to pipe index in practice
+               for (opp_inst = 0; opp_inst < opp_count; opp_inst++) {
+                       if (dc->res_pool->opps[opp_inst]->mpcc_disconnect_pending[mpcc_inst]) {
+                               dc->res_pool->mpc->funcs->wait_for_idle(dc->res_pool->mpc, mpcc_inst);
+                               dc->res_pool->opps[opp_inst]->mpcc_disconnect_pending[mpcc_inst] = false;
+                               break;
+                       }
+               }
+       }
+}
+
 static void commit_planes_for_stream(struct dc *dc,
                struct dc_surface_update *srf_updates,
                int surface_count,
@@ -3519,24 +3558,9 @@ static void commit_planes_for_stream(struct dc *dc,
        // dc->current_state anymore, so we have to cache it before we apply
        // the new SubVP context
        subvp_prev_use = false;
-
-
        dc_z10_restore(dc);
-
-       if (update_type == UPDATE_TYPE_FULL) {
-               /* wait for all double-buffer activity to clear on all pipes */
-               int pipe_idx;
-
-               for (pipe_idx = 0; pipe_idx < dc->res_pool->pipe_count; pipe_idx++) {
-                       struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[pipe_idx];
-
-                       if (!pipe_ctx->stream)
-                               continue;
-
-                       if (pipe_ctx->stream_res.tg->funcs->wait_drr_doublebuffer_pending_clear)
-                               pipe_ctx->stream_res.tg->funcs->wait_drr_doublebuffer_pending_clear(pipe_ctx->stream_res.tg);
-               }
-       }
+       if (update_type == UPDATE_TYPE_FULL)
+               wait_for_outstanding_hw_updates(dc, context);
 
        if (update_type == UPDATE_TYPE_FULL) {
                dc_allow_idle_optimizations(dc, false);