Merge branch 'net-thunderbolt-two-fixes-for-the-failed-bring-up-path'

Fan Ye says:

====================
net: thunderbolt: two fixes for the failed bring-up path

Two separate defects reached through the same branch in
tbnet_connected_work(), found on an ASMedia ASM4242 host-to-host link
when the peer drops out while a connection is being brought up.

  1 releases the HopID the allocator handed out when it is not the one
    that was asked for.  Today it stays allocated for the rest of the
    XDomain connection.

  2 marks the connection down on the failure paths, so the next
    tbnet_tear_down() does not run a second teardown over work that was
    already undone: stopping rings that are already stopped, which is
    fatal under panic_on_warn, and handing back a HopID this connection
    never owned.

Patch 2 edits the lines patch 1 adds, so it has to come second.
====================

Link: https://patch.msgid.link/20260811-b4-tbnet-hopid-v3-0-9e75d1b51331@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Jakub Kicinski 2026-08-17 11:15:15 -07:00
commit 603fa1f50a

View File

@ -626,6 +626,14 @@ static int tbnet_alloc_tx_buffers(struct tbnet *net)
return 0;
}
static void tbnet_connect_failed(struct tbnet *net)
{
/* Leave login_received set: only the peer can make it true again. */
mutex_lock(&net->connection_lock);
net->login_sent = false;
mutex_unlock(&net->connection_lock);
}
static void tbnet_connected_work(struct work_struct *work)
{
struct tbnet *net = container_of(work, typeof(*net), connected_work);
@ -647,6 +655,9 @@ static void tbnet_connected_work(struct work_struct *work)
ret = tb_xdomain_alloc_in_hopid(net->xd, net->remote_transmit_path);
if (ret != net->remote_transmit_path) {
netdev_err(net->dev, "failed to allocate Rx HopID\n");
if (ret >= 0)
tb_xdomain_release_in_hopid(net->xd, ret);
tbnet_connect_failed(net);
return;
}
@ -691,6 +702,7 @@ static void tbnet_connected_work(struct work_struct *work)
tb_ring_stop(net->rx_ring.ring);
tb_ring_stop(net->tx_ring.ring);
tb_xdomain_release_in_hopid(net->xd, net->remote_transmit_path);
tbnet_connect_failed(net);
}
static void tbnet_login_work(struct work_struct *work)