diff mbox series

[3/4] drm/dp_mst: Put connector of disconnected end device when handling CSN

Message ID 20210720160342.11415-4-Wayne.Lin@amd.com (mailing list archive)
State New, archived
Headers show
Series Unregister mst connectors when hotplug | expand

Commit Message

Lin, Wayne July 20, 2021, 4:03 p.m. UTC
[Why]
Now, after receiving CSN notifying that a port is disconnected, we can
unregister child connectors under a branch device via
drm_dp_mst_topology_put_mstb() in drm_dp_port_set_pdt(). However, if
this reported disconnected port is used to connect to an end
device(sst/dp_to_legace converter), we won't unregiser such connector.

[How]
Take sst/dp_to_legacy conveter device into consideration, also
unregister connectors of this case when handling CSN.

In addition, check whether port->connector exist to avoid
null pointer dereference.

Cc: stable@vger.kernel.org
Signed-off-by: Wayne Lin <Wayne.Lin@amd.com>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index f13c7187b07f..85a959427247 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -2567,6 +2567,12 @@  drm_dp_mst_handle_conn_stat(struct drm_dp_mst_branch *mstb,
 	else if (create_connector)
 		drm_dp_mst_port_add_connector(mstb, port);
 
+	if (port->connector && port->pdt == DP_PEER_DEVICE_NONE) {
+		drm_connector_unregister(port->connector);
+		drm_connector_put(port->connector);
+		port->connector = NULL;
+	}
+
 out:
 	drm_dp_mst_topology_put_port(port);
 	if (dowork)
@@ -4442,10 +4448,12 @@  int drm_dp_atomic_find_vcpi_slots(struct drm_atomic_state *state,
 	req_slots = DIV_ROUND_UP(pbn, pbn_div);
 
 	drm_dbg_atomic(mgr->dev, "[CONNECTOR:%d:%s] [MST PORT:%p] VCPI %d -> %d\n",
-		       port->connector->base.id, port->connector->name,
+		       port->connector ? port->connector->base.id : 0,
+		       port->connector ? port->connector->name : "NULL",
 		       port, prev_slots, req_slots);
 	drm_dbg_atomic(mgr->dev, "[CONNECTOR:%d:%s] [MST PORT:%p] PBN %d -> %d\n",
-		       port->connector->base.id, port->connector->name,
+		       port->connector ? port->connector->base.id : 0,
+		       port->connector ? port->connector->name : "NULL",
 		       port, prev_bw, pbn);
 
 	/* Add the new allocation to the state */