Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/display/dp_mst: Handle old/new payload states in drm_dp_remove_payload()

Atm, drm_dp_remove_payload() uses the same payload state to both get the
vc_start_slot required for the payload removal DPCD message and to
deduct time_slots from vc_start_slot of all payloads after the one being
removed.

The above isn't always correct, as vc_start_slot must be the up-to-date
version contained in the new payload state, but time_slots must be the
one used when the payload was previously added, contained in the old
payload state. The new payload's time_slots can change vs. the old one
if the current atomic commit changes the corresponding mode.

This patch let's drivers pass the old and new payload states to
drm_dp_remove_payload(), but keeps these the same for now in all drivers
not to change the behavior. A follow-up i915 patch will pass in that
driver the correct old and new states to the function.

Cc: Lyude Paul <lyude@redhat.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Karol Herbst <kherbst@redhat.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Wayne Lin <Wayne.Lin@amd.com>
Cc: stable@vger.kernel.org # 6.1
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Acked-by: Lyude Paul <lyude@redhat.com>
Acked-by: Daniel Vetter <daniel@ffwll.ch>
Acked-by: Wayne Lin <wayne.lin@amd.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230206114856.2665066-2-imre.deak@intel.com

+21 -16
+1 -1
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
··· 208 208 if (enable) 209 209 drm_dp_add_payload_part1(mst_mgr, mst_state, payload); 210 210 else 211 - drm_dp_remove_payload(mst_mgr, mst_state, payload); 211 + drm_dp_remove_payload(mst_mgr, mst_state, payload, payload); 212 212 213 213 /* mst_mgr->->payloads are VC payload notify MST branch using DPCD or 214 214 * AUX message. The sequence is slot 1-63 allocated sequence for each
+14 -12
drivers/gpu/drm/display/drm_dp_mst_topology.c
··· 3342 3342 * drm_dp_remove_payload() - Remove an MST payload 3343 3343 * @mgr: Manager to use. 3344 3344 * @mst_state: The MST atomic state 3345 - * @payload: The payload to write 3345 + * @old_payload: The payload with its old state 3346 + * @new_payload: The payload to write 3346 3347 * 3347 3348 * Removes a payload from an MST topology if it was successfully assigned a start slot. Also updates 3348 3349 * the starting time slots of all other payloads which would have been shifted towards the start of ··· 3351 3350 */ 3352 3351 void drm_dp_remove_payload(struct drm_dp_mst_topology_mgr *mgr, 3353 3352 struct drm_dp_mst_topology_state *mst_state, 3354 - struct drm_dp_mst_atomic_payload *payload) 3353 + const struct drm_dp_mst_atomic_payload *old_payload, 3354 + struct drm_dp_mst_atomic_payload *new_payload) 3355 3355 { 3356 3356 struct drm_dp_mst_atomic_payload *pos; 3357 3357 bool send_remove = false; 3358 3358 3359 3359 /* We failed to make the payload, so nothing to do */ 3360 - if (payload->vc_start_slot == -1) 3360 + if (new_payload->vc_start_slot == -1) 3361 3361 return; 3362 3362 3363 3363 mutex_lock(&mgr->lock); 3364 - send_remove = drm_dp_mst_port_downstream_of_branch(payload->port, mgr->mst_primary); 3364 + send_remove = drm_dp_mst_port_downstream_of_branch(new_payload->port, mgr->mst_primary); 3365 3365 mutex_unlock(&mgr->lock); 3366 3366 3367 3367 if (send_remove) 3368 - drm_dp_destroy_payload_step1(mgr, mst_state, payload); 3368 + drm_dp_destroy_payload_step1(mgr, mst_state, new_payload); 3369 3369 else 3370 3370 drm_dbg_kms(mgr->dev, "Payload for VCPI %d not in topology, not sending remove\n", 3371 - payload->vcpi); 3371 + new_payload->vcpi); 3372 3372 3373 3373 list_for_each_entry(pos, &mst_state->payloads, next) { 3374 - if (pos != payload && pos->vc_start_slot > payload->vc_start_slot) 3375 - pos->vc_start_slot -= payload->time_slots; 3374 + if (pos != new_payload && pos->vc_start_slot > new_payload->vc_start_slot) 3375 + pos->vc_start_slot -= old_payload->time_slots; 3376 3376 } 3377 - payload->vc_start_slot = -1; 3377 + new_payload->vc_start_slot = -1; 3378 3378 3379 3379 mgr->payload_count--; 3380 - mgr->next_start_slot -= payload->time_slots; 3380 + mgr->next_start_slot -= old_payload->time_slots; 3381 3381 3382 - if (payload->delete) 3383 - drm_dp_mst_put_port_malloc(payload->port); 3382 + if (new_payload->delete) 3383 + drm_dp_mst_put_port_malloc(new_payload->port); 3384 3384 } 3385 3385 EXPORT_SYMBOL(drm_dp_remove_payload); 3386 3386
+3 -1
drivers/gpu/drm/i915/display/intel_dp_mst.c
··· 526 526 to_intel_connector(old_conn_state->connector); 527 527 struct drm_dp_mst_topology_state *mst_state = 528 528 drm_atomic_get_mst_topology_state(&state->base, &intel_dp->mst_mgr); 529 + struct drm_dp_mst_atomic_payload *payload = 530 + drm_atomic_get_mst_payload_state(mst_state, connector->port); 529 531 struct drm_i915_private *i915 = to_i915(connector->base.dev); 530 532 531 533 drm_dbg_kms(&i915->drm, "active links %d\n", ··· 536 534 intel_hdcp_disable(intel_mst->connector); 537 535 538 536 drm_dp_remove_payload(&intel_dp->mst_mgr, mst_state, 539 - drm_atomic_get_mst_payload_state(mst_state, connector->port)); 537 + payload, payload); 540 538 541 539 intel_audio_codec_disable(encoder, old_crtc_state, old_conn_state); 542 540 }
+1 -1
drivers/gpu/drm/nouveau/dispnv50/disp.c
··· 885 885 886 886 // TODO: Figure out if we want to do a better job of handling VCPI allocation failures here? 887 887 if (msto->disabled) { 888 - drm_dp_remove_payload(mgr, mst_state, payload); 888 + drm_dp_remove_payload(mgr, mst_state, payload, payload); 889 889 890 890 nvif_outp_dp_mst_vcpi(&mstm->outp->outp, msto->head->base.index, 0, 0, 0, 0); 891 891 } else {
+2 -1
include/drm/display/drm_dp_mst_helper.h
··· 841 841 struct drm_dp_mst_atomic_payload *payload); 842 842 void drm_dp_remove_payload(struct drm_dp_mst_topology_mgr *mgr, 843 843 struct drm_dp_mst_topology_state *mst_state, 844 - struct drm_dp_mst_atomic_payload *payload); 844 + const struct drm_dp_mst_atomic_payload *old_payload, 845 + struct drm_dp_mst_atomic_payload *new_payload); 845 846 846 847 int drm_dp_check_act_status(struct drm_dp_mst_topology_mgr *mgr); 847 848