• Lyude Paul's avatar
    drm/dp_mst: Add topology ref history tracking for debugging · 12a280c7
    Lyude Paul authored
    For very subtle mistakes with topology refs, it can be rather difficult
    to trace them down with the debugging info that we already have. I had
    one such issue recently while trying to implement suspend/resume
    reprobing for MST, and ended up coming up with this.
    
    Inspired by Chris Wilson's wakeref tracking for i915, this adds a very
    similar feature to the DP MST helpers, which allows for partial tracking
    of topology refs for both ports and branch devices. This is a lot less
    advanced then wakeref tracking: we merely keep a count of all of the
    spots where a topology ref has been grabbed or dropped, then dump out
    that history in chronological order when a port or branch device's
    topology refcount reaches 0. So far, I've found this incredibly useful
    for debugging topology refcount errors.
    
    Since this has the potential to be somewhat slow and loud, we add an
    expert kernel config option to enable or disable this feature,
    CONFIG_DRM_DEBUG_DP_MST_TOPOLOGY_REFS.
    
    Changes since v1:
    * Don't forget to destroy topology_ref_history_lock
    Changes since v4:
    * Correct order of kref_put()/topology_ref_history_unlock - we can't
      unlock the history after kref_put() since the memory might have been
      freed by that point
    * Don't print message on allocation error failures, the kernel already
      does this for us
    Changes since v5:
    * Get rid of some leftover usages of %px
    * Remove a leftover empty return; statement
    
    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-15-lyude@redhat.com
    12a280c7
drm_dp_mst_topology.c 136 KB