diff options
author | Gil Fine <gil.fine@linux.intel.com> | 2023-11-15 11:09:57 +0100 |
---|---|---|
committer | Mika Westerberg <mika.westerberg@linux.intel.com> | 2023-12-14 07:07:45 +0100 |
commit | 2b3a6239d286d6b74295ccf21905ba6533bcf3a9 (patch) | |
tree | 041092c2dd62ccb9147b228df6d7d557c488c12f /drivers/thunderbolt/tunnel.c | |
parent | thunderbolt: Make PCIe tunnel setup and teardown follow CM guide (diff) | |
download | linux-2b3a6239d286d6b74295ccf21905ba6533bcf3a9.tar.xz linux-2b3a6239d286d6b74295ccf21905ba6533bcf3a9.zip |
thunderbolt: Disable PCIe extended encapsulation upon teardown properly
In case of PCIe tunnel teardown (including if caused by router unplug),
PCIe extended encapsulation bit should be cleared in downstream and
upstream routers accordingly.
Signed-off-by: Gil Fine <gil.fine@linux.intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/thunderbolt/tunnel.c')
-rw-r--r-- | drivers/thunderbolt/tunnel.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c index b0c3c8373775..6fffb2c82d3d 100644 --- a/drivers/thunderbolt/tunnel.c +++ b/drivers/thunderbolt/tunnel.c @@ -173,16 +173,28 @@ static int tb_pci_set_ext_encapsulation(struct tb_tunnel *tunnel, bool enable) int ret; /* Only supported of both routers are at least USB4 v2 */ - if (tb_port_get_link_generation(port) < 4) + if ((usb4_switch_version(tunnel->src_port->sw) < 2) || + (usb4_switch_version(tunnel->dst_port->sw) < 2)) + return 0; + + if (enable && tb_port_get_link_generation(port) < 4) return 0; ret = usb4_pci_port_set_ext_encapsulation(tunnel->src_port, enable); if (ret) return ret; + /* + * Downstream router could be unplugged so disable of encapsulation + * in upstream router is still possible. + */ ret = usb4_pci_port_set_ext_encapsulation(tunnel->dst_port, enable); - if (ret) - return ret; + if (ret) { + if (enable) + return ret; + if (ret != -ENODEV) + return ret; + } tb_tunnel_dbg(tunnel, "extended encapsulation %s\n", str_enabled_disabled(enable)); |