]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
thunderbolt: Activate path hops from source to destination
authorGil Fine <gil.fine@linux.intel.com>
Wed, 6 May 2026 12:37:05 +0000 (15:37 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Wed, 20 May 2026 09:54:34 +0000 (11:54 +0200)
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

index 0092b2ec7873f4812b047748efe000beaf6efe23..b2c322e76b8ad76ae1ef5396d73003b6a450193f 100644 (file)
@@ -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;
                }