Linux USB
 help / color / mirror / Atom feed
* [PATCH 0/8] thunderbolt: Make the driver follow CM guide more closely
@ 2026-05-12 12:29 Mika Westerberg
  2026-05-12 12:29 ` [PATCH 1/8] thunderbolt: Improve multi-display DisplayPort tunnel allocation Mika Westerberg
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Mika Westerberg @ 2026-05-12 12:29 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Lukas Wunner, Andreas Noever, Alan Borzeszkowski,
	Pooja Katiyar, Rene Sapiens, Gil Fine, Mika Westerberg

Hi all,

This series includes various improvements to make the Thunderbolt/USB4
driver follow the USB4 Connection Manager guide more closely (and hopefully
work better with wider range of USB4 devices). There is also one
improvement for DisplayPort tunneling with more than 2 tunnels when
bandwidth allocation mode is enabled.

Alan Borzeszkowski (1):
  thunderbolt: Improve multi-display DisplayPort tunnel allocation

Gil Fine (6):
  thunderbolt: Fix lane bonding log when bonding not possible
  thunderbolt: Activate path hops from source to destination
  thunderbolt: Verify PCIe adapter in detect state before tunnel setup
  thunderbolt: Verify Router Ready bit is set after router enumeration
  thunderbolt: Increase timeout for Configuration Ready bit
  thunderbolt: Increase Notification Timeout to 255 ms for USB4 routers

Pooja Katiyar (1):
  thunderbolt: Don't access path config space on Lane 1 adapters in tb_switch_reset_host()

 drivers/thunderbolt/path.c    |  6 +++---
 drivers/thunderbolt/switch.c  | 22 +++++++++++-----------
 drivers/thunderbolt/tb.c      |  3 +++
 drivers/thunderbolt/tb.h      |  1 +
 drivers/thunderbolt/tb_regs.h | 19 +++++++++++++++++--
 drivers/thunderbolt/tunnel.c  | 35 +++++++++++++++++++++++++++++++++++
 drivers/thunderbolt/usb4.c    | 35 ++++++++++++++++++++++++++++++++---
 7 files changed, 102 insertions(+), 19 deletions(-)

-- 
2.50.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/8] thunderbolt: Improve multi-display DisplayPort tunnel allocation
  2026-05-12 12:29 [PATCH 0/8] thunderbolt: Make the driver follow CM guide more closely Mika Westerberg
@ 2026-05-12 12:29 ` Mika Westerberg
  2026-05-12 12:29 ` [PATCH 2/8] thunderbolt: Don't access path config space on Lane 1 adapters in tb_switch_reset_host() Mika Westerberg
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mika Westerberg @ 2026-05-12 12:29 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Lukas Wunner, Andreas Noever, Alan Borzeszkowski,
	Pooja Katiyar, Rene Sapiens, Gil Fine, Mika Westerberg

From: Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com>

When 3 monitors are connected through Thunderbolt dock to the system at
once, one of the monitors might fail to establish DisplayPort tunnel.
This happens during DP bandwidth negotiation - each monitor takes
maximum bandwidth that is supported and there might not be enough for
3rd display. In this case Thunderbolt driver drops DP tunnel and
'forgets' about it but with DP bandwidth allocation mode, that comes in
later, some bandwidth might be freed.

Make Thunderbolt driver check again if DP tunnel can be established
after DP bandwidth consumption changed.

Signed-off-by: Alan Borzeszkowski <alan.borzeszkowski@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/tb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index a9d26a2ec259..72a0dd27937e 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -2849,6 +2849,9 @@ static void tb_handle_dp_bandwidth_request(struct work_struct *work)
 
 		/* Update other clients about the allocation change */
 		tb_recalc_estimated_bandwidth(tb);
+
+		tb_dbg(tb, "checking if more DP tunnels can be established now\n");
+		tb_tunnel_dp(tb);
 	}
 
 put_sw:
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/8] thunderbolt: Don't access path config space on Lane 1 adapters in tb_switch_reset_host()
  2026-05-12 12:29 [PATCH 0/8] thunderbolt: Make the driver follow CM guide more closely Mika Westerberg
  2026-05-12 12:29 ` [PATCH 1/8] thunderbolt: Improve multi-display DisplayPort tunnel allocation Mika Westerberg
