Skip to content

Commit e761cc2

Browse files
committed
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
1 parent 326b1e7 commit e761cc2

5 files changed

Lines changed: 21 additions & 16 deletions

File tree

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ bool dm_helpers_dp_mst_write_payload_allocation_table(
208208
if (enable)
209209
drm_dp_add_payload_part1(mst_mgr, mst_state, payload);
210210
else
211-
drm_dp_remove_payload(mst_mgr, mst_state, payload);
211+
drm_dp_remove_payload(mst_mgr, mst_state, payload, payload);
212212

213213
/* mst_mgr->->payloads are VC payload notify MST branch using DPCD or
214214
* AUX message. The sequence is slot 1-63 allocated sequence for each

drivers/gpu/drm/display/drm_dp_mst_topology.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3342,44 +3342,46 @@ EXPORT_SYMBOL(drm_dp_add_payload_part1);
33423342
* drm_dp_remove_payload() - Remove an MST payload
33433343
* @mgr: Manager to use.
33443344
* @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
33463347
*
33473348
* Removes a payload from an MST topology if it was successfully assigned a start slot. Also updates
33483349
* the starting time slots of all other payloads which would have been shifted towards the start of
33493350
* the VC table as a result. After calling this, the driver should generate ACT and payload packets.
33503351
*/
33513352
void drm_dp_remove_payload(struct drm_dp_mst_topology_mgr *mgr,
33523353
struct drm_dp_mst_topology_state *mst_state,
3353-
struct drm_dp_mst_atomic_payload *payload)
3354+
const struct drm_dp_mst_atomic_payload *old_payload,
3355+
struct drm_dp_mst_atomic_payload *new_payload)
33543356
{
33553357
struct drm_dp_mst_atomic_payload *pos;
33563358
bool send_remove = false;
33573359

33583360
/* We failed to make the payload, so nothing to do */
3359-
if (payload->vc_start_slot == -1)
3361+
if (new_payload->vc_start_slot == -1)
33603362
return;
33613363

33623364
mutex_lock(&mgr->lock);
3363-
send_remove = drm_dp_mst_port_downstream_of_branch(payload->port, mgr->mst_primary);
3365+
send_remove = drm_dp_mst_port_downstream_of_branch(new_payload->port, mgr->mst_primary);
33643366
mutex_unlock(&mgr->lock);
33653367

33663368
if (send_remove)
3367-
drm_dp_destroy_payload_step1(mgr, mst_state, payload);
3369+
drm_dp_destroy_payload_step1(mgr, mst_state, new_payload);
33683370
else
33693371
drm_dbg_kms(mgr->dev, "Payload for VCPI %d not in topology, not sending remove\n",
3370-
payload->vcpi);
3372+
new_payload->vcpi);
33713373

33723374
list_for_each_entry(pos, &mst_state->payloads, next) {
3373-
if (pos != payload && pos->vc_start_slot > payload->vc_start_slot)
3374-
pos->vc_start_slot -= payload->time_slots;
3375+
if (pos != new_payload && pos->vc_start_slot > new_payload->vc_start_slot)
3376+
pos->vc_start_slot -= old_payload->time_slots;
33753377
}
3376-
payload->vc_start_slot = -1;
3378+
new_payload->vc_start_slot = -1;
33773379

33783380
mgr->payload_count--;
3379-
mgr->next_start_slot -= payload->time_slots;
3381+
mgr->next_start_slot -= old_payload->time_slots;
33803382

3381-
if (payload->delete)
3382-
drm_dp_mst_put_port_malloc(payload->port);
3383+
if (new_payload->delete)
3384+
drm_dp_mst_put_port_malloc(new_payload->port);
33833385
}
33843386
EXPORT_SYMBOL(drm_dp_remove_payload);
33853387

drivers/gpu/drm/i915/display/intel_dp_mst.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,8 @@ static void intel_mst_disable_dp(struct intel_atomic_state *state,
526526
to_intel_connector(old_conn_state->connector);
527527
struct drm_dp_mst_topology_state *mst_state =
528528
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);
529531
struct drm_i915_private *i915 = to_i915(connector->base.dev);
530532

531533
drm_dbg_kms(&i915->drm, "active links %d\n",
@@ -534,7 +536,7 @@ static void intel_mst_disable_dp(struct intel_atomic_state *state,
534536
intel_hdcp_disable(intel_mst->connector);
535537

536538
drm_dp_remove_payload(&intel_dp->mst_mgr, mst_state,
537-
drm_atomic_get_mst_payload_state(mst_state, connector->port));
539+
payload, payload);
538540

539541
intel_audio_codec_disable(encoder, old_crtc_state, old_conn_state);
540542
}

drivers/gpu/drm/nouveau/dispnv50/disp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ nv50_msto_prepare(struct drm_atomic_state *state,
885885

886886
// TODO: Figure out if we want to do a better job of handling VCPI allocation failures here?
887887
if (msto->disabled) {
888-
drm_dp_remove_payload(mgr, mst_state, payload);
888+
drm_dp_remove_payload(mgr, mst_state, payload, payload);
889889

890890
nvif_outp_dp_mst_vcpi(&mstm->outp->outp, msto->head->base.index, 0, 0, 0, 0);
891891
} else {

include/drm/display/drm_dp_mst_helper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,8 @@ int drm_dp_add_payload_part2(struct drm_dp_mst_topology_mgr *mgr,
841841
struct drm_dp_mst_atomic_payload *payload);
842842
void drm_dp_remove_payload(struct drm_dp_mst_topology_mgr *mgr,
843843
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);
845846

846847
int drm_dp_check_act_status(struct drm_dp_mst_topology_mgr *mgr);
847848

0 commit comments

Comments
 (0)