Skip to content

Commit 6016137

Browse files
Gil Finewesteri
authored andcommitted
thunderbolt: Fix calculation of consumed USB3 bandwidth on a path
Currently, when setup a new USB3 tunnel that is starting from downstream USB3 adapter of first depth router (or deeper), to upstream USB3 adapter of a second depth router (or deeper), we calculate consumed bandwidth. For this calculation we take into account first USB3 tunnel consumed bandwidth while we shouldn't, because we just recalculating the first USB3 tunnel allocated bandwidth. Fix that, so that more bandwidth is available for the new USB3 tunnel being setup. While there, fix the kernel-doc to decribe more accurately the purpose of the function. Signed-off-by: Gil Fine <[email protected]> Signed-off-by: Mika Westerberg <[email protected]>
1 parent 9a96651 commit 6016137

File tree

1 file changed

+5
-4
lines changed
  • drivers/thunderbolt

1 file changed

+5
-4
lines changed

drivers/thunderbolt/tb.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,9 @@ static struct tb_tunnel *tb_find_first_usb3_tunnel(struct tb *tb,
498498
* @consumed_down: Consumed downstream bandwidth (Mb/s)
499499
*
500500
* Calculates consumed USB3 and PCIe bandwidth at @port between path
501-
* from @src_port to @dst_port. Does not take tunnel starting from
502-
* @src_port and ending from @src_port into account.
501+
* from @src_port to @dst_port. Does not take USB3 tunnel starting from
502+
* @src_port and ending on @src_port into account because that bandwidth is
503+
* already included in as part of the "first hop" USB3 tunnel.
503504
*/
504505
static int tb_consumed_usb3_pcie_bandwidth(struct tb *tb,
505506
struct tb_port *src_port,
@@ -514,8 +515,8 @@ static int tb_consumed_usb3_pcie_bandwidth(struct tb *tb,
514515
*consumed_up = *consumed_down = 0;
515516

516517
tunnel = tb_find_first_usb3_tunnel(tb, src_port, dst_port);
517-
if (tunnel && tunnel->src_port != src_port &&
518-
tunnel->dst_port != dst_port) {
518+
if (tunnel && !tb_port_is_usb3_down(src_port) &&
519+
!tb_port_is_usb3_up(dst_port)) {
519520
int ret;
520521

521522
ret = tb_tunnel_consumed_bandwidth(tunnel, consumed_up,

0 commit comments

Comments
 (0)