@ 2026-05-12 12:29 ` Mika Westerberg
  2026-05-12 12:29 ` [PATCH 3/8] thunderbolt: Fix lane bonding log when bonding not possible Mika Westerberg
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mika Westerberg @ 2026-05-12 12:29 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Lukas Wunner, Andreas Noever, Alan Borzeszkowski,
	Pooja Katiyar, Rene Sapiens, Gil Fine, Mika Westerberg

From: Pooja Katiyar <pooja.katiyar@intel.com>

USB4 Lane 1 adapters do not have accessible path config space. Skip the
path config space cleanup in tb_switch_reset_host() for these ports. The
check is for USB4 switches only. Thunderbolt 1-3 Lane 1 adapters stay as
is because we do need to program their path config space.

Co-developed-by: Rene Sapiens <rene.sapiens@linux.intel.com>
Signed-off-by: Rene Sapiens <rene.sapiens@linux.intel.com>
Signed-off-by: Pooja Katiyar <pooja.katiyar@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/switch.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index bfcab98faf4b..ad0ec8f8ee28 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -1620,6 +1620,12 @@ static int tb_switch_reset_host(struct tb_switch *sw)
 				ret = tb_port_reset(port);
 				if (ret)
 					return ret;
+				/*
+				 * USB4 Lane 1 adapters do not have accessible
+				 * path config space.
+				 */
+				if (tb_switch_is_usb4(sw) && !port->usb4)
+					continue;
 			} else if (tb_port_is_usb3_down(port) ||
 				   tb_port_is_usb3_up(port)) {
 				tb_usb3_port_enable(port, false);
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/8] thunderbolt: Fix lane bonding log when bonding not possible
  2026-05-12 12:29 [PATCH 0/8] thunderbolt: Make the driver follow CM guide more closely Mika Westerberg
  2026-05-12 12:29 ` [PATCH 1/8] thunderbolt: Improve multi-display DisplayPort tunnel allocation Mika Westerberg
  2026-05-12 12:29 ` [PATCH 2/8] thunderbolt: Don't access path config space on Lane 1 adapters in tb_switch_reset_host() Mika Westerberg
@ 2026-05-12 12:29 ` Mika Westerberg
  2026-05-12 12:29 ` [PATCH 4/8] thunderbolt: Activate path hops from source to destination Mika Westerberg
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mika Westerberg @ 2026-05-12 12:29 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Lukas Wunner, Andreas Noever, Alan Borzeszkowski,
	Pooja Katiyar, Rene Sapiens, Gil Fine, Mika Westerberg

From: Gil Fine <gil.fine@linux.intel.com>

Currently if lane bonding is not possible or not supported, we continue
and read the updated number of Total Buffers from lane adapters unnecessarily
and incorrectly log the bonding as successful.

Fix this by bailing out early when bonding is not possible, avoiding
the unnecessary read and the misleading log message.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/switch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index ad0ec8f8ee28..f421997c298d 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -2977,14 +2977,14 @@ static int tb_switch_lane_bonding_enable(struct tb_switch *sw)
 	int ret;
 
 	if (!tb_switch_lane_bonding_possible(sw))
-		return 0;
+		return -EOPNOTSUPP;
 
 	up = tb_upstream_port(sw);
 	down = tb_switch_downstream_port(sw);
 
 	if (!tb_port_width_supported(up, TB_LINK_WIDTH_DUAL) ||
 	    !tb_port_width_supported(down, TB_LINK_WIDTH_DUAL))
-		return 0;
+		return -EOPNOTSUPP;
 
 	/*
 	 * Both lanes need to be in CL0. Here we assume lane 0 already be in
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/8] thunderbolt: Activate path hops from source to destination
  2026-05-12 12:29 [PATCH 0/8] thunderbolt: Make the driver follow CM guide more closely Mika Westerberg
                   ` (2 preceding siblings ...)
  2026-05-12 12:29 ` [PATCH 3/8] thunderbolt: Fix lane bonding log when bonding not possible Mika Westerberg
@ 2026-05-12 12:29 ` Mika Westerberg
  2026-05-12 12:29 ` [PATCH 5/8] thunderbolt: Verify PCIe adapter in detect state before tunnel setup Mika Westerberg
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mika Westerberg @ 2026-05-12 12:29 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Lukas Wunner, Andreas Noever, Alan Borzeszkowski,
	Pooja Katiyar, Rene Sapiens, Gil Fine, Mika Westerberg

From: Gil Fine <gil.fine@linux.intel.com>

Currently, path activation starts from the last hop (destination adapter)
and iterates backwards to the first hop (source adapter). This does not
follow the order suggested in the USB4 Connection Manager guide and could
potentially cause issues with tunnelled protocols.

Reverse the activation order to start from the first hop (source adapter)
and end at the last hop (destination adapter), as suggested in the
Connection Manager guide.
Adjust the rollback in the failure path to deactivate from the first
hop, since hops are now activated starting at the source.

Fix kernel-doc accordingly.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/path.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/thunderbolt/path.c b/drivers/thunderbolt/path.c
index 0092b2ec7873..b2c322e76b8a 100644
--- a/drivers/thunderbolt/path.c
+++ b/drivers/thunderbolt/path.c
@@ -484,7 +484,7 @@ void tb_path_deactivate(struct tb_path *path)
  * tb_path_activate() - activate a path
  * @path: Path to activate
  *
- * Activate a path starting with the last hop and iterating backwards. The
+ * Activate a path starting with the first hop and ending on the last hop. The
  * caller must fill path->hops before calling tb_path_activate().
  *
  * Return: %0 on success, negative errno otherwise.
@@ -526,7 +526,7 @@ int tb_path_activate(struct tb_path *path)
 	}
 
 	/* Activate hops. */
-	for (i = path->path_length - 1; i >= 0; i--) {
+	for (i = 0; i < path->path_length; i++) {
 		struct tb_regs_hop hop = { 0 };
 
 		/* If it is left active deactivate it first */
@@ -576,7 +576,7 @@ int tb_path_activate(struct tb_path *path)
 		res = tb_port_write(path->hops[i].in_port, &hop, TB_CFG_HOPS,
 				    2 * path->hops[i].in_hop_index, 2);
 		if (res) {
-			__tb_path_deactivate_hops(path, i);
+			__tb_path_deactivate_hops(path, 0);
 			__tb_path_deallocate_nfc(path, 0);
 			goto err;
 		}
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 5/8] thunderbolt: Verify PCIe adapter in detect state before tunnel setup
  2026-05-12 12:29 [PATCH 0/8] thunderbolt: Make the driver follow CM guide more closely Mika Westerberg
                   ` (3 preceding siblings ...)
  2026-05-12 12:29 ` [PATCH 4/8] thunderbolt: Activate path hops from source to destination Mika Westerberg
@ 2026-05-12 12:29 ` Mika Westerberg
  2026-05-12 12:29 ` [PATCH 6/8] thunderbolt: Verify Router Ready bit is set after router enumeration Mika Westerberg
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mika Westerberg @ 2026-05-12 12:29 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Lukas Wunner, Andreas Noever, Alan Borzeszkowski,
	Pooja Katiyar, Rene Sapiens, Gil Fine, Mika Westerberg

From: Gil Fine <gil.fine@linux.intel.com>

The USB4 Connection Manager guide suggests that a PCIe downstream and
PCIe upstream adapters of the USB4 router is in the Detect state before
setting up a PCIe tunnel.

Add this check by verifying the LTSSM field in ADP_PCIE_CS_0 before
tunnel setup.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/tb.h      |  1 +
 drivers/thunderbolt/tb_regs.h | 15 +++++++++++++++
 drivers/thunderbolt/tunnel.c  | 35 +++++++++++++++++++++++++++++++++++
 drivers/thunderbolt/usb4.c    | 24 ++++++++++++++++++++++++
 4 files changed, 75 insertions(+)

diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h
index 229b9e7961fb..d86919474fdb 100644
--- a/drivers/thunderbolt/tb.h
+++ b/drivers/thunderbolt/tb.h
@@ -1481,6 +1481,7 @@ int usb4_dp_port_allocate_bandwidth(struct tb_port *port, int bw);
 int usb4_dp_port_requested_bandwidth(struct tb_port *port);
 
 int usb4_pci_port_set_ext_encapsulation(struct tb_port *port, bool enable);
+int usb4_pci_port_ltssm_state(struct tb_port *port);
 
 static inline bool tb_is_usb4_port_device(const struct device *dev)
 {
diff --git a/drivers/thunderbolt/tb_regs.h b/drivers/thunderbolt/tb_regs.h
index c0bf136236e6..75131fcfe044 100644
--- a/drivers/thunderbolt/tb_regs.h
+++ b/drivers/thunderbolt/tb_regs.h
@@ -473,10 +473,25 @@ struct tb_regs_port_header {
 
 /* PCIe adapter registers */
 #define ADP_PCIE_CS_0				0x00
+#define ADP_PCIE_CS_0_LTSSM_MASK		GENMASK(28, 25)
 #define ADP_PCIE_CS_0_PE			BIT(31)
 #define ADP_PCIE_CS_1				0x01
 #define ADP_PCIE_CS_1_EE			BIT(0)
 
+enum tb_pcie_ltssm_state {
+	USB4_PCIE_LTSSM_DETECT,
+	USB4_PCIE_LTSSM_POLLING,
+	USB4_PCIE_LTSSM_CONFIG,
+	USB4_PCIE_LTSSM_CONFIG_IDLE,
+	USB4_PCIE_LTSSM_RECOVERY,
+	USB4_PCIE_LTSSM_RECOVERY_IDLE,
+	USB4_PCIE_LTSSM_L0,
+	USB4_PCIE_LTSSM_L1,
+	USB4_PCIE_LTSSM_L2,
+	USB4_PCIE_LTSSM_DISABLED,
+	USB4_PCIE_LTSSM_HOT_RESET,
+};
+
 /* USB adapter registers */
 #define ADP_USB3_CS_0				0x00
 #define ADP_USB3_CS_0_V				BIT(30)
diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c
index f38f7753b6e4..b7f32305f14a 100644
--- a/drivers/thunderbolt/tunnel.c
+++ b/drivers/thunderbolt/tunnel.c
@@ -290,6 +290,40 @@ static inline void tb_tunnel_changed(struct tb_tunnel *tunnel)
 			tunnel->src_port, tunnel->dst_port);
 }
 
+static int tb_pci_port_ltssm_state_detect(struct tb_port *port)
+{
+	ktime_t timeout = ktime_add_ms(ktime_get(), 500);
+
+	do {
+		int ret;
+
+		ret = usb4_pci_port_ltssm_state(port);
+		if (ret < 0)
+			return ret;
+		if (ret == USB4_PCIE_LTSSM_DETECT)
+			return 0;
+
+		fsleep(50);
+	} while (ktime_before(ktime_get(), timeout));
+
+	return -ETIMEDOUT;
+}
+
+static int tb_pci_pre_activate(struct tb_tunnel *tunnel)
+{
+	struct tb_port *down = tunnel->src_port;
+	struct tb_port *up = tunnel->dst_port;
+	int ret;
+
+	ret = tb_switch_is_usb4(down->sw) ?
+		tb_pci_port_ltssm_state_detect(down) : 0;
+	if (ret)
+		return ret;
+
+	return tb_switch_is_usb4(up->sw) ?
+		tb_pci_port_ltssm_state_detect(up) : 0;
+}
+
 static int tb_pci_set_ext_encapsulation(struct tb_tunnel *tunnel, bool enable)
 {
 	struct tb_port *port = tb_upstream_port(tunnel->dst_port->sw);
@@ -505,6 +539,7 @@ struct tb_tunnel *tb_tunnel_alloc_pci(struct tb *tb, struct tb_port *up,
 	if (!tunnel)
 		return NULL;
 
+	tunnel->pre_activate = tb_pci_pre_activate;
 	tunnel->activate = tb_pci_activate;
 	tunnel->src_port = down;
 	tunnel->dst_port = up;
diff --git a/drivers/thunderbolt/usb4.c b/drivers/thunderbolt/usb4.c
index 9e810b2ae0b5..6f76bcaefa49 100644
--- a/drivers/thunderbolt/usb4.c
+++ b/drivers/thunderbolt/usb4.c
@@ -3145,3 +3145,27 @@ int usb4_pci_port_set_ext_encapsulation(struct tb_port *port, bool enable)
 	return tb_port_write(port, &val, TB_CFG_PORT,
 			     port->cap_adap + ADP_PCIE_CS_1, 1);
 }
+
+/**
+ * usb4_pci_port_ltssm_state() - Read PCIe adapter LTSSM state
+ * @port: PCIe adapter
+ *
+ * Return:
+ * * LTSSM state of @port.
+ * * Negative errno - On failure.
+ */
+int usb4_pci_port_ltssm_state(struct tb_port *port)
+{
+	u32 val;
+	int ret;
+
+	if (!tb_port_is_pcie_down(port) && !tb_port_is_pcie_up(port))
+		return -EINVAL;
+
+	ret = tb_port_read(port, &val, TB_CFG_PORT,
+			   port->cap_adap + ADP_PCIE_CS_0, 1);
+	if (ret)
+		return ret;
+
+	return FIELD_GET(ADP_PCIE_CS_0_LTSSM_MASK, val);
+}
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 6/8] thunderbolt: Verify Router Ready bit is set after router enumeration
  2026-05-12 12:29 [PATCH 0/8] thunderbolt: Make the driver follow CM guide more closely Mika Westerberg
                   ` (4 preceding siblings ...)
  2026-05-12 12:29 ` [PATCH 5/8] thunderbolt: Verify PCIe adapter in detect state before tunnel setup Mika Westerberg
@ 2026-05-12 12:29 ` Mika Westerberg
  2026-05-12 12:29 ` [PATCH 7/8] thunderbolt: Increase timeout for Configuration Ready bit Mika Westerberg
  2026-05-12 12:29 ` [PATCH 8/8] thunderbolt: Increase Notification Timeout to 255 ms for USB4 routers Mika Westerberg
  7 siblings, 0 replies; 9+ messages in thread
From: Mika Westerberg @ 2026-05-12 12:29 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Lukas Wunner, Andreas Noever, Alan Borzeszkowski,
	Pooja Katiyar, Rene Sapiens, Gil Fine, Mika Westerberg

From: Gil Fine <gil.fine@linux.intel.com>

The USB4 Connection Manager guide specifies that after enumerating a
router, the Connection Manager shall verify that the Router Ready bit
(ROUTER_CS_6.RR) has been set to ensure hardware configuration has completed.
Currently, this step is missing from the enumeration sequence.

Add this check to follow the Connection Manager guide more closely.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/tb_regs.h | 1 +
 drivers/thunderbolt/usb4.c    | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/thunderbolt/tb_regs.h b/drivers/thunderbolt/tb_regs.h
index 75131fcfe044..69ca4c379cc9 100644
--- a/drivers/thunderbolt/tb_regs.h
+++ b/drivers/thunderbolt/tb_regs.h
@@ -216,6 +216,7 @@ struct tb_regs_switch_header {
 #define ROUTER_CS_6_WOPS			BIT(2)
 #define ROUTER_CS_6_WOUS			BIT(3)
 #define ROUTER_CS_6_HCI				BIT(18)
+#define ROUTER_CS_6_RR				BIT(24)
 #define ROUTER_CS_6_CR				BIT(25)
 #define ROUTER_CS_7				0x07
 #define ROUTER_CS_9				0x09
diff --git a/drivers/thunderbolt/usb4.c b/drivers/thunderbolt/usb4.c
index 6f76bcaefa49..54f4f5fa3c5a 100644
--- a/drivers/thunderbolt/usb4.c
+++ b/drivers/thunderbolt/usb4.c
@@ -294,7 +294,12 @@ int usb4_switch_setup(struct tb_switch *sw)
 	/* TBT3 supported by the CM */
 	val &= ~ROUTER_CS_5_CNS;
 
-	return tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1);
+	ret = tb_sw_write(sw, &val, TB_CFG_SWITCH, ROUTER_CS_5, 1);
+	if (ret)
+		return ret;
+
+	return tb_switch_wait_for_bit(sw, ROUTER_CS_6, ROUTER_CS_6_RR,
+				      ROUTER_CS_6_RR, 500);
 }
 
 /**
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 7/8] thunderbolt: Increase timeout for Configuration Ready bit
  2026-05-12 12:29 [PATCH 0/8] thunderbolt: Make the driver follow CM guide more closely Mika Westerberg
                   ` (5 preceding siblings ...)
  2026-05-12 12:29 ` [PATCH 6/8] thunderbolt: Verify Router Ready bit is set after router enumeration Mika Westerberg
@ 2026-05-12 12:29 ` Mika Westerberg
  2026-05-12 12:29 ` [PATCH 8/8] thunderbolt: Increase Notification Timeout to 255 ms for USB4 routers Mika Westerberg
  7 siblings, 0 replies; 9+ messages in thread
From: Mika Westerberg @ 2026-05-12 12:29 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Lukas Wunner, Andreas Noever, Alan Borzeszkowski,
	Pooja Katiyar, Rene Sapiens, Gil Fine, Mika Westerberg

From: Gil Fine <gil.fine@linux.intel.com>

After setting the Configuration Valid bit (ROUTER_CS_5.CV), the USB4
Connection Manager guide specifies a 500 ms timeout for the router to
set the Configuration Ready bit (ROUTER_CS_6.CR). The current timeout
is shorter than specified. While there, fix the kernel-doc typo.

Increase the timeout to match the CM guide recommendation.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/usb4.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/thunderbolt/usb4.c b/drivers/thunderbolt/usb4.c
index 54f4f5fa3c5a..5fd4fe070f25 100644
--- a/drivers/thunderbolt/usb4.c
+++ b/drivers/thunderbolt/usb4.c
@@ -309,7 +309,7 @@ int usb4_switch_setup(struct tb_switch *sw)
  * Sets configuration valid bit for the router. Must be called before
  * any tunnels can be set through the router and after
  * usb4_switch_setup() has been called. Can be called to host and device
- * routers (does nothing for the latter).
+ * routers (does nothing for the former).
  *
  * Return: %0 on success, negative errno otherwise.
  */
@@ -332,7 +332,7 @@ int usb4_switch_configuration_valid(struct tb_switch *sw)
 		return ret;
 
 	return tb_switch_wait_for_bit(sw, ROUTER_CS_6, ROUTER_CS_6_CR,
-				      ROUTER_CS_6_CR, 50);
+				      ROUTER_CS_6_CR, 500);
 }
 
 /**
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 8/8] thunderbolt: Increase Notification Timeout to 255 ms for USB4 routers
  2026-05-12 12:29 [PATCH 0/8] thunderbolt: Make the driver follow CM guide more closely Mika Westerberg
                   ` (6 preceding siblings ...)
  2026-05-12 12:29 ` [PATCH 7/8] thunderbolt: Increase timeout for Configuration Ready bit Mika Westerberg
@ 2026-05-12 12:29 ` Mika Westerberg
  7 siblings, 0 replies; 9+ messages in thread
From: Mika Westerberg @ 2026-05-12 12:29 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Lukas Wunner, Andreas Noever, Alan Borzeszkowski,
	Pooja Katiyar, Rene Sapiens, Gil Fine, Mika Westerberg

From: Gil Fine <gil.fine@linux.intel.com>

Currently we set the Notification Timeout field in ROUTER_CS_4 for USB4
routers to 10 ms, which is unnecessarily short and may cause unnecessary
retransmissions of Hot Plug packets by the router in case of slow
software response.
Increase the timeout to 255 ms, aligning with Thunderbolt 3 routers
and providing adequate time for software to process Hot Plug Events.

While there, fix the comment describing the Notification Timeout
field to match the USB4 specification.

Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/switch.c  | 12 +++---------
 drivers/thunderbolt/tb_regs.h |  3 +--
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c
index f421997c298d..d7c53eb3221b 100644
--- a/drivers/thunderbolt/switch.c
+++ b/drivers/thunderbolt/switch.c
@@ -1767,8 +1767,6 @@ int tb_switch_wait_for_bit(struct tb_switch *sw, u32 offset, u32 bit,
 /*
  * tb_plug_events_active() - enable/disable plug events on a switch
  *
- * Also configures a sane plug_events_delay of 255ms.
- *
  * Return: %0 on success, negative errno otherwise.
  */
 static int tb_plug_events_active(struct tb_switch *sw, bool active)
@@ -1779,11 +1777,6 @@ static int tb_plug_events_active(struct tb_switch *sw, bool active)
 	if (tb_switch_is_icm(sw) || tb_switch_is_usb4(sw))
 		return 0;
 
-	sw->config.plug_events_delay = 0xff;
-	res = tb_sw_write(sw, ((u32 *) &sw->config) + 4, TB_CFG_SWITCH, 4, 1);
-	if (res)
-		return res;
-
 	res = tb_sw_read(sw, &data, TB_CFG_SWITCH, sw->cap_plug_events + 1, 1);
 	if (res)
 		return res;
@@ -2645,6 +2638,8 @@ int tb_switch_configure(struct tb_switch *sw)
 
 	sw->config.enabled = 1;
 
+	/* Set Notification Timeout to 255 ms for all routers */
+	sw->config.plug_events_delay = 0xff;
 	if (tb_switch_is_usb4(sw)) {
 		/*
 		 * For USB4 devices, we need to program the CM version
@@ -2656,7 +2651,6 @@ int tb_switch_configure(struct tb_switch *sw)
 			sw->config.cmuv = ROUTER_CS_4_CMUV_V1;
 		else
 			sw->config.cmuv = ROUTER_CS_4_CMUV_V2;
-		sw->config.plug_events_delay = 0xa;
 
 		/* Enumerate the switch */
 		ret = tb_sw_write(sw, (u32 *)&sw->config + 1, TB_CFG_SWITCH,
@@ -2677,7 +2671,7 @@ int tb_switch_configure(struct tb_switch *sw)
 
 		/* Enumerate the switch */
 		ret = tb_sw_write(sw, (u32 *)&sw->config + 1, TB_CFG_SWITCH,
-				  ROUTER_CS_1, 3);
+				  ROUTER_CS_1, 4);
 	}
 	if (ret)
 		return ret;
diff --git a/drivers/thunderbolt/tb_regs.h b/drivers/thunderbolt/tb_regs.h
index 69ca4c379cc9..92d893634d2b 100644
--- a/drivers/thunderbolt/tb_regs.h
+++ b/drivers/thunderbolt/tb_regs.h
@@ -182,8 +182,7 @@ struct tb_regs_switch_header {
 	/* DWORD 4 */
 	u32 plug_events_delay:8; /*
 				  * RW, pause between plug events in
-				  * milliseconds. Writing 0x00 is interpreted
-				  * as 255ms.
+				  * milliseconds.
 				  */
 	u32 cmuv:8;
 	u32 __unknown4:8;
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-05-12 12:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-12 12:29 [PATCH 0/8] thunderbolt: Make the driver follow CM guide more closely Mika Westerberg
2026-05-12 12:29 ` [PATCH 1/8] thunderbolt: Improve multi-display DisplayPort tunnel allocation Mika Westerberg
2026-05-12 12:29 ` [PATCH 2/8] thunderbolt: Don't access path config space on Lane 1 adapters in tb_switch_reset_host() Mika Westerberg
2026-05-12 12:29 ` [PATCH 3/8] thunderbolt: Fix lane bonding log when bonding not possible Mika Westerberg
2026-05-12 12:29 ` [PATCH 4/8] thunderbolt: Activate path hops from source to destination Mika Westerberg
2026-05-12 12:29 ` [PATCH 5/8] thunderbolt: Verify PCIe adapter in detect state before tunnel setup Mika Westerberg
2026-05-12 12:29 ` [PATCH 6/8] thunderbolt: Verify Router Ready bit is set after router enumeration Mika Westerberg
2026-05-12 12:29 ` [PATCH 7/8] thunderbolt: Increase timeout for Configuration Ready bit Mika Westerberg
2026-05-12 12:29 ` [PATCH 8/8] thunderbolt: Increase Notification Timeout to 255 ms for USB4 routers Mika Westerberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox