Commit 06f4d7ce authored by Dave Airlie's avatar Dave Airlie Committed by Sasha Levin

drm/dp/mst: fixup handling hotplug on port removal.

[ Upstream commit df4839fd ]

output ports should always have a connector, unless
in the rare case connector allocation fails in the
driver.

In this case we only need to teardown the pdt,
and free the struct, and there is no need to
send a hotplug msg.

In the case were we add the port to the destroy
list we need to send a hotplug if we destroy
any connectors, so userspace knows to reprobe
stuff.

this patch also handles port->connector allocation
failing which should be a rare event, but makes
the code consistent.
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
parent 7d1dc93a
...@@ -861,29 +861,33 @@ static void drm_dp_destroy_port(struct kref *kref) ...@@ -861,29 +861,33 @@ static void drm_dp_destroy_port(struct kref *kref)
{ {
struct drm_dp_mst_port *port = container_of(kref, struct drm_dp_mst_port, kref); struct drm_dp_mst_port *port = container_of(kref, struct drm_dp_mst_port, kref);
struct drm_dp_mst_topology_mgr *mgr = port->mgr; struct drm_dp_mst_topology_mgr *mgr = port->mgr;
if (!port->input) { if (!port->input) {
port->vcpi.num_slots = 0; port->vcpi.num_slots = 0;
kfree(port->cached_edid); kfree(port->cached_edid);
/* we can't destroy the connector here, as /*
we might be holding the mode_config.mutex * The only time we don't have a connector
from an EDID retrieval */ * on an output port is if the connector init
* fails.
*/
if (port->connector) { if (port->connector) {
/* we can't destroy the connector here, as
* we might be holding the mode_config.mutex
* from an EDID retrieval */
mutex_lock(&mgr->destroy_connector_lock); mutex_lock(&mgr->destroy_connector_lock);
list_add(&port->next, &mgr->destroy_connector_list); list_add(&port->next, &mgr->destroy_connector_list);
mutex_unlock(&mgr->destroy_connector_lock); mutex_unlock(&mgr->destroy_connector_lock);
schedule_work(&mgr->destroy_connector_work); schedule_work(&mgr->destroy_connector_work);
return; return;
} }
/* no need to clean up vcpi
* as if we have no connector we never setup a vcpi */
drm_dp_port_teardown_pdt(port, port->pdt); drm_dp_port_teardown_pdt(port, port->pdt);
if (!port->input && port->vcpi.vcpi > 0)
drm_dp_mst_put_payload_id(mgr, port->vcpi.vcpi);
} }
kfree(port); kfree(port);
(*mgr->cbs->hotplug)(mgr);
} }
static void drm_dp_put_port(struct drm_dp_mst_port *port) static void drm_dp_put_port(struct drm_dp_mst_port *port)
...@@ -1113,12 +1117,21 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb, ...@@ -1113,12 +1117,21 @@ static void drm_dp_add_port(struct drm_dp_mst_branch *mstb,
char proppath[255]; char proppath[255];
build_mst_prop_path(port, mstb, proppath, sizeof(proppath)); build_mst_prop_path(port, mstb, proppath, sizeof(proppath));
port->connector = (*mstb->mgr->cbs->add_connector)(mstb->mgr, port, proppath); port->connector = (*mstb->mgr->cbs->add_connector)(mstb->mgr, port, proppath);
if (!port->connector) {
/* remove it from the port list */
mutex_lock(&mstb->mgr->lock);
list_del(&port->next);
mutex_unlock(&mstb->mgr->lock);
/* drop port list reference */
drm_dp_put_port(port);
goto out;
}
if (port->port_num >= 8) { if (port->port_num >= 8) {
port->cached_edid = drm_get_edid(port->connector, &port->aux.ddc); port->cached_edid = drm_get_edid(port->connector, &port->aux.ddc);
} }
} }
out:
/* put reference to this port */ /* put reference to this port */
drm_dp_put_port(port); drm_dp_put_port(port);
} }
...@@ -2740,7 +2753,7 @@ static void drm_dp_destroy_connector_work(struct work_struct *work) ...@@ -2740,7 +2753,7 @@ static void drm_dp_destroy_connector_work(struct work_struct *work)
{ {
struct drm_dp_mst_topology_mgr *mgr = container_of(work, struct drm_dp_mst_topology_mgr, destroy_connector_work); struct drm_dp_mst_topology_mgr *mgr = container_of(work, struct drm_dp_mst_topology_mgr, destroy_connector_work);
struct drm_dp_mst_port *port; struct drm_dp_mst_port *port;
bool send_hotplug = false;
/* /*
* Not a regular list traverse as we have to drop the destroy * Not a regular list traverse as we have to drop the destroy
* connector lock before destroying the connector, to avoid AB->BA * connector lock before destroying the connector, to avoid AB->BA
...@@ -2763,7 +2776,10 @@ static void drm_dp_destroy_connector_work(struct work_struct *work) ...@@ -2763,7 +2776,10 @@ static void drm_dp_destroy_connector_work(struct work_struct *work)
if (!port->input && port->vcpi.vcpi > 0) if (!port->input && port->vcpi.vcpi > 0)
drm_dp_mst_put_payload_id(mgr, port->vcpi.vcpi); drm_dp_mst_put_payload_id(mgr, port->vcpi.vcpi);
kfree(port); kfree(port);
send_hotplug = true;
} }
if (send_hotplug)
(*mgr->cbs->hotplug)(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