From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, YehezkelShB@gmail.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
pabeni@redhat.com
Subject: Re: [PATCH 2/2] net: thunderbolt: Fix lockdep issue during tunnel tear down
Date: Wed, 29 Apr 2026 06:47:01 +0200 [thread overview]
Message-ID: <20260429044701.GY557136@black.igk.intel.com> (raw)
In-Reply-To: <20260429011226.1505821-1-kuba@kernel.org>
On Tue, Apr 28, 2026 at 06:12:26PM -0700, Jakub Kicinski wrote:
> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
> ---
> net: thunderbolt: Fix lockdep issue during tunnel tear down
>
> This commit attempts to fix a circular locking dependency warning in
> tbnet_tear_down() by dropping the connection lock earlier and returning if the
> connection isn't fully established.
>
> > diff --git a/drivers/net/thunderbolt/main.c b/drivers/net/thunderbolt/main.c
> > index 631af237998d..d8fcf18fc55c 100644
> > --- a/drivers/net/thunderbolt/main.c
> > +++ b/drivers/net/thunderbolt/main.c
> [ ... ]
> > @@ -372,48 +372,47 @@ static void tbnet_free_buffers(struct tbnet_ring *ring)
> >
> > static void tbnet_tear_down(struct tbnet *net, bool send_logout)
> > {
> > + int ret, retries = TBNET_LOGOUT_RETRIES;
> > +
> > netif_carrier_off(net->dev);
> > netif_stop_queue(net->dev);
> >
> > stop_login(net);
> >
> > mutex_lock(&net->connection_lock);
> > + if (!net->login_sent || !net->login_received) {
> > + mutex_unlock(&net->connection_lock);
> > + return;
> > + }
>
> If the connection is in a partially established state (e.g. login_sent is
> true, but login_received is false), this early return skips clearing the
> connection states.
>
> Could this stall the connection if a new TBIP_LOGIN arrives later?
> tbnet_handle_packet() would see net->login_sent as true and might fail to
> queue the login_work to reply.
I don't think that matters because tbnet_tear_down() is actually tearing
down the connection so after this we do not expect the connection to be
established until start_login() is called again (this happens when the
interface is brought up again or on resume).
> > + net->login_sent = false;
> > + net->login_received = false;
> > + mutex_unlock(&net->connection_lock);
>
> By releasing net->connection_lock here, the rest of the teardown process runs
> without mutual exclusion. Since the network interface is still running, is it
> possible for tbnet_handle_packet() to receive a new TBIP_LOGIN request right
> after this lock is dropped?
>
> If tbnet_handle_packet() acquires the lock, updates net->remote_transmit_path
> and brings up a new connection concurrently:
>
> CPU1
> tbnet_tear_down()
> mutex_unlock(&net->connection_lock);
>
> CPU2
> tbnet_handle_packet()
> mutex_lock(&net->connection_lock);
> net->remote_transmit_path = pkg->transmit_path;
> mutex_unlock(&net->connection_lock);
>
> CPU1
> tb_xdomain_release_in_hopid(net->xd, net->remote_transmit_path);
>
> Would CPU1 then erroneously release the newly established connection's hopid
> and free active buffers?
Oh, this one definitely can happen.
> >
> > - if (net->login_sent && net->login_received) {
> > - int ret, retries = TBNET_LOGOUT_RETRIES;
> [ ... ]
> > - tb_xdomain_release_in_hopid(net->xd, net->remote_transmit_path);
> > - net->remote_transmit_path = 0;
> > - }
> > + tb_xdomain_release_in_hopid(net->xd, net->remote_transmit_path);
> > + net->remote_transmit_path = 0;
> >
> > - net->login_retries = 0;
>
> With the unconditional clearing of net->login_retries removed, does the
> login_retries counter keep accumulating if tbnet_tear_down() returns early
> above?
>
> If it exceeds TBNET_LOGIN_RETRIES, could it permanently prevent new
> connections until the module is reloaded?
Indeed, that's an accidental removal.
Okay let me try to figure out better fix for this lockdep issue.
next prev parent reply other threads:[~2026-04-29 4:47 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-27 8:16 [PATCH 1/2] net: thunderbolt: Call tbnet_stop() upon shutdown Mika Westerberg
2026-04-27 8:16 ` [PATCH 2/2] net: thunderbolt: Fix lockdep issue during tunnel tear down Mika Westerberg
2026-04-29 1:12 ` Jakub Kicinski
2026-04-29 1:12 ` Jakub Kicinski
2026-04-29 4:47 ` Mika Westerberg [this message]
2026-04-29 1:12 ` [PATCH 1/2] net: thunderbolt: Call tbnet_stop() upon shutdown Jakub Kicinski
2026-04-29 5:30 ` Mika Westerberg
2026-04-29 13:31 ` Andrew Lunn
2026-04-29 16:57 ` Mika Westerberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260429044701.GY557136@black.igk.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=YehezkelShB@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox