Commit 88ec89ad authored by Lyude Paul's avatar Lyude Paul

drm/nouveau: Move PBN and VCPI allocation into nv50_head_atom

Atomic checks should never modify anything outside of the state that
they're passed in. Unfortunately this appears to be exactly what we're
doing in nv50_msto_atomic_check() where we update mstc->pbn every time
the function is called. This hasn't caused any bugs yet, but it needs to
be fixed in order to ensure that when committing an artificially
duplicated state (like during system resume), that we reuse the PBN of
that state to perform VCPI allocations and don't recalculate a different
value from the drm connector's reported bpc.

Also, move the VCPI slot allocations while we're at it as well. With
this, removing a topology in suspend while using nouveau no longer
causes the new atomic VCPI helpers to complain.
Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
Fixes: eceae147 ("drm/dp_mst: Start tracking per-port VCPI allocations")
Cc: Daniel Vetter <daniel@ffwll.ch>
Reviewed-by: default avatarBen Skeggs <bskeggs@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190202002023.29665-5-lyude@redhat.com
parent 022debad
...@@ -116,6 +116,12 @@ struct nv50_head_atom { ...@@ -116,6 +116,12 @@ struct nv50_head_atom {
u8 depth:4; u8 depth:4;
} or; } or;
/* Currently only used for MST */
struct {
int pbn;
u8 tu:6;
} dp;
union nv50_head_atom_mask { union nv50_head_atom_mask {
struct { struct {
bool olut:1; bool olut:1;
......
...@@ -659,8 +659,6 @@ struct nv50_mstc { ...@@ -659,8 +659,6 @@ struct nv50_mstc {
struct drm_display_mode *native; struct drm_display_mode *native;
struct edid *edid; struct edid *edid;
int pbn;
}; };
struct nv50_msto { struct nv50_msto {
...@@ -765,17 +763,26 @@ nv50_msto_atomic_check(struct drm_encoder *encoder, ...@@ -765,17 +763,26 @@ nv50_msto_atomic_check(struct drm_encoder *encoder,
struct drm_connector *connector = conn_state->connector; struct drm_connector *connector = conn_state->connector;
struct nv50_mstc *mstc = nv50_mstc(connector); struct nv50_mstc *mstc = nv50_mstc(connector);
struct nv50_mstm *mstm = mstc->mstm; struct nv50_mstm *mstm = mstc->mstm;
int bpp = connector->display_info.bpc * 3; struct nv50_head_atom *asyh = nv50_head_atom(crtc_state);
int slots; int slots;
mstc->pbn = drm_dp_calc_pbn_mode(crtc_state->adjusted_mode.clock, /* When restoring duplicated states, we need to make sure that the
bpp); * bw remains the same and avoid recalculating it, as the connector's
* bpc may have changed after the state was duplicated
*/
if (!state->duplicated)
asyh->dp.pbn =
drm_dp_calc_pbn_mode(crtc_state->adjusted_mode.clock,
connector->display_info.bpc * 3);
if (drm_atomic_crtc_needs_modeset(crtc_state)) { if (drm_atomic_crtc_needs_modeset(crtc_state)) {
slots = drm_dp_atomic_find_vcpi_slots(state, &mstm->mgr, slots = drm_dp_atomic_find_vcpi_slots(state, &mstm->mgr,
mstc->port, mstc->pbn); mstc->port,
asyh->dp.pbn);
if (slots < 0) if (slots < 0)
return slots; return slots;
asyh->dp.tu = slots;
} }
return nv50_outp_atomic_check_view(encoder, crtc_state, conn_state, return nv50_outp_atomic_check_view(encoder, crtc_state, conn_state,
...@@ -786,13 +793,13 @@ static void ...@@ -786,13 +793,13 @@ static void
nv50_msto_enable(struct drm_encoder *encoder) nv50_msto_enable(struct drm_encoder *encoder)
{ {
struct nv50_head *head = nv50_head(encoder->crtc); struct nv50_head *head = nv50_head(encoder->crtc);
struct nv50_head_atom *armh = nv50_head_atom(head->base.base.state);
struct nv50_msto *msto = nv50_msto(encoder); struct nv50_msto *msto = nv50_msto(encoder);
struct nv50_mstc *mstc = NULL; struct nv50_mstc *mstc = NULL;
struct nv50_mstm *mstm = NULL; struct nv50_mstm *mstm = NULL;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_list_iter conn_iter; struct drm_connector_list_iter conn_iter;
u8 proto, depth; u8 proto, depth;
int slots;
bool r; bool r;
drm_connector_list_iter_begin(encoder->dev, &conn_iter); drm_connector_list_iter_begin(encoder->dev, &conn_iter);
...@@ -808,8 +815,8 @@ nv50_msto_enable(struct drm_encoder *encoder) ...@@ -808,8 +815,8 @@ nv50_msto_enable(struct drm_encoder *encoder)
if (WARN_ON(!mstc)) if (WARN_ON(!mstc))
return; return;
slots = drm_dp_find_vcpi_slots(&mstm->mgr, mstc->pbn); r = drm_dp_mst_allocate_vcpi(&mstm->mgr, mstc->port, armh->dp.pbn,
r = drm_dp_mst_allocate_vcpi(&mstm->mgr, mstc->port, mstc->pbn, slots); armh->dp.tu);
WARN_ON(!r); WARN_ON(!r);
if (!mstm->links++) if (!mstm->links++)
...@@ -827,8 +834,7 @@ nv50_msto_enable(struct drm_encoder *encoder) ...@@ -827,8 +834,7 @@ nv50_msto_enable(struct drm_encoder *encoder)
default: depth = 0x6; break; default: depth = 0x6; break;
} }
mstm->outp->update(mstm->outp, head->base.index, mstm->outp->update(mstm->outp, head->base.index, armh, proto, depth);
nv50_head_atom(head->base.base.state), proto, depth);
msto->head = head; msto->head = head;
msto->mstc = mstc; msto->mstc = mstc;
......
...@@ -413,6 +413,7 @@ nv50_head_atomic_duplicate_state(struct drm_crtc *crtc) ...@@ -413,6 +413,7 @@ nv50_head_atomic_duplicate_state(struct drm_crtc *crtc)
asyh->ovly = armh->ovly; asyh->ovly = armh->ovly;
asyh->dither = armh->dither; asyh->dither = armh->dither;
asyh->procamp = armh->procamp; asyh->procamp = armh->procamp;
asyh->dp = armh->dp;
asyh->clr.mask = 0; asyh->clr.mask = 0;
asyh->set.mask = 0; asyh->set.mask = 0;
return &asyh->state; return &asyh->state;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment