Commit 9254ec49 authored by Daniel Vetter's avatar Daniel Vetter Committed by Dave Airlie

drm/dp/mst: make sure mst_primary mstb is valid in work function

This validates the mst_primary under the lock, and then calls
into the check and send function. This makes the code a lot
easier to understand the locking rules in.
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent ce8e3942
...@@ -1189,7 +1189,7 @@ static void drm_dp_check_and_send_link_address(struct drm_dp_mst_topology_mgr *m ...@@ -1189,7 +1189,7 @@ static void drm_dp_check_and_send_link_address(struct drm_dp_mst_topology_mgr *m
struct drm_dp_mst_branch *mstb) struct drm_dp_mst_branch *mstb)
{ {
struct drm_dp_mst_port *port; struct drm_dp_mst_port *port;
struct drm_dp_mst_branch *mstb_child;
if (!mstb->link_address_sent) { if (!mstb->link_address_sent) {
drm_dp_send_link_address(mgr, mstb); drm_dp_send_link_address(mgr, mstb);
mstb->link_address_sent = true; mstb->link_address_sent = true;
...@@ -1204,17 +1204,31 @@ static void drm_dp_check_and_send_link_address(struct drm_dp_mst_topology_mgr *m ...@@ -1204,17 +1204,31 @@ static void drm_dp_check_and_send_link_address(struct drm_dp_mst_topology_mgr *m
if (!port->available_pbn) if (!port->available_pbn)
drm_dp_send_enum_path_resources(mgr, mstb, port); drm_dp_send_enum_path_resources(mgr, mstb, port);
if (port->mstb) if (port->mstb) {
drm_dp_check_and_send_link_address(mgr, port->mstb); mstb_child = drm_dp_get_validated_mstb_ref(mgr, port->mstb);
if (mstb_child) {
drm_dp_check_and_send_link_address(mgr, mstb_child);
drm_dp_put_mst_branch_device(mstb_child);
}
}
} }
} }
static void drm_dp_mst_link_probe_work(struct work_struct *work) static void drm_dp_mst_link_probe_work(struct work_struct *work)
{ {
struct drm_dp_mst_topology_mgr *mgr = container_of(work, struct drm_dp_mst_topology_mgr, work); struct drm_dp_mst_topology_mgr *mgr = container_of(work, struct drm_dp_mst_topology_mgr, work);
struct drm_dp_mst_branch *mstb;
drm_dp_check_and_send_link_address(mgr, mgr->mst_primary); mutex_lock(&mgr->lock);
mstb = mgr->mst_primary;
if (mstb) {
kref_get(&mstb->kref);
}
mutex_unlock(&mgr->lock);
if (mstb) {
drm_dp_check_and_send_link_address(mgr, mstb);
drm_dp_put_mst_branch_device(mstb);
}
} }
static bool drm_dp_validate_guid(struct drm_dp_mst_topology_mgr *mgr, static bool drm_dp_validate_guid(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