drm/amd/display: Run full global validation in dc_commit_state
authorNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Mon, 8 Nov 2021 18:33:12 +0000 (13:33 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 22 Nov 2021 19:59:13 +0000 (14:59 -0500)
[Why]
Dynamic link encoder assignment expects that it can modify DC
current_state and the links associated with the incoming state when
performing full validation.

This does not align with our actual synchronization constraints
in DM's atomic_check.

[How]
Since link encoder assignment only happens as part of full validation
we can just use fast validation as part of atomic_check instead.

This satisfy's DC interface requirements and skips the DML calculations
needed for pipe programming - hopefully speeding up things a little bit
to offset the cost of double validation during stream modification.

We already do this as part of dc_commit_updates_for_stream()
with validate_bandwidth(), so extend this to dc_commit_state() as
well.

Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com>
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/amd/display/dc/core/dc.c

index b2bf77c..3845d7e 100644 (file)
@@ -2307,14 +2307,6 @@ static enum dc_status amdgpu_dm_commit_zero_streams(struct dc *dc)
                        goto fail;
        }
 
-
-       res = dc_validate_global_state(dc, context, false);
-
-       if (res != DC_OK) {
-               DRM_ERROR("%s:resource validation failed, dc_status:%d\n", __func__, res);
-               goto fail;
-       }
-
        res = dc_commit_state(dc, context);
 
 fail:
@@ -2583,15 +2575,6 @@ static int dm_resume(void *handle)
                                        = 0xffffffff;
                        }
                }
-#if defined(CONFIG_DRM_AMD_DC_DCN)
-               /*
-                * Resource allocation happens for link encoders for newer ASIC in
-                * dc_validate_global_state, so we need to revalidate it.
-                *
-                * This shouldn't fail (it passed once before), so warn if it does.
-                */
-               WARN_ON(dc_validate_global_state(dm->dc, dc_state, false) != DC_OK);
-#endif
 
                WARN_ON(!dc_commit_state(dm->dc, dc_state));
 
@@ -11130,7 +11113,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
                        DRM_DEBUG_DRIVER("drm_dp_mst_atomic_check() failed\n");
                        goto fail;
                }
-               status = dc_validate_global_state(dc, dm_state->context, false);
+               status = dc_validate_global_state(dc, dm_state->context, true);
                if (status != DC_OK) {
                        DRM_DEBUG_DRIVER("DC global validation failure: %s (%d)",
                                       dc_status_to_str(status), status);
index 34382d0..0545e17 100644 (file)
@@ -1827,6 +1827,19 @@ bool dc_commit_state(struct dc *dc, struct dc_state *context)
                dc_stream_log(dc, stream);
        }
 
+       /*
+        * Previous validation was perfomred with fast_validation = true and
+        * the full DML state required for hardware programming was skipped.
+        *
+        * Re-validate here to calculate these parameters / watermarks.
+        */
+       result = dc_validate_global_state(dc, context, false);
+       if (result != DC_OK) {
+               DC_LOG_ERROR("DC commit global validation failure: %s (%d)",
+                            dc_status_to_str(result), result);
+               return result;
+       }
+
        result = dc_commit_state_no_check(dc, context);
 
        return (result == DC_OK);