Skip to contentSkip to conversation

thunderbolt: Disable Gen 4 Recovery on Asymmetric Transitions

PATCH Superseded Mohammad Rahimi 1 participant 1 message Jan 31, 2025

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 thunderbolt: Disable Gen 4 Recovery on Asymmetric Transitions

Updates the Connection Manager to disable the Gen 4 Link Recovery flow before transitioning from a Symmetric Link to an Asymmetric Link, as specified in recent changes to the USB4 v2 specification.

According to the "USB4 2.0 ENGINEERING CHANGE NOTICE FORM" published in September 2024, the rationale for this change is:

"Since the default value of the Target Asymmetric Link might be different than Symmetric Link and Gen 4 Link Recovery flow checks this field to make sure it matched the actual Negotiated Link Width, we’re removing the condition for a Disconnect in the Gen 4 Link Recovery flow when Target Asymmetric Link doesn’t match the actual Link width and adding a Connection Manager note to Disable Gen 4 Link Recovery flow before doing Asymmetric Transitions."

---
 drivers/thunderbolt/tb.c      | 18 ++++++--
 drivers/thunderbolt/tb.h      |  3 ++
 drivers/thunderbolt/tb_regs.h |  1 +
 drivers/thunderbolt/usb4.c    | 77 +++++++++++++++++++++++++++++++++++
 4 files changed, 96 insertions(+), 3 deletions(-)
drivers/thunderbolt/tb.c +15 -3
index a7c6919fbf97..923d08b26631 100644
@@ -1013,6 +1013,7 @@ static int tb_configure_asym(struct tb *tb, struct tb_port *src_port,
 			     struct tb_port *dst_port, int requested_up,
 			     int requested_down)
 {
+	bool link_recovery_up = false, link_recovery_down = false;
 	bool clx = false, clx_disabled = false, downstream;
 	struct tb_switch *sw;
 	struct tb_port *up;
@@ -1075,15 +1076,19 @@ static int tb_configure_asym(struct tb *tb, struct tb_port *src_port,
 			continue;
 
 		/*
-		 * Disable CL states before doing any transitions. We
-		 * delayed it until now that we know there is a real
-		 * transition taking place.
+		 * Disable CL states and Link Recovery before doing any
+		 * transitions. We delayed it until now that we know
+		 * there is a real transition taking place.
 		 */
 		if (!clx_disabled) {
 			clx = tb_disable_clx(sw);
 			clx_disabled = true;
 		}
 
+		/* Ignore non-critical errors of disabling Link Recovery */
+		link_recovery_up = (0 < usb4_port_link_recovery_disable(up));
+		link_recovery_down = (0 < usb4_port_link_recovery_disable(down));
+
 		tb_sw_dbg(up->sw, "configuring asymmetric link\n");
 
 		/*
@@ -1091,6 +1096,13 @@ static int tb_configure_asym(struct tb *tb, struct tb_port *src_port,
 		 * transtion the link into asymmetric now.
 		 */
 		ret = tb_switch_set_link_width(up->sw, width_up);
+
+		/* Re-enable Link Recovery if they were previously enabled */
+		if (link_recovery_up)
+			usb4_port_link_recovery_enable(up);
+		if (link_recovery_down)
+			usb4_port_link_recovery_enable(down);
+
 		if (ret) {
 			tb_sw_warn(up->sw, "failed to set link width\n");
 			break;
drivers/thunderbolt/tb.h +3 -0
index ddbf0cd78377..d37d778082fc 100644
@@ -1332,6 +1332,9 @@ int usb4_port_router_online(struct tb_port *port);
 int usb4_port_enumerate_retimers(struct tb_port *port);
 bool usb4_port_clx_supported(struct tb_port *port);
 
+int usb4_port_link_recovery_enable(struct tb_port *port);
+int usb4_port_link_recovery_disable(struct tb_port *port);
+
 bool usb4_port_asym_supported(struct tb_port *port);
 int usb4_port_asym_set_link_width(struct tb_port *port, enum tb_link_width width);
 int usb4_port_asym_start(struct tb_port *port);
drivers/thunderbolt/tb_regs.h +1 -0
index 4e43b47f9f11..085139e1a958 100644
@@ -398,6 +398,7 @@ struct tb_regs_port_header {
 #define PORT_CS_19_WOD				BIT(17)
 #define PORT_CS_19_WOU4				BIT(18)
 #define PORT_CS_19_START_ASYM			BIT(24)
+#define PORT_CS_19_ELR				BIT(31)
 
 /* Display Port adapter registers */
 #define ADP_DP_CS_0				0x00
drivers/thunderbolt/usb4.c +77 -0

89 lines not on this page · raw message

Signature · 1 line
2.45.2