dm_helpers_dp_mst_update_mst_mgr_for_deallocation() calls
drm_dp_remove_payload_part2() unconditionally. That function decrements
payload_count and moves next_start_slot back by the payload's time
slots. If the payload was never added with drm_dp_add_payload_part1(),
or was already released, both counters underflow. Every payload
allocated afterwards then starts at a bogus slot and ACT never
completes.

This can happen when the same stream is disabled twice, e.g. first by
link_set_all_streams_dpms_off_for_link() during a destructive link
verification and then again when userspace disables its CRTC, or when
the stream enable was aborted before its payload was allocated.

drm_dp_add_payload_part1() sets vc_start_slot and
drm_dp_remove_payload_part2() resets it to -1, so a negative
vc_start_slot means there is nothing to release. Return early in that
case.

Signed-off-by: Bart Verwilst <[email protected]>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c    | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index 6192c0f..bc26f65 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -524,6 +524,22 @@ void dm_helpers_dp_mst_update_mst_mgr_for_deallocation(
        mst_mgr = &aconnector->mst_root->mst_mgr;
        mst_state = to_drm_dp_mst_topology_state(mst_mgr->base.state);
        new_payload = drm_atomic_get_mst_payload_state(mst_state, 
aconnector->mst_output_port);
+       if (!new_payload)
+               return;
+
+       /*
+        * Only a payload that went through drm_dp_add_payload_part1() holds
+        * time slots in the manager (vc_start_slot >= 0). Releasing a payload
+        * that was never added, or releasing one twice, would underflow
+        * payload_count and next_start_slot.
+        */
+       if (new_payload->vc_start_slot < 0) {
+               drm_dbg_kms(mst_mgr->dev,
+                           "MST payload for VCPI %d holds no time slots, 
nothing to release\n",
+                           new_payload->vcpi);
+               return;
+       }
+
        dm_helpers_construct_old_payload(mst_mgr, mst_state,
                                         new_payload, &old_payload);
 
-- 
2.56.1

Reply via email to