Re: [PATCH v4] thunderbolt: Fix tb->lock deadlock during hot-unplug on AMD USB4 routers
From: Mika Westerberg
Date: Mon Aug 31 2026 - 09:09:01 EST
Hi,
On Mon, Aug 31, 2026 at 07:55:16AM -0500, Mario Limonciello wrote:
> > > +static void tb_domain_reset_interface(struct tb *tb)
> > > +{
> > > + guard(mutex)(&tb->lock);
> > > + __tb_domain_reset_interface_locked(tb);
> > > +}
> > > +
> > > /**
> > > * tb_domain_disconnect_xdomain_paths() - Disable DMA paths for XDomain
> > > * @tb: Domain disabling the DMA paths
> > > @@ -835,7 +849,7 @@ int tb_domain_disconnect_xdomain_paths(struct tb *tb, struct tb_xdomain *xd,
> > > if (ret)
> > > return ret;
> > > - if (tb->nhi->quirks & QUIRK_RESET_DMA_ON_TEARDOWN)
> > > + if (!xd->is_unplugged)
> >
> > If I read this right, if you unplug a tree (say a router and then after
> > that router there is inter-domain link) with this check the reset does not
> > happen and AMD system still hangs?
> >
>
> It should be a different problem. The quirk fixed a problem in the USB4
> router (router wasn't functional when problem occurred).
>
> This fixes a deadlock in the kernel that system gets stuck while shutting
> down.
Right, but now since this checks !xd->is_unplugged and only then does the
reset, if you unplug the whole chain including the XDomain connection (i.e.
the unplug happens say on host router downstream port) then we mark
everything below that with is_unplugged=1 so now this function will skip
the quirk and the DMA will get stuck, no?
Because..
>
> > > tb_domain_reset_interface(tb);
> > > return 0;
> > > diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
> > > index b7cc6894a598..89dfb3381345 100644
> > > --- a/drivers/thunderbolt/tb.c
> > > +++ b/drivers/thunderbolt/tb.c
> > > @@ -2489,6 +2489,7 @@ static void tb_handle_hotplug(struct work_struct *work)
> > > tb_xdomain_remove(xd);
> > > port->xdomain = NULL;
> > > __tb_disconnect_xdomain_paths(tb, xd, -1, -1, -1, -1);
> > > + __tb_domain_reset_interface_locked(tb);
... this is not called when the unplug happens elsewhere (like before the
XDomain link).