diff mbox series

[v3] thunderbolt: Add DP out resource when DP tunnel is discovered.

Message ID 1659587394-115256-1-git-send-email-Sanju.Mehta@amd.com
State New
Headers show
Series [v3] thunderbolt: Add DP out resource when DP tunnel is discovered. | expand

Commit Message

Sanjay R Mehta Aug. 4, 2022, 4:29 a.m. UTC
From: Sanjay R Mehta <sanju.mehta@amd.com>

If the boot firmware implements a connection manager of its
own it may create a DP tunnel and will be handed off to Linux
CM, but the DP out resource is not saved in the dp_resource
list.

This patch adds tunnelled DP out port to the dp_resource list
once the DP tunnel is discovered.

Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com>
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>

---
v3: make tb_dp_resource_available_discovered as static function.

v2: Re-ordering the function declaration as per Greg's comment.
---
 drivers/thunderbolt/tb.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index 9a3214f..53abce3 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -105,6 +105,21 @@  static void tb_remove_dp_resources(struct tb_switch *sw)
 	}
 }
 
+static void tb_dp_resource_available_discovered(struct tb *tb, struct tb_port *port)
+{
+	struct tb_cm *tcm = tb_priv(tb);
+	struct tb_port *p;
+
+	list_for_each_entry(p, &tcm->dp_resources, list) {
+		if (p == port)
+			return;
+	}
+
+	tb_port_dbg(port, "DP %s resource available discovered\n",
+		    tb_port_is_dpin(port) ? "IN" : "OUT");
+	list_add_tail(&port->list, &tcm->dp_resources);
+}
+
 static void tb_switch_discover_tunnels(struct tb_switch *sw,
 				       struct list_head *list,
 				       bool alloc_hopids)
@@ -118,6 +133,7 @@  static void tb_switch_discover_tunnels(struct tb_switch *sw,
 		switch (port->config.type) {
 		case TB_TYPE_DP_HDMI_IN:
 			tunnel = tb_tunnel_discover_dp(tb, port, alloc_hopids);
+			tb_dp_resource_available_discovered(tb, tunnel->dst_port);
 			break;
 
 		case TB_TYPE_PCIE_DOWN: