Skip to content
  1. Jan 10, 2019
    • Lyude Paul's avatar
      drm/nouveau: Use atomic VCPI helpers for MST · ace7e71e
      Lyude Paul authored
      
      
      Currently, nouveau uses the yolo method of setting up MST displays: it
      uses the old VCPI helpers (drm_dp_find_vcpi_slots()) for computing the
      display configuration. These helpers don't take care to make sure they
      take a reference to the mstb port that they're checking, and
      additionally don't actually check whether or not the topology still has
      enough bandwidth to provide the VCPI tokens required.
      
      So, drop usage of the old helpers and move entirely over to the atomic
      helpers.
      
      Changes since v6:
      * Cleanup atomic check logic and remove a bunch of unneeded checks -
        danvet
      Changes since v5:
      * Update nv50_msto_atomic_check() and nv50_mstc_atomic_check() to the
        new requirements for drm_dp_atomic_find_vcpi_slots() and
        drm_dp_atomic_release_vcpi_slots()
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Harry Wentland <harry.wentland@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      ace7e71e
    • Lyude Paul's avatar
      drm/dp_mst: Check payload count in drm_dp_mst_atomic_check() · fec48ce7
      Lyude Paul authored
      
      
      It occurred to me that we never actually check this! So let's start
      doing that.
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Harry Wentland <harry.wentland@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      fec48ce7
    • Lyude Paul's avatar
      drm/dp_mst: Start tracking per-port VCPI allocations · 07c5758b
      Lyude Paul authored
      
      
      There has been a TODO waiting for quite a long time in
      drm_dp_mst_topology.c:
      
      	/* We cannot rely on port->vcpi.num_slots to update
      	 * topology_state->avail_slots as the port may not exist if the parent
      	 * branch device was unplugged. This should be fixed by tracking
      	 * per-port slot allocation in drm_dp_mst_topology_state instead of
      	 * depending on the caller to tell us how many slots to release.
      	 */
      
      That's not the only reason we should fix this: forcing the driver to
      track the VCPI allocations throughout a state's atomic check is
      error prone, because it means that extra care has to be taken with the
      order that drm_dp_atomic_find_vcpi_slots() and
      drm_dp_atomic_release_vcpi_slots() are called in in order to ensure
      idempotency. Currently the only driver actually using these helpers,
      i915, doesn't even do this correctly: multiple ->best_encoder() checks
      with i915's current implementation would not be idempotent and would
      over-allocate VCPI slots, something I learned trying to implement
      fallback retraining in MST.
      
      So: simplify this whole mess, and teach drm_dp_atomic_find_vcpi_slots()
      and drm_dp_atomic_release_vcpi_slots() to track the VCPI allocations for
      each port. This allows us to ensure idempotency without having to rely
      on the driver as much. Additionally: the driver doesn't need to do any
      kind of VCPI slot tracking anymore if it doesn't need it for it's own
      internal state.
      
      Additionally; this adds a new drm_dp_mst_atomic_check() helper which
      must be used by atomic drivers to perform validity checks for the new
      VCPI allocations incurred by a state.
      
      Also: update the documentation and make it more obvious that these
      /must/ be called by /all/ atomic drivers supporting MST.
      
      Changes since v9:
      * Add some missing changes that were requested by danvet that I forgot
        about after I redid all of the kref stuff:
        * Remove unnecessary state changes in intel_dp_mst_atomic_check
        * Cleanup atomic check logic for VCPI allocations - all we need to check in
          compute_config is whether or not this state disables a CRTC, then free
          VCPI based off that
      
      Changes since v8:
       * Fix compile errors, whoops!
      
      Changes since v7:
       - Don't check for mixed stale/valid VCPI allocations, just rely on
       connector registration to stop such erroneous modesets
      
      Changes since v6:
       - Keep a kref to all of the ports we have allocations on. This required
         a good bit of changing to when we call drm_dp_find_vcpi_slots(),
         mainly that we need to ensure that we only redo VCPI allocations on
         actual mode or CRTC changes, not crtc_state->active changes.
         Additionally, we no longer take the registration of the DRM connector
         for each port into account because so long as we have a kref to the
         port in the new or previous atomic state, the connector will stay
         registered.
       - Use the small changes to drm_dp_put_port() to add even more error
         checking to make misusage of the helpers more obvious. I added this
         after having to chase down various use-after-free conditions that
         started popping up from the new helpers so no one else has to
         troubleshoot that.
       - Move some accidental DRM_DEBUG_KMS() calls to DRM_DEBUG_ATOMIC()
       - Update documentation again, note that find/release() should both not be
         called on the same port in a single atomic check phase (but multiple
         calls to one or the other is OK)
      
      Changes since v4:
       - Don't skip the atomic checks for VCPI allocations if no new VCPI
         allocations happen in a state. This makes the next change I'm about
         to list here a lot easier to implement.
       - Don't ignore VCPI allocations on destroyed ports, instead ensure that
         when ports are destroyed and still have VCPI allocations in the
         topology state, the only state changes allowed are releasing said
         ports' VCPI. This prevents a state with a mix of VCPI allocations
         from destroyed ports, and allocations from valid ports.
      
      Changes since v3:
       - Don't release VCPI allocations in the topology state immediately in
         drm_dp_atomic_release_vcpi_slots(), instead mark them as 0 and skip
         over them in drm_dp_mst_duplicate_state(). This makes it so
         drm_dp_atomic_release_vcpi_slots() is still idempotent while also
         throwing warnings if the driver messes up it's book keeping and tries
         to release VCPI slots on a port that doesn't have any pre-existing
         VCPI allocation - danvet
       - Change mst_state/state in some debugging messages to "mst state"
      
      Changes since v2:
       - Use kmemdup() for duplicating MST state - danvet
       - Move port validation out of duplicate state callback - danvet
       - Handle looping through MST topology states in
         drm_dp_mst_atomic_check() so the driver doesn't have to do it
       - Fix documentation in drm_dp_atomic_find_vcpi_slots()
       - Move the atomic check for each individual topology state into it's
         own function, reduces indenting
       - Don't consider "stale" MST ports when calculating the bandwidth
         requirements. This is needed because originally we relied on the
         state duplication functions to prune any stale ports from the new
         state, which would prevent us from incorrectly considering their
         bandwidth requirements alongside legitimate new payloads.
       - Add function references in drm_dp_atomic_release_vcpi_slots() - danvet
       - Annotate atomic VCPI and atomic check functions with __must_check
         - danvet
      
      Changes since v1:
       - Don't use the now-removed ->atomic_check() for private objects hook,
         just give drivers a function to call themselves
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Reviewed-by: default avatarDaniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Harry Wentland <harry.wentland@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      07c5758b
    • Lyude Paul's avatar
      drm/dp_mst: Add some atomic state iterator macros · 47c7645b
      Lyude Paul authored
      
      
      Changes since v6:
       - Move EXPORT_SYMBOL() for drm_dp_mst_topology_state_funcs to this
         commit
       - Document __drm_dp_mst_state_iter_get() and note that it shouldn't be
         called directly
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Harry Wentland <harry.wentland@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      47c7645b
    • Lyude Paul's avatar
      drm/nouveau: Grab payload lock in nv50_msto_payload() · eaaf7b6d
      Lyude Paul authored
      
      
      Going through the currently programmed payloads isn't safe without
      holding mgr->payload_lock, so actually do that and warn if anyone tries
      calling nv50_msto_payload() in the future without grabbing the right
      locks.
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Harry Wentland <harry.wentland@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      eaaf7b6d
    • Lyude Paul's avatar
      drm/nouveau: Stop unsetting mstc->port, use malloc refs · ce1fba59
      Lyude Paul authored
      
      
      Same as we did for i915, but for nouveau this time. Additionally, we
      grab a malloc reference to the port that lasts for the entire lifetime
      of nv50_mstc, which gives us the guarantee that mstc->port will always
      point to valid memory for as long as the mstc stays around.
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Harry Wentland <harry.wentland@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      ce1fba59
    • Lyude Paul's avatar
      drm/nouveau: Keep malloc references to MST ports · c831e228
      Lyude Paul authored
      
      
      Now that we finally have a sane way to keep port allocations around, use
      it to fix the potential unchecked ->port accesses that nouveau makes by
      making sure we keep the mst port allocated for as long as it's
      drm_connector is accessible.
      
      Additionally, now that we've guaranteed that mstc->port is allocated for
      as long as we keep mstc around we can remove the connector registration
      checks for codepaths which release payloads, allowing us to release
      payloads on active topologies properly. These registration checks were
      only required before in order to avoid situations where mstc->port could
      technically be pointing at freed memory.
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Harry Wentland <harry.wentland@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      c831e228
    • Lyude Paul's avatar
      drm/nouveau: Remove unnecessary VCPI checks in nv50_msto_cleanup() · 40e7adbe
      Lyude Paul authored
      
      
      There is no need to look at the port's VCPI allocation before calling
      drm_dp_mst_deallocate_vcpi(), as we already have msto->disabled to let
      us avoid cleaning up an msto more then once. The DP MST core will never
      call drm_dp_mst_deallocate_vcpi() on it's own, which is presumably what
      these checks are meant to protect against.
      
      More importantly though, we're about to stop clearing mstc->port in the
      next commit, which means if we could potentially hit a use-after-free
      error if we tried to check mstc->port->vcpi here. So to make life easier
      for anyone who bisects this code in the future, use msto->disabled
      instead to check whether or not we need to deallocate VCPI instead.
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Harry Wentland <harry.wentland@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      40e7adbe
    • Lyude Paul's avatar
      drm/nouveau: Remove bogus cleanup in nv50_mstm_add_connector() · f086e1e4
      Lyude Paul authored
      
      
      Trying to destroy the connector using mstc->connector.funcs->destroy()
      if connector initialization fails is wrong: there is no possible
      codepath in nv50_mstc_new where nv50_mstm_add_connector() would return
      <0 and mstc would be non-NULL.
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Harry Wentland <harry.wentland@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      f086e1e4
    • Lyude Paul's avatar
      drm/amdgpu/display: Keep malloc ref to MST port · 57b46e91
      Lyude Paul authored
      
      
      Just like i915 and nouveau, it's a good idea for us to hold a malloc
      reference to the port here so that we never pass a freed pointer to any
      of the DP MST helper functions.
      
      Also, we stop unsetting aconnector->port in
      dm_dp_destroy_mst_connector(). There's literally no point to that
      assignment that I can see anyway.
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      57b46e91
    • Lyude Paul's avatar
      drm/i915: Keep malloc references to MST ports · 55a7f34e
      Lyude Paul authored
      
      
      So that the ports stay around until we've destroyed the connectors, in
      order to ensure that we don't pass an invalid pointer to any MST helpers
      once we introduce the new MST VCPI helpers.
      
      Changes since v1:
      * Move drm_dp_mst_get_port_malloc() to where we assign
        intel_connector->port - danvet
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Reviewed-by: default avatarDaniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Harry Wentland <harry.wentland@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      55a7f34e
    • Lyude Paul's avatar
      drm/dp_mst: Fix payload deallocation on hotplugs using malloc refs · 1f1ac426
      Lyude Paul authored
      
      
      Up until now, freeing payloads on remote MST hubs that just had ports
      removed has almost never worked because we've been relying on port
      validation in order to stop us from accessing ports that have already
      been freed from memory, but ports which need their payloads released due
      to being removed will never be a valid part of the topology after
      they've been removed.
      
      Since we've introduced malloc refs, we can replace all of the validation
      logic in payload helpers which are used for deallocation with some
      well-placed malloc krefs. This ensures that regardless of whether or not
      the ports are still valid and in the topology, any port which has an
      allocated payload will remain allocated in memory until it's payloads
      have been removed - finally allowing us to actually release said
      payloads correctly.
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      1f1ac426
    • Lyude Paul's avatar
      drm/dp_mst: Stop releasing VCPI when removing ports from topology · 73de9b01
      Lyude Paul authored
      
      
      This has never actually worked, and isn't needed anyway: the driver's
      always going to try to deallocate VCPI when it tears down the display
      that the VCPI belongs to.
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
      Reviewed-by: default avatarDaniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      73de9b01
    • Lyude Paul's avatar
      drm/dp_mst: Restart last_connected_port_and_mstb() if topology ref fails · c168e720
      Lyude Paul authored
      
      
      While this isn't a complete fix, this will improve the reliability of
      drm_dp_get_last_connected_port_and_mstb() pretty significantly during
      hotplug events, since there's a chance that the in-memory topology tree
      may not be fully updated when drm_dp_get_last_connected_port_and_mstb()
      is called and thus might end up causing our search to fail on an mstb
      whose topology refcount has reached 0, but has not yet been removed from
      it's parent.
      
      Ideally, we should further fix this problem by ensuring that we deal
      with the potential for racing with a hotplug event, which would look
      like this:
      
      * drm_dp_payload_send_msg() retrieves the last living relative of mstb
        with drm_dp_get_last_connected_port_and_mstb()
      * drm_dp_payload_send_msg() starts building payload message
        At the same time, mstb gets unplugged from the topology and is no
        longer the actual last living relative of the original mstb
      * drm_dp_payload_send_msg() tries sending the payload message, hub times
        out
      * Hub timed out, we give up and run away-resulting in the payload being
        leaked
      
      This could be fixed by restarting the
      drm_dp_get_last_connected_port_and_mstb() search whenever we get a
      timeout, sending the payload to the new mstb, then repeating until
      either the entire topology is removed from the system or
      drm_dp_get_last_connected_port_and_mstb() fails. But since the above
      race condition is not terribly likely, we'll address that in a later
      patch series once we've improved the recovery handling for VCPI
      allocations in the rest of the DP MST helpers.
      
      Changes since v1:
      * Convert kerneldoc for drm_dp_get_last_connected_port_and_mstb to
        normal comment - danvet
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
      Reviewed-by: default avatarDaniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      c168e720
    • Lyude Paul's avatar
      drm/dp_mst: Introduce new refcounting scheme for mstbs and ports · 09b0b312
      Lyude Paul authored
      
      
      The current way of handling refcounting in the DP MST helpers is really
      confusing and probably just plain wrong because it's been hacked up many
      times over the years without anyone actually going over the code and
      seeing if things could be simplified.
      
      To the best of my understanding, the current scheme works like this:
      drm_dp_mst_port and drm_dp_mst_branch both have a single refcount. When
      this refcount hits 0 for either of the two, they're removed from the
      topology state, but not immediately freed. Both ports and branch devices
      will reinitialize their kref once it's hit 0 before actually destroying
      themselves. The intended purpose behind this is so that we can avoid
      problems like not being able to free a remote payload that might still
      be active, due to us having removed all of the port/branch device
      structures in memory, as per:
      
      commit 91a25e46 ("drm/dp/mst: deallocate payload on port destruction")
      
      Which may have worked, but then it caused use-after-free errors. Being
      new to MST at the time, I tried fixing it;
      
      commit 263efde3 ("drm/dp/mst: Get validated port ref in drm_dp_update_payload_part1()")
      
      But, that was broken: both drm_dp_mst_port and drm_dp_mst_branch structs
      are validated in almost every DP MST helper function. Simply put, this
      means we go through the topology and try to see if the given
      drm_dp_mst_branch or drm_dp_mst_port is still attached to something
      before trying to use it in order to avoid dereferencing freed memory
      (something that has happened a LOT in the past with this library).
      Because of this it doesn't actually matter whether or not we keep keep
      the ports and branches around in memory as that's not enough, because
      any function that validates the branches and ports passed to it will
      still reject them anyway since they're no longer in the topology
      structure. So, use-after-free errors were fixed but payload deallocation
      was completely broken.
      
      Two years later, AMD informed me about this issue and I attempted to
      come up with a temporary fix, pending a long-overdue cleanup of this
      library:
      
      commit c54c7374 ("drm/dp_mst: Skip validating ports during destruction, just ref")
      
      But then that introduced use-after-free errors, so I quickly reverted
      it:
      
      commit 9765635b ("Revert "drm/dp_mst: Skip validating ports during destruction, just ref"")
      
      And in the process, learned that there is just no simple fix for this:
      the design is just broken. Unfortunately, the usage of these helpers are
      quite broken as well. Some drivers like i915 have been smart enough to
      avoid accessing any kind of information from MST port structures, but
      others like nouveau have assumed, understandably so, that
      drm_dp_mst_port structures are normal and can just be accessed at any
      time without worrying about use-after-free errors.
      
      After a lot of discussion, me and Daniel Vetter came up with a better
      idea to replace all of this.
      
      To summarize, since this is documented far more indepth in the
      documentation this patch introduces, we make it so that drm_dp_mst_port
      and drm_dp_mst_branch structures have two different classes of
      refcounts: topology_kref, and malloc_kref. topology_kref corresponds to
      the lifetime of the given drm_dp_mst_port or drm_dp_mst_branch in it's
      given topology. Once it hits zero, any associated connectors are removed
      and the branch or port can no longer be validated. malloc_kref
      corresponds to the lifetime of the memory allocation for the actual
      structure, and will always be non-zero so long as the topology_kref is
      non-zero. This gives us a way to allow callers to hold onto port and
      branch device structures past their topology lifetime, and dramatically
      simplifies the lifetimes of both structures. This also finally fixes the
      port deallocation problem, properly.
      
      Additionally: since this now means that we can keep ports and branch
      devices allocated in memory for however long we need, we no longer need
      a significant amount of the port validation that we currently do.
      
      Additionally, there is one last scenario that this fixes, which couldn't
      have been fixed properly beforehand:
      
      - CPU1 unrefs port from topology (refcount 1->0)
      - CPU2 refs port in topology(refcount 0->1)
      
      Since we now can guarantee memory safety for ports and branches
      as-needed, we also can make our main reference counting functions fix
      this problem by using kref_get_unless_zero() internally so that topology
      refcounts can only ever reach 0 once.
      
      Changes since v4:
      * Change the kernel-figure summary for dp-mst/topology-figure-1.dot a
        bit - danvet
      * Remove figure numbers - danvet
      
      Changes since v3:
      * Remove rebase detritus - danvet
      * Split out purely style changes into separate patches - hwentlan
      
      Changes since v2:
      * Fix commit message - checkpatch
      * s/)-1/) - 1/g - checkpatch
      
      Changes since v1:
      * Remove forward declarations - danvet
      * Move "Branch device and port refcounting" section from documentation
        into kernel-doc comments - danvet
      * Export internal topology lifetime functions into their own section in
        the kernel-docs - danvet
      * s/@/&/g for struct references in kernel-docs - danvet
      * Drop the "when they are no longer being used" bits from the kernel
        docs - danvet
      * Modify diagrams to show how the DRM driver interacts with the topology
        and payloads - danvet
      * Make suggested documentation changes for
        drm_dp_mst_topology_get_mstb() and drm_dp_mst_topology_get_port() -
        danvet
      * Better explain the relationship between malloc refs and topology krefs
        in the documentation for drm_dp_mst_topology_get_port() and
        drm_dp_mst_topology_get_mstb() - danvet
      * Fix "See also" in drm_dp_mst_topology_get_mstb() - danvet
      * Rename drm_dp_mst_topology_get_(port|mstb)() ->
        drm_dp_mst_topology_try_get_(port|mstb)() and
        drm_dp_mst_topology_ref_(port|mstb)() ->
        drm_dp_mst_topology_get_(port|mstb)() - danvet
      * s/should/must in docs - danvet
      * WARN_ON(refcount == 0) in topology_get_(mstb|port) - danvet
      * Move kdocs for mstb/port structs inline - danvet
      * Split drm_dp_get_last_connected_port_and_mstb() changes into their own
        commit - danvet
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
      Reviewed-by: default avatarDaniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      09b0b312
    • Lyude Paul's avatar
      drm/dp_mst: Rename drm_dp_mst_get_validated_(port|mstb)_ref and friends · 0df342a5
      Lyude Paul authored
      
      
      s/drm_dp_get_validated_port_ref/drm_dp_mst_topology_get_port_validated/
      s/drm_dp_put_port/drm_dp_mst_topology_put_port/
      s/drm_dp_get_validated_mstb_ref/drm_dp_mst_topology_get_mstb_validated/
      s/drm_dp_put_mst_branch_device/drm_dp_mst_topology_put_mstb/
      
      This is a much more consistent naming scheme, and will make even more
      sense once we redesign how the current refcounting scheme here works.
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Reviewed-by: default avatarDaniel Vetter <daniel@ffwll.ch>
      Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      0df342a5
    • Lyude Paul's avatar
      drm/dp_mst: Fix some formatting in drm_dp_mst_deallocate_vcpi() · 1ccfcdef
      Lyude Paul authored
      
      
      Split some stuff across multiple lines
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
      Reviewed-by: default avatarDaniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      1ccfcdef
    • Lyude Paul's avatar
      drm/dp_mst: Fix some formatting in drm_dp_mst_allocate_vcpi() · dc465627
      Lyude Paul authored
      
      
      Fix some indenting, split some stuff across multiple lines.
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
      Reviewed-by: default avatarDaniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      dc465627
    • Lyude Paul's avatar
      drm/dp_mst: Fix some formatting in drm_dp_payload_send_msg() · aa31817b
      Lyude Paul authored
      
      
      Split some stuff across multiple lines, remove some unnecessary braces
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
      Reviewed-by: default avatarDaniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      aa31817b
    • Lyude Paul's avatar
      drm/dp_mst: Fix some formatting in drm_dp_add_port() · f4b03cc0
      Lyude Paul authored
      
      
      Reindent some stuff, and split some stuff across multiple lines so we
      aren't going over the text width limit.
      
      Signed-off-by: Lyude Paul's avatarLyude Paul <lyude@redhat.com>
      Reviewed-by: default avatarHarry Wentland <harry.wentland@amd.com>
      Reviewed-by: default avatarDaniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@redhat.com>
      Cc: Jerry Zuo <Jerry.Zuo@amd.com>
      Cc: Juston Li <juston.li@intel.com>
      f4b03cc0
    • Ville Syrjälä's avatar
    • Ville Syrjälä's avatar
    • Ville Syrjälä's avatar
    • Ville Syrjälä's avatar
    • Ville Syrjälä's avatar
    • Ville Syrjälä's avatar
      Merge remote-tracking branch 'drm_misc_push/drm-misc-next' into drm-tip · 2700eb0f
      Ville Syrjälä authored
      # Conflicts:
      #	drivers/gpu/drm/omapdrm/omap_encoder.c
      2700eb0f
    • Ville Syrjälä's avatar
    • Ville Syrjälä's avatar
    • Ville Syrjälä's avatar
      drm/edid: Add display_info.rgb_quant_range_selectable · 1581b2df
      Ville Syrjälä authored
      
      
      Move the CEA-861 QS bit handling entirely into the edid code. No
      need to bother the drivers with this.
      
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: "Christian König" <christian.koenig@amd.com>
      Cc: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
      Cc: amd-gfx@lists.freedesktop.org
      Cc: Eric Anholt <eric@anholt.net> (supporter:DRM DRIVERS FOR VC4)
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Acked-by: default avatarEric Anholt <eric@anholt.net>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190108172828.15184-4-ville.syrjala@linux.intel.com
      1581b2df
    • Ville Syrjälä's avatar
      drm/radeon: Use drm_hdmi_avi_infoframe_quant_range() · 8ee491b4
      Ville Syrjälä authored
      
      
      Fill out the AVI infoframe quantization range bits using
      drm_hdmi_avi_infoframe_quant_range() instead of hand rolling it.
      
      This changes the behaviour slightly as
      drm_hdmi_avi_infoframe_quant_range() will set a non-zero Q bit
      even when QS==0 iff the Q bit matched the default quantization
      range for the given mode. This matches the recommendation in
      HDMI 2.0 and is allowed even before that.
      
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: "Christian König" <christian.koenig@amd.com>
      Cc: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
      Cc: amd-gfx@lists.freedesktop.org
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190108172828.15184-3-ville.syrjala@linux.intel.com
      8ee491b4
    • Ville Syrjälä's avatar
      drm/i915: Use drm_hdmi_avi_infoframe_quant_range() for SDVO HDMI as well · c3735f5c
      Ville Syrjälä authored
      
      
      Fill out the AVI infoframe quantization range bits using
      drm_hdmi_avi_infoframe_quant_range() for SDVO HDMI encoder as well.
      
      This changes the behaviour slightly as
      drm_hdmi_avi_infoframe_quant_range() will set a non-zero Q bit
      even when QS==0 iff the Q bit matched the default quantization
      range for the given mode. This matches the recommendation in
      HDMI 2.0 and is allowed even before that.
      
      v2: Pimp commit msg (DK)
      
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Reviewed-by: default avatarDhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190108172828.15184-2-ville.syrjala@linux.intel.com
      c3735f5c
    • Ville Syrjälä's avatar
      drm/edid: Pass connector to AVI infoframe functions · 13d0add3
      Ville Syrjälä authored
      
      
      Make life easier for drivers by simply passing the connector
      to drm_hdmi_avi_infoframe_from_display_mode() and
      drm_hdmi_avi_infoframe_quant_range(). That way drivers don't
      need to worry about is_hdmi2_sink mess.
      
      v2: Make is_hdmi2_sink() return true for sil-sii8620
          Adapt to omap/vc4 changes
      
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: "Christian König" <christian.koenig@amd.com>
      Cc: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
      Cc: Archit Taneja <architt@codeaurora.org>
      Cc: Andrzej Hajda <a.hajda@samsung.com>
      Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
      Cc: Inki Dae <inki.dae@samsung.com>
      Cc: Joonyoung Shim <jy0922.shim@samsung.com>
      Cc: Seung-Woo Kim <sw0312.kim@samsung.com>
      Cc: Kyungmin Park <kyungmin.park@samsung.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: CK Hu <ck.hu@mediatek.com>
      Cc: Philipp Zabel <p.zabel@pengutronix.de>
      Cc: Rob Clark <robdclark@gmail.com>
      Cc: Ben Skeggs <bskeggs@redhat.com>
      Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
      Cc: Sandy Huang <hjc@rock-chips.com>
      Cc: "Heiko Stübner" <heiko@sntech.de>
      Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
      Cc: Vincent Abriou <vincent.abriou@st.com>
      Cc: Thierry Reding <thierry.reding@gmail.com>
      Cc: Eric Anholt <eric@anholt.net>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Ilia Mirkin <imirkin@alum.mit.edu>
      Cc: amd-gfx@lists.freedesktop.org
      Cc: linux-arm-msm@vger.kernel.org
      Cc: freedreno@lists.freedesktop.org
      Cc: nouveau@lists.freedesktop.org
      Cc: linux-tegra@vger.kernel.org
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Acked-by: default avatarThierry Reding <treding@nvidia.com>
      Acked-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190108172828.15184-1-ville.syrjala@linux.intel.com
      13d0add3
    • Chris Wilson's avatar
      drm/i915: Removing polling for struct_mutex from vmap shrinker · 9fab8a2e
      Chris Wilson authored
      
      
      The wait-for-idle used from within the shrinker_lock_uninterruptible
      depends on the struct_mutex locking state being known and declared to
      i915_request_wait(). As it is conceivable that we reach the vmap
      notifier from underneath struct_mutex (and so keep on relying on the
      mutex_trylock_recursive), we should not blindly call i915_request_wait.
      
      In the process we can remove the dubious polling to acquire
      struct_mutex, and simply act, or not, on a successful trylock.
      
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
      Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190109164204.23935-2-chris@chris-wilson.co.uk
      9fab8a2e
    • Chris Wilson's avatar
      drm/i915: Use mutex_lock_killable() from inside the shrinker · 3824e419
      Chris Wilson authored
      
      
      If the current process is being killed (it was interrupted with SIGKILL
      or equivalent), it will not make any progress in page allocation and we
      can abort performing the shrinking on its behalf. So we can use
      mutex_lock_killable() instead (although this path should only be
      reachable from kswapd currently).
      
      Tvrtko pointed out that it should also be reachable from debugfs, which
      he would prefer retain its interruptiblity. As a compromise, killable is a
      step in the right direction!
      
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
      Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190109164204.23935-1-chris@chris-wilson.co.uk
      3824e419
    • Chris Wilson's avatar
      drm/i915: Guard error capture against unpinned vma · 7f9e20ef
      Chris Wilson authored
      
      
      If we find an incompletely setup vma inside the request/engine at the
      time of a hang, it may not have vma->pages initialised, so skip
      capturing the object before we iterate over NULL.
      
      Spotted by Matthew in preparation for using unpinned vma to track engine
      state.
      
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Cc: Matthew Auld <matthew.auld@intel.com>
      Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190110111522.11023-1-chris@chris-wilson.co.uk
      7f9e20ef
    • José Roberto de Souza's avatar
      drm: Fix documentation generation for DP_DPCD_QUIRK_NO_PSR · f299e0bd
      José Roberto de Souza authored and Jani Nikula's avatar Jani Nikula committed
      
      
      The DP_DPCD_QUIRK_NO_PSR comment is missing colon causing this
      warning when generating kernel documentation.
      
      ./include/drm/drm_dp_helper.h:1374: warning: Incorrect use of kernel-doc format:          * @DP_DPCD_QUIRK_NO_PSR
      
      Fixes: 1035f4a6 ("drm/i915: Disable PSR in Apple panels")
      Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
      Signed-off-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      Reviewed-by: default avatarDhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20181205184850.13218-1-jose.souza@intel.com
      
      
      (cherry picked from commit ed17b555)
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      f299e0bd
    • Daniele Ceraolo Spurio's avatar
      drm/i915: init per-engine WAs for all engines · 70e31424
      Daniele Ceraolo Spurio authored and Jani Nikula's avatar Jani Nikula committed
      
      
      commit 4a15c75c ("drm/i915: Introduce per-engine workarounds")
      refactored the workaround code to have functions per-engine, but didn't
      call any of them from logical_xcs_ring_init. Since we do have a non-RCS
      workaround for KBL (WaKBLVECSSemaphoreWaitPoll) we do need to call
      intel_engine_init_workarounds for non-RCS engines.
      Note that whitelist is still RCS-only.
      
      v2: move the call to logical_ring_init (Chris)
      
      Fixes: 4a15c75c ("drm/i915: Introduce per-engine workarounds")
      Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: default avatarDaniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
      Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Signed-off-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190110013232.8972-2-daniele.ceraolospurio@intel.com
      
      
      (cherry picked from commit a60acb22)
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      70e31424
    • Chris Wilson's avatar
      drm/i915: Unwind failure on pinning the gen7 ppgtt · 280d479b
      Chris Wilson authored and Jani Nikula's avatar Jani Nikula committed
      
      
      If we fail to pin the ggtt vma slot for the ppgtt page tables, we need
      to unwind the locals before reporting the error. Or else on subsequent
      attempts to bind the page tables into the ggtt, we will already believe
      that the vma has been pinned and continue on blithely. If something else
      should happen to be at that location, choas ensues.
      
      Fixes: a2bbf714 ("drm/i915/gtt: Only keep gen6 page directories pinned while active")
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
      Cc: Matthew Auld <matthew.william.auld@gmail.com>
      Cc: <stable@vger.kernel.org> # v4.19+
      Reviewed-by: default avatarMatthew Auld <matthew.william.auld@gmail.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20181222030623.21710-1-chris@chris-wilson.co.uk
      
      
      (cherry picked from commit d4de7535)
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      280d479b
    • Chris Wilson's avatar
      drm/i915: Skip the ERR_PTR error state · 107c595c
      Chris Wilson authored and Jani Nikula's avatar Jani Nikula committed
      
      
      Although commit fb6f0b64 ("drm/i915: Prevent machine hang from
      Broxton's vtd w/a and error capture") applied cleanly after a 24 month
      hiatus, the code had moved on with new methods for peeking and fetching
      the captured gpu info. Make sure we catch all uses of the stashed error
      state and avoid dereferencing the error pointer.
      
      v2: Move error pointer determination into i915_gpu_capture_state
      v3: Restore early check to avoid capturing and then throwing away
      subsequent GPU error states.
      
      Fixes: fb6f0b64 ("drm/i915: Prevent machine hang from Broxton's vtd w/a and error capture")
      Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
      Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20181207110554.19897-1-chris@chris-wilson.co.uk
      
      
      (cherry picked from commit e6154e4c)
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      107c595c
    • José Roberto de Souza's avatar
      drm/i915: Disable PSR in Apple panels · 1035f4a6
      José Roberto de Souza authored and Jani Nikula's avatar Jani Nikula committed
      
      
      i915 yet don't support PSR in Apple panels, so lets keep it disabled
      while we work on that.
      
      v2: Renamed DP_DPCD_QUIRK_PSR_NOT_CURRENTLY_SUPPORTED to
      DP_DPCD_QUIRK_NO_PSR (Ville)
      
      v3:
      Adding documentation to DP_DPCD_QUIRK_NO_PSR(Dhinakaran and Jani)
      Fixed typo in comment of the new quirk entry(Jani)
      
      Fixes: 598c6cfe (drm/i915/psr: Enable PSR1 on gen-9+ HW)
      Cc: Jani Nikula <jani.nikula@intel.com>
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
      Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
      Reviewed-by: default avatarDhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
      Signed-off-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20181204003403.23361-1-jose.souza@intel.com
      
      
      (cherry picked from commit 7c5c641a)
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      1035f4a6
Loading