Commit 9dcf67de authored by Imre Deak's avatar Imre Deak

drm/dp_mst: Add helper to determine if an MST port is downstream of another port

Add drm_dp_mst_port_downstream_of_parent() required by the i915
driver in a follow-up patch to resolve a BW overallocation of MST
streams going through a given MST port.

Cc: Lyude Paul <lyude@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: default avatarLyude Paul <lyude@redhat.com>
Acked-by: default avatarMaxime Ripard <mripard@kernel.org>
Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231030155843.2251023-4-imre.deak@intel.com
parent 7707dd60
...@@ -5126,6 +5126,58 @@ static bool drm_dp_mst_port_downstream_of_branch(struct drm_dp_mst_port *port, ...@@ -5126,6 +5126,58 @@ static bool drm_dp_mst_port_downstream_of_branch(struct drm_dp_mst_port *port,
return false; return false;
} }
static bool
drm_dp_mst_port_downstream_of_parent_locked(struct drm_dp_mst_topology_mgr *mgr,
struct drm_dp_mst_port *port,
struct drm_dp_mst_port *parent)
{
if (!mgr->mst_primary)
return false;
port = drm_dp_mst_topology_get_port_validated_locked(mgr->mst_primary,
port);
if (!port)
return false;
if (!parent)
return true;
parent = drm_dp_mst_topology_get_port_validated_locked(mgr->mst_primary,
parent);
if (!parent)
return false;
if (!parent->mstb)
return false;
return drm_dp_mst_port_downstream_of_branch(port, parent->mstb);
}
/**
* drm_dp_mst_port_downstream_of_parent - check if a port is downstream of a parent port
* @mgr: MST topology manager
* @port: the port being looked up
* @parent: the parent port
*
* The function returns %true if @port is downstream of @parent. If @parent is
* %NULL - denoting the root port - the function returns %true if @port is in
* @mgr's topology.
*/
bool
drm_dp_mst_port_downstream_of_parent(struct drm_dp_mst_topology_mgr *mgr,
struct drm_dp_mst_port *port,
struct drm_dp_mst_port *parent)
{
bool ret;
mutex_lock(&mgr->lock);
ret = drm_dp_mst_port_downstream_of_parent_locked(mgr, port, parent);
mutex_unlock(&mgr->lock);
return ret;
}
EXPORT_SYMBOL(drm_dp_mst_port_downstream_of_parent);
static int static int
drm_dp_mst_atomic_check_port_bw_limit(struct drm_dp_mst_port *port, drm_dp_mst_atomic_check_port_bw_limit(struct drm_dp_mst_port *port,
struct drm_dp_mst_topology_state *state); struct drm_dp_mst_topology_state *state);
......
...@@ -892,6 +892,9 @@ drm_atomic_get_new_mst_topology_state(struct drm_atomic_state *state, ...@@ -892,6 +892,9 @@ drm_atomic_get_new_mst_topology_state(struct drm_atomic_state *state,
struct drm_dp_mst_atomic_payload * struct drm_dp_mst_atomic_payload *
drm_atomic_get_mst_payload_state(struct drm_dp_mst_topology_state *state, drm_atomic_get_mst_payload_state(struct drm_dp_mst_topology_state *state,
struct drm_dp_mst_port *port); struct drm_dp_mst_port *port);
bool drm_dp_mst_port_downstream_of_parent(struct drm_dp_mst_topology_mgr *mgr,
struct drm_dp_mst_port *port,
struct drm_dp_mst_port *parent);
int __must_check int __must_check
drm_dp_atomic_find_time_slots(struct drm_atomic_state *state, drm_dp_atomic_find_time_slots(struct drm_atomic_state *state,
struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_topology_mgr *mgr,
......
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