]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
thunderbolt: Increase Notification Timeout to 255 ms for USB4 routers
authorGil Fine <gil.fine@linux.intel.com>
Wed, 6 May 2026 12:37:09 +0000 (15:37 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Wed, 20 May 2026 09:54:35 +0000 (11:54 +0200)
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
drivers/thunderbolt/tb_regs.h

index f421997c298db5e7f500cc9d7266d377757f0417..d7c53eb3221b0577d53dbc1986909ff3898dc6ab 100644 (file)
@@ -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;
index 69ca4c379cc9d152915a6c892b45bd45ec0f8b69..92d893634d2bc66b365b29ed42a8248659617b82 100644 (file)
@@ -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;