Skip to content

Commit 25d905d

Browse files
Gil Finewesteri
authored andcommitted
thunderbolt: Allow USB3 bandwidth to be lower than maximum supported
Currently USB3 tunnel setup fails if USB4 link available bandwidth is too low to allow USB3 Maximum Supported Link Rate. In reality, this limitation is not needed, and may cause failure of USB3 tunnel establishment, if USB4 link available bandwidth is lower than USB3 Maximum Supported Link Rate. E.g. if we connect to USB4 v1 host router, a USB4 v1 device router, via 10 Gb/s cable. Hence, here we discard this limitation, and now we only limit USB3 bandwidth allocation to be not higher than 90% of USB3 Max Supported Link Rate (for first USB3 tunnel only). Signed-off-by: Gil Fine <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
1 parent 6016137 commit 25d905d

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

drivers/thunderbolt/tunnel.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,26 +2064,21 @@ struct tb_tunnel *tb_tunnel_alloc_usb3(struct tb *tb, struct tb_port *up,
20642064
{
20652065
struct tb_tunnel *tunnel;
20662066
struct tb_path *path;
2067-
int max_rate = 0;
2067+
int max_rate;
20682068

2069-
/*
2070-
* Check that we have enough bandwidth available for the new
2071-
* USB3 tunnel.
2072-
*/
2073-
if (max_up > 0 || max_down > 0) {
2069+
if (!tb_route(down->sw) && (max_up > 0 || max_down > 0)) {
2070+
/*
2071+
* For USB3 isochronous transfers, we allow bandwidth which is
2072+
* not higher than 90% of maximum supported bandwidth by USB3
2073+
* adapters.
2074+
*/
20742075
max_rate = tb_usb3_max_link_rate(down, up);
20752076
if (max_rate < 0)
20762077
return NULL;
20772078

2078-
/* Only 90% can be allocated for USB3 isochronous transfers */
20792079
max_rate = max_rate * 90 / 100;
2080-
tb_port_dbg(up, "required bandwidth for USB3 tunnel %d Mb/s\n",
2080+
tb_port_dbg(up, "maximum required bandwidth for USB3 tunnel %d Mb/s\n",
20812081
max_rate);
2082-
2083-
if (max_rate > max_up || max_rate > max_down) {
2084-
tb_port_warn(up, "not enough bandwidth for USB3 tunnel\n");
2085-
return NULL;
2086-
}
20872082
}
20882083

20892084
tunnel = tb_tunnel_alloc(tb, 2, TB_TUNNEL_USB3);
@@ -2115,8 +2110,8 @@ struct tb_tunnel *tb_tunnel_alloc_usb3(struct tb *tb, struct tb_port *up,
21152110
tunnel->paths[TB_USB3_PATH_UP] = path;
21162111

21172112
if (!tb_route(down->sw)) {
2118-
tunnel->allocated_up = max_rate;
2119-
tunnel->allocated_down = max_rate;
2113+
tunnel->allocated_up = min(max_rate, max_up);
2114+
tunnel->allocated_down = min(max_rate, max_down);
21202115

21212116
tunnel->init = tb_usb3_init;
21222117
tunnel->consumed_bandwidth = tb_usb3_consumed_bandwidth;

0 commit comments

Comments
 (0)