From: sashiko-bot@kernel.org
To: "Basavaraj Natikar" <Basavaraj.Natikar@amd.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH 3/3] thunderbolt: Add quirk to reset host interface for AMD USB4 routers
Date: Tue, 06 Oct 2026 16:49:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-162270@kernel.org> (raw)
In-Reply-To: <26ea33592937dcd93d06c901443a9b938cc24caf.1790854235.git.Basavaraj.Natikar@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] thunderbolt: NULL pointer dereference in nhi_reset_work() due to late dev_set_drvdata()
--
commit 9823327103fd3f6d1af1a55c73b76fed9264dad0
Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
thunderbolt: Add quirk to reset host interface for AMD USB4 routers
This commit adds a quirk for AMD USB4 routers to reset the host interface
before reprogramming a reused DMA HopID, preventing TX ring hangs. The reset
operation waits for DMA rings to stop while leaving other tunnels intact.
> diff --git a/drivers/thunderbolt/pci.c b/drivers/thunderbolt/pci.c
> index 4408229d8ac7b..b26f5b39e923b 100644
> --- a/drivers/thunderbolt/pci.c
> +++ b/drivers/thunderbolt/pci.c
[ ... ]
> @@ -63,6 +63,27 @@ static void nhi_pci_check_quirks(struct tb_nhi_pci *nhi_pci)
> nhi->quirks |= QUIRK_E2E;
> break;
> }
> + } else if (pdev->vendor == PCI_VENDOR_ID_AMD) {
> + switch (pdev->device) {
[ ... ]
> + case PCI_DEVICE_ID_AMD_1AH_M70H_NHI0:
> + case PCI_DEVICE_ID_AMD_1AH_M70H_NHI1:
> + /*
> + * These hosts may hang the Tx ring if its HopID is
> + * programmed again without a host interface reset
> + * in between.
> + */
> + nhi->quirks |= QUIRK_RESET_DMA_ON_REUSE;
[Severity: High]
Does adding this quirk expose a race condition during probe that leads to a
NULL pointer dereference in nhi_reset_work()?
When QUIRK_RESET_DMA_ON_REUSE is set, it seems nhi_reset_work() can be queued
when a DMA ring stops. However, looking at the initialization sequence in
nhi_probe(), drvdata is set very late:
drivers/thunderbolt/nhi.c:nhi_probe() {
...
res = tb_domain_add(tb, host_reset);
if (res) {
...
}
dev_set_drvdata(dev, tb);
...
}
During tb_domain_add(), event processing is started and the lock is dropped
before returning:
drivers/thunderbolt/domain.c:tb_domain_add() {
...
/* This starts event processing */
mutex_unlock(&tb->lock);
device_init_wakeup(&tb->dev, true);
...
}
Because tb_domain_add() allows asynchronous events (like DMA ring start/stop
operations) to execute before returning to nhi_probe(), nhi_reset_work() can
be scheduled while drvdata is still NULL. If this happens, it leads to a crash
when trying to acquire the lock:
drivers/thunderbolt/nhi.c:nhi_reset_work() {
struct tb *tb = dev_get_drvdata(nhi->dev);
/* The connection manager must be blocked over the reset */
guard(mutex)(&tb->lock);
...
}
Can we ensure drvdata is set before enabling event processing, or otherwise
prevent the reset work from running before tb_domain_add() finishes?
> + break;
> + }
> }
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1790854235.git.Basavaraj.Natikar@amd.com?part=3
prev parent reply other threads:[~2026-10-06 16:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 13:43 [PATCH 0/3] thunderbolt: Reset affected AMD host interfaces before DMA HopID reuse Basavaraj Natikar
2026-10-05 13:43 ` [PATCH 1/3] thunderbolt: Allow tb_ring_start() to fail Basavaraj Natikar
2026-10-06 4:27 ` Mika Westerberg
2026-10-06 16:24 ` sashiko-bot
2026-10-05 13:43 ` [PATCH 2/3] thunderbolt: Reset the host interface before reusing a DMA HopID Basavaraj Natikar
2026-10-05 14:35 ` Mika Westerberg
2026-10-05 15:12 ` Mario Limonciello
2026-10-05 16:50 ` Basavaraj Natikar
2026-10-06 4:33 ` Mika Westerberg
2026-10-06 14:47 ` Basavaraj Natikar
2026-10-06 16:35 ` sashiko-bot
2026-10-05 13:43 ` [PATCH 3/3] thunderbolt: Add quirk to reset host interface for AMD USB4 routers Basavaraj Natikar
2026-10-06 16:49 ` sashiko-bot [this message]
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=sashiko-outbox-162270@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Basavaraj.Natikar@amd.com \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.