drm/display/dp_mst: Handle old/new payload states in drm_dp_remove_payload()
authorjsg <jsg@openbsd.org>
Mon, 17 Apr 2023 05:29:45 +0000 (05:29 +0000)
committerjsg <jsg@openbsd.org>
Mon, 17 Apr 2023 05:29:45 +0000 (05:29 +0000)
From Imre Deak
0c64d72fd3f21ac9d0da186809394d9593090ce7 in linux-6.1.y/6.1.24
e761cc20946a0094df71cb31a565a6a0d03bd8be in mainline linux

sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
sys/dev/pci/drm/display/drm_dp_mst_topology.c
sys/dev/pci/drm/i915/display/intel_dp_mst.c
sys/dev/pci/drm/include/drm/display/drm_dp_mst_helper.h

index 422c76a..c3f63e1 100644 (file)
@@ -206,7 +206,7 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
        if (enable)
                drm_dp_add_payload_part1(mst_mgr, mst_state, payload);
        else
-               drm_dp_remove_payload(mst_mgr, mst_state, payload);
+               drm_dp_remove_payload(mst_mgr, mst_state, payload, payload);
 
        /* mst_mgr->->payloads are VC payload notify MST branch using DPCD or
         * AUX message. The sequence is slot 1-63 allocated sequence for each
index f930f0d..0a59cd7 100644 (file)
@@ -3352,7 +3352,8 @@ EXPORT_SYMBOL(drm_dp_add_payload_part1);
  * drm_dp_remove_payload() - Remove an MST payload
  * @mgr: Manager to use.
  * @mst_state: The MST atomic state
- * @payload: The payload to write
+ * @old_payload: The payload with its old state
+ * @new_payload: The payload to write
  *
  * Removes a payload from an MST topology if it was successfully assigned a start slot. Also updates
  * the starting time slots of all other payloads which would have been shifted towards the start of
@@ -3360,36 +3361,37 @@ EXPORT_SYMBOL(drm_dp_add_payload_part1);
  */
 void drm_dp_remove_payload(struct drm_dp_mst_topology_mgr *mgr,
                           struct drm_dp_mst_topology_state *mst_state,
-                          struct drm_dp_mst_atomic_payload *payload)
+                          const struct drm_dp_mst_atomic_payload *old_payload,
+                          struct drm_dp_mst_atomic_payload *new_payload)
 {
        struct drm_dp_mst_atomic_payload *pos;
        bool send_remove = false;
 
        /* We failed to make the payload, so nothing to do */
-       if (payload->vc_start_slot == -1)
+       if (new_payload->vc_start_slot == -1)
                return;
 
        mutex_lock(&mgr->lock);
-       send_remove = drm_dp_mst_port_downstream_of_branch(payload->port, mgr->mst_primary);
+       send_remove = drm_dp_mst_port_downstream_of_branch(new_payload->port, mgr->mst_primary);
        mutex_unlock(&mgr->lock);
 
        if (send_remove)
-               drm_dp_destroy_payload_step1(mgr, mst_state, payload);
+               drm_dp_destroy_payload_step1(mgr, mst_state, new_payload);
        else
                drm_dbg_kms(mgr->dev, "Payload for VCPI %d not in topology, not sending remove\n",
-                           payload->vcpi);
+                           new_payload->vcpi);
 
        list_for_each_entry(pos, &mst_state->payloads, next) {
-               if (pos != payload && pos->vc_start_slot > payload->vc_start_slot)
-                       pos->vc_start_slot -= payload->time_slots;
+               if (pos != new_payload && pos->vc_start_slot > new_payload->vc_start_slot)
+                       pos->vc_start_slot -= old_payload->time_slots;
        }
-       payload->vc_start_slot = -1;
+       new_payload->vc_start_slot = -1;
 
        mgr->payload_count--;
-       mgr->next_start_slot -= payload->time_slots;
+       mgr->next_start_slot -= old_payload->time_slots;
 
-       if (payload->delete)
-               drm_dp_mst_put_port_malloc(payload->port);
+       if (new_payload->delete)
+               drm_dp_mst_put_port_malloc(new_payload->port);
 }
 EXPORT_SYMBOL(drm_dp_remove_payload);
 
index 27c2098..256afff 100644 (file)
@@ -366,6 +366,8 @@ static void intel_mst_disable_dp(struct intel_atomic_state *state,
                to_intel_connector(old_conn_state->connector);
        struct drm_dp_mst_topology_state *mst_state =
                drm_atomic_get_mst_topology_state(&state->base, &intel_dp->mst_mgr);
+       struct drm_dp_mst_atomic_payload *payload =
+               drm_atomic_get_mst_payload_state(mst_state, connector->port);
        struct drm_i915_private *i915 = to_i915(connector->base.dev);
 
        drm_dbg_kms(&i915->drm, "active links %d\n",
@@ -374,7 +376,7 @@ static void intel_mst_disable_dp(struct intel_atomic_state *state,
        intel_hdcp_disable(intel_mst->connector);
 
        drm_dp_remove_payload(&intel_dp->mst_mgr, mst_state,
-                             drm_atomic_get_mst_payload_state(mst_state, connector->port));
+                             payload, payload);
 
        intel_audio_codec_disable(encoder, old_crtc_state, old_conn_state);
 }
index bf55728..8622e3c 100644 (file)
@@ -841,7 +841,8 @@ int drm_dp_add_payload_part2(struct drm_dp_mst_topology_mgr *mgr,
                             struct drm_dp_mst_atomic_payload *payload);
 void drm_dp_remove_payload(struct drm_dp_mst_topology_mgr *mgr,
                           struct drm_dp_mst_topology_state *mst_state,
-                          struct drm_dp_mst_atomic_payload *payload);
+                          const struct drm_dp_mst_atomic_payload *old_payload,
+                          struct drm_dp_mst_atomic_payload *new_payload);
 
 int drm_dp_check_act_status(struct drm_dp_mst_topology_mgr *mgr);