From: Tobias Heath <heathtobias@gmail.com>
To: Andreas Noever <andreas.noever@gmail.com>,
Mika Westerberg <westeri@kernel.org>,
Yehezkel Bernat <YehezkelShB@gmail.com>,
Sukhdeep Singh <sukhdeeps@marvell.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>,
linux-usb@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] atlantic: skip hardware teardown when PCIe parent is
Date: Wed, 25 Nov 2026 12:48:33 +0000 [thread overview]
Message-ID: <c3e6cc57-a091-4342-bbb5-03b594c05fdf@gmail.com> (raw)
In-Reply-To: <31d3413a-9aa0-4208-8e15-3ba85829ef79@gmail.com>
When the PCIe parent bridge of an atlantic NIC is removed - which
happens routinely on laptops with Thunderbolt docks whenever the dock
is physically disconnected while any sleep / power management cycle is
in flight - the kernel enters a deadlock:
* pciehp_ist invokes pci_stop_and_remove_bus_device() on the atlantic
device; this acquires the device's lock and calls the driver's
.remove callback (aq_pci_remove).
* aq_pci_remove -> unregister_netdev -> aq_ndev_close -> aq_nic_stop
-> aq_vec_stop -> napi_disable -> napi_disable_locked.
* napi_disable_locked waits for NAPI_STATE_SCHED to clear in a
usleep_range loop. NAPI_STATE_SCHED is cleared by the poll
function (aq_vec_poll) calling napi_complete_done, but the poll
function reads the RX ring state over the (now disconnected) PCIe
bus: config reads return 0xffffffff, the poll never decides it has
quiesced, NAPI_STATE_SCHED never clears, and the loop spins
indefinitely.
* Every other device_resume waiting on the parent bridge blocks on
the mutex held by pciehp_ist; most visibly an async wiphy_resume
for the laptop's Wi-Fi, which DPM watchdog times out at 120 s,
panicking the kernel.
The kernel already has the signal we need: pciehp calls
pci_dev_set_disconnected() (which sets dev->error_state to
pci_channel_io_perm_failure) via pci_walk_bus() before starting the
device-removal walk. By the time aq_pci_remove() runs on a surprise-
removed device, pci_dev_is_disconnected(pdev) is already true.
aq_nic_deinit() in the same file already consults the equivalent
c pci_device_is_present() for the firmware deinit path; aq_nic_stop()
simply does not. This patch adds the check: when the PCIe parent is
disconnected, skip the hardware-touch work (hw_irq_disable, aq_vec_stop
with its napi_disable, aq_ptp_ring_stop, hw_stop) and still free the
IRQs that need userspace-side cleanup. unregister_netdev() in the
caller continues to free the NAPI structures on the kernel's side as
normal.
This mirrors the handling in Marvell's AQtion Windows driver
(aqnic650.sys 3.1.10), which uses a "surprise_removed" flag set from
NdisDevicePnPEventSurpriseRemoved to short-circuit every hardware
code path while still completing software teardown. Static analysis of
that driver confirmed both the pattern and the bounded wait times on
its remaining hardware polls (1 s register poll, 2 s firmware mailbox)
- details available on request.
Before this patch, with a TB dock connected to the atlantic device,
disconnecting the dock during any sleep or power transition caused a
reproducible DPM-watchdog panic at T+120 s. With this patch, the
teardown completes in milliseconds and the system continues normally.
Signed-off-by: Tobias Heath <heathtobias@gmail.com>
---
.../net/ethernet/aquantia/atlantic/aq_nic.c | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
index 42e0fe924..0cca82974 100644
--- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
+++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c
@@ -1434,6 +1434,27 @@ int aq_nic_stop(struct aq_nic_s *self)
timer_delete_sync(&self->service_timer);
cancel_work_sync(&self->service_task);
+ /*
+ * If the PCIe parent bridge was removed (e.g. a Thunderbolt dock
+ * was physically unplugged while the kernel was mid-teardown),
+ * the device's config space reads as all-ones. Register writes are
+ * harmless no-ops, but napi_disable() waits for NAPI_STATE_SCHED
+ * to clear via napi_complete_done() from the poll function, which
+ * reads the RX ring state from dead hardware and never decides it
+ * is done — the wait loop spins indefinitely. This matches the
+ * Windows AQtion driver's handling of NdisDevicePnPEventSurpriseRemoved
+ * (a "surprise_removed" flag short-circuits every hardware path
+ * while still freeing software state).
+ *
+ * Skip the hardware-touching teardown; unregister_netdev() in the
+ * caller takes care of the NAPI structures on the kernel side.
+ */
+ if (pci_dev_is_disconnected(self->pdev)) {
+ if (!self->aq_nic_cfg.is_polling)
+ aq_pci_func_free_irqs(self);
+ return 0;
+ }
+
self->aq_hw_ops->hw_irq_disable(self->aq_hw, AQ_CFG_IRQ_MASK);
if (self->aq_nic_cfg.is_polling)
--
2.56.1
prev parent reply other threads:[~2026-11-25 12:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 12:39 [PATCH 0/2] thunderbolt + atlantic: preserve dock across s2idle; fix surprise-removed deadlock Tobias Heath
2026-11-25 12:45 ` [PATCH 1/2] thunderbolt: add opt-in to preserve tunnels across s2idle Tobias Heath
2026-11-25 12:48 ` Tobias Heath [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=c3e6cc57-a091-4342-bbb5-03b594c05fdf@gmail.com \
--to=heathtobias@gmail.com \
--cc=YehezkelShB@gmail.com \
--cc=andreas.noever@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=sukhdeeps@marvell.com \
--cc=westeri@kernel.org \
/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