[PATCH v2 15/42] thunderbolt: No need to transition the link to symmetric during suspend

Imre Deak imre.deak at intel.com
Tue Jan 23 20:28:09 UTC 2024


From: Mika Westerberg <mika.westerberg at linux.intel.com>

There is no point transitioning the link back to symmetric when
suspending if it was asymmetric. The USB4 spec says the link should come
up as it was configured prior entering sleep so this saves unnecessary
link transitions.

Signed-off-by: Mika Westerberg <mika.westerberg at linux.intel.com>
---
 drivers/thunderbolt/tb.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index 59733521e7b01..91e3f950a66ae 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -1540,7 +1540,8 @@ static void tb_scan_port(struct tb_port *port)
 	}
 }
 
-static void tb_deactivate_and_free_tunnel(struct tb_tunnel *tunnel)
+static void tb_deactivate_and_free_tunnel(struct tb_tunnel *tunnel,
+					  bool suspending)
 {
 	struct tb_port *src_port, *dst_port;
 	struct tb *tb;
@@ -1564,10 +1565,12 @@ static void tb_deactivate_and_free_tunnel(struct tb_tunnel *tunnel)
 		 */
 		tb_switch_dealloc_dp_resource(src_port->sw, src_port);
 		/*
-		 * If bandwidth on a link is < asym_threshold
-		 * transition the link to symmetric.
+		 * If bandwidth on a link is < asym_threshold transition
+		 * the link to symmetric. But only if we are not
+		 * entering suspend.
 		 */
-		tb_configure_sym(tb, src_port, dst_port, true);
+		if (!suspending)
+			tb_configure_sym(tb, src_port, dst_port, true);
 		/* Now we can allow the domain to runtime suspend again */
 		pm_runtime_mark_last_busy(&dst_port->sw->dev);
 		pm_runtime_put_autosuspend(&dst_port->sw->dev);
@@ -1601,7 +1604,7 @@ static void tb_free_invalid_tunnels(struct tb *tb)
 
 	list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) {
 		if (tb_tunnel_is_invalid(tunnel))
-			tb_deactivate_and_free_tunnel(tunnel);
+			tb_deactivate_and_free_tunnel(tunnel, false);
 	}
 }
 
@@ -1985,7 +1988,7 @@ static void tb_dp_resource_unavailable(struct tb *tb, struct tb_port *port)
 	}
 
 	tunnel = tb_find_tunnel(tb, TB_TUNNEL_DP, in, out);
-	tb_deactivate_and_free_tunnel(tunnel);
+	tb_deactivate_and_free_tunnel(tunnel, false);
 	list_del_init(&port->list);
 
 	/*
@@ -2028,7 +2031,7 @@ static void tb_disconnect_and_release_dp(struct tb *tb)
 	 */
 	list_for_each_entry_safe_reverse(tunnel, n, &tcm->tunnel_list, list) {
 		if (tb_tunnel_is_dp(tunnel))
-			tb_deactivate_and_free_tunnel(tunnel);
+			tb_deactivate_and_free_tunnel(tunnel, true);
 	}
 
 	while (!list_empty(&tcm->dp_resources)) {
@@ -2175,7 +2178,7 @@ static void __tb_disconnect_xdomain_paths(struct tb *tb, struct tb_xdomain *xd,
 
 		if (tb_tunnel_match_dma(tunnel, transmit_path, transmit_ring,
 					receive_path, receive_ring))
-			tb_deactivate_and_free_tunnel(tunnel);
+			tb_deactivate_and_free_tunnel(tunnel, false);
 	}
 
 	/*
-- 
2.39.2



More information about the Intel-gfx-trybot mailing list