Commit 6f85f738 authored by Lyude Paul's avatar Lyude Paul

drm/dp_mst: Add basic topology reprobing when resuming

Finally! For a very long time, our MST helpers have had one very
annoying issue: They don't know how to reprobe the topology state when
coming out of suspend. This means that if a user has a machine connected
to an MST topology and decides to suspend their machine, we lose all
topology changes that happened during that period. That can be a big
problem if the machine was connected to a different topology on the same
port before resuming, as we won't bother reprobing any of the ports and
likely cause the user's monitors not to come back up as expected.

So, we start fixing this by teaching our MST helpers how to reprobe the
link addresses of each connected topology when resuming. As it turns
out, the behavior that we want here is identical to the behavior we want
when initially probing a newly connected MST topology, with a couple of
important differences:

- We need to be more careful about handling the potential races between
  events from the MST hub that could change the topology state as we're
  performing the link address reprobe
- We need to be more careful about handling unlikely state changes on
  ports - such as an input port turning into an output port, something
  that would be far more likely to happen in situations like the MST hub
  we're connected to being changed while we're suspend

Both of which have been solved by previous commits. That leaves one
requirement:

- We need to prune any MST ports in our in-memory topology state that
  were present when suspending, but have not appeared in the post-resume
  link address response from their parent branch device

Which we can now handle in this commit by modifying
drm_dp_send_link_address(). We then introduce suspend/resume reprobing
by introducing drm_dp_mst_topology_mgr_invalidate_mstb(), which we call
in drm_dp_mst_topology_mgr_suspend() to traverse the in-memory topology
state to indicate that each mstb needs it's link address resent and PBN
resources reprobed.

On resume, we start back up &mgr->work and have it reprobe the topology
in the same way we would on a hotplug, removing any leftover ports that
no longer appear in the topology state.

Changes since v4:
* Split indenting changes in drm_dp_mst_topology_mgr_resume() into a
  separate patch
* Only fire hotplugs when something has actually changed after a link
  address probe
* Don't try to change port->connector at all on ports, just throw out
  ports that need their connectors removed to make things easier.

Cc: Juston Li <juston.li@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Harry Wentland <hwentlan@amd.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: default avatarSean Paul <sean@poorly.run>
Signed-off-by: default avatarLyude Paul <lyude@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191022023641.8026-14-lyude@redhat.com
parent d20ebea8
...@@ -974,7 +974,7 @@ static void s3_handle_mst(struct drm_device *dev, bool suspend) ...@@ -974,7 +974,7 @@ static void s3_handle_mst(struct drm_device *dev, bool suspend)
if (suspend) { if (suspend) {
drm_dp_mst_topology_mgr_suspend(mgr); drm_dp_mst_topology_mgr_suspend(mgr);
} else { } else {
ret = drm_dp_mst_topology_mgr_resume(mgr); ret = drm_dp_mst_topology_mgr_resume(mgr, true);
if (ret < 0) { if (ret < 0) {
drm_dp_mst_topology_mgr_set_mst(mgr, false); drm_dp_mst_topology_mgr_set_mst(mgr, false);
need_hotplug = true; need_hotplug = true;
......
This diff is collapsed.
...@@ -7625,7 +7625,8 @@ void intel_dp_mst_resume(struct drm_i915_private *dev_priv) ...@@ -7625,7 +7625,8 @@ void intel_dp_mst_resume(struct drm_i915_private *dev_priv)
if (!intel_dp->can_mst) if (!intel_dp->can_mst)
continue; continue;
ret = drm_dp_mst_topology_mgr_resume(&intel_dp->mst_mgr); ret = drm_dp_mst_topology_mgr_resume(&intel_dp->mst_mgr,
true);
if (ret) { if (ret) {
intel_dp->is_mst = false; intel_dp->is_mst = false;
drm_dp_mst_topology_mgr_set_mst(&intel_dp->mst_mgr, drm_dp_mst_topology_mgr_set_mst(&intel_dp->mst_mgr,
......
...@@ -1309,14 +1309,14 @@ nv50_mstm_fini(struct nv50_mstm *mstm) ...@@ -1309,14 +1309,14 @@ nv50_mstm_fini(struct nv50_mstm *mstm)
} }
static void static void
nv50_mstm_init(struct nv50_mstm *mstm) nv50_mstm_init(struct nv50_mstm *mstm, bool runtime)
{ {
int ret; int ret;
if (!mstm || !mstm->mgr.mst_state) if (!mstm || !mstm->mgr.mst_state)
return; return;
ret = drm_dp_mst_topology_mgr_resume(&mstm->mgr); ret = drm_dp_mst_topology_mgr_resume(&mstm->mgr, !runtime);
if (ret == -1) { if (ret == -1) {
drm_dp_mst_topology_mgr_set_mst(&mstm->mgr, false); drm_dp_mst_topology_mgr_set_mst(&mstm->mgr, false);
drm_kms_helper_hotplug_event(mstm->mgr.dev); drm_kms_helper_hotplug_event(mstm->mgr.dev);
...@@ -2263,7 +2263,7 @@ nv50_display_init(struct drm_device *dev, bool resume, bool runtime) ...@@ -2263,7 +2263,7 @@ nv50_display_init(struct drm_device *dev, bool resume, bool runtime)
if (encoder->encoder_type != DRM_MODE_ENCODER_DPMST) { if (encoder->encoder_type != DRM_MODE_ENCODER_DPMST) {
struct nouveau_encoder *nv_encoder = struct nouveau_encoder *nv_encoder =
nouveau_encoder(encoder); nouveau_encoder(encoder);
nv50_mstm_init(nv_encoder->dp.mstm); nv50_mstm_init(nv_encoder->dp.mstm, runtime);
} }
} }
......
...@@ -706,7 +706,8 @@ void drm_dp_mst_dump_topology(struct seq_file *m, ...@@ -706,7 +706,8 @@ void drm_dp_mst_dump_topology(struct seq_file *m,
void drm_dp_mst_topology_mgr_suspend(struct drm_dp_mst_topology_mgr *mgr); void drm_dp_mst_topology_mgr_suspend(struct drm_dp_mst_topology_mgr *mgr);
int __must_check int __must_check
drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr); drm_dp_mst_topology_mgr_resume(struct drm_dp_mst_topology_mgr *mgr,
bool sync);
ssize_t drm_dp_mst_dpcd_read(struct drm_dp_aux *aux, ssize_t drm_dp_mst_dpcd_read(struct drm_dp_aux *aux,
unsigned int offset, void *buffer, size_t size); unsigned int offset, void *buffer, size_t size);
......
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