diff mbox series

[OEM5.14/J,SRU,v2,7/7] UBUNTU: SAUCE: thunderbolt: Add DP out resource when DP tunnel is discovered.

Message ID 20220802181115.22369-8-mario.limonciello@amd.com
State New
Headers show
Series | expand

Commit Message

Mario Limonciello Aug. 2, 2022, 6:11 p.m. UTC
From: Sanjay R Mehta <sanju.mehta@amd.com>

BugLink: https://bugs.launchpad.net/bugs/1983143

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>
(cherry-picked from https://lore.kernel.org/linux-usb/1657215088-6185-1-git-send-email-Sanju.Mehta@amd.com/)
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/thunderbolt/tb.c     | 15 +++++++++++++++
 drivers/thunderbolt/tb.h     |  1 +
 drivers/thunderbolt/tunnel.c |  2 ++
 3 files changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index a231191b06c6..9f55da11cf46 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -992,6 +992,21 @@  static void tb_dp_resource_unavailable(struct tb *tb, struct tb_port *port)
 	tb_tunnel_dp(tb);
 }
 
+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_dp_resource_available(struct tb *tb, struct tb_port *port)
 {
 	struct tb_cm *tcm = tb_priv(tb);
diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 3fae40670b72..3149b3ca0f2e 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -956,6 +956,7 @@  int tb_dp_port_set_hops(struct tb_port *port, unsigned int video,
 			unsigned int aux_tx, unsigned int aux_rx);
 bool tb_dp_port_is_enabled(struct tb_port *port);
 int tb_dp_port_enable(struct tb_port *port, bool enable);
+void tb_dp_resource_available_discovered(struct tb *tb, struct tb_port *port);
 
 struct tb_path *tb_path_discover(struct tb_port *src, int src_hopid,
 				 struct tb_port *dst, int dst_hopid,
diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c
index a473cc7d9a8d..7588cf9c70e6 100644
--- a/drivers/thunderbolt/tunnel.c
+++ b/drivers/thunderbolt/tunnel.c
@@ -832,6 +832,8 @@  struct tb_tunnel *tb_tunnel_discover_dp(struct tb *tb, struct tb_port *in,
 		goto err_deactivate;
 	}
 
+	tb_dp_resource_available_discovered(tb, tunnel->dst_port);
+
 	tb_tunnel_dbg(tunnel, "discovered\n");
 	return tunnel;