From: "Nikhil P. Rao" <nikhil.rao@amd.com>
To: Brett Creeley <brett.creeley@amd.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>,
Richard Cochran <richardcochran@gmail.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Eric Joyner <eric.joyner@amd.com>,
Abhijit Gangurde <abhijit.gangurde@amd.com>,
"Allen Hubbe" <allen.hubbe@amd.com>,
"Nikhil P. Rao" <nikhil.rao@amd.com>, <stable@vger.kernel.org>
Subject: [PATCH net v2 0/5] ionic: fix register reads racing the BAR unmap on PCI reset
Date: Fri, 4 Dec 2026 22:04:19 +0000 [thread overview]
Message-ID: <20261204-b4-pr60-v2-0-9e0b5408a68e@amd.com> (raw)
A PCI reset of an ionic device runs ionic_reset_prepare(), which ends
in ionic_clear_pci(): it clears the driver's pointers into BAR0 and
unmaps it. Several readers test one of those pointers and then read
through it without synchronizing with that teardown, so a reset that
lands between the test and the read makes them access the unmapped
BAR. This series closes those windows.
Patch 1 clears and sets the device command registers under
dev_cmd_lock and takes the lock in the two readers that did not.
Patch 2 turns the lockless device info readers (firmware status,
heartbeat and the ethtool register dump) into RCU readers and has the
teardown wait for them.
Patch 3 clears the PHC counter registers under phc->lock when the
reset starts and has the PHC operations check them under that lock.
Patch 4 holds queue_lock while ethtool -C writes the interrupt control
registers, so the update cannot race the queue teardown of either reset.
Patch 5 cancels a queue's DIM work after NAPI is disabled, so a poll
cannot queue it again before the queue is freed and BAR0 unmapped.
The firmware up handler, run from deferred work, also reads the device
info registers. A reset's own admin commands can queue that work after
the reset has cancelled it; a separate series keeps the deferred work
stopped across a reset.
The races in patches 1-3 were reproduced on an AMD Pensando NIC, on a
kernel with KASAN and lockdep, by holding the reader between its check
and its access with a test-only kprobe module while a PCI reset ran:
without the series the access faults on the unmapped BAR, with it the
reset waits for the reader or the reader backs off. The races in patches
4 and 5 were not reproduced. The series was also run through 30 PCI
resets per test under concurrent ethtool, devlink and PHC load with
lockdep enabled, without regressions.
The races in patches 1-3 and 5 were found by Sashiko and the one in
patch 4 by a Claude Code review; Claude Code was also used in developing
and testing the fixes.
Signed-off-by: Nikhil P. Rao <nikhil.rao@amd.com>
---
Changes in v2:
- Patch 1: note in dev_cmd_lock's comment that it protects
idev.dev_cmd_regs (Sashiko).
- Patch 2: note that dev_info_regs is RCU protected (Sashiko).
- Patch 4: cover the firmware reset path too, retitle, add
Fixes: c672412f6172 (Sashiko).
- New patch 5: cancel the DIM work after napi_disable() and reset its
state (Sashiko).
- Link to v1: https://patch.msgid.link/20261202-b4-pr60-v1-0-b1f6706e065b@amd.com
---
Nikhil P. Rao (5):
ionic: fix devcmds racing the BAR unmap on PCI reset
ionic: fix device info register reads racing the BAR unmap on PCI reset
ionic: fix PHC reads racing the BAR unmap on PCI reset
ionic: fix ethtool coalesce updates racing a reset
ionic: fix DIM work racing the queue teardown
drivers/net/ethernet/pensando/ionic/ionic.h | 3 +-
.../net/ethernet/pensando/ionic/ionic_bus_pci.c | 21 ++++++++++++-
drivers/net/ethernet/pensando/ionic/ionic_dev.c | 34 +++++++++++++---------
drivers/net/ethernet/pensando/ionic/ionic_dev.h | 1 +
.../net/ethernet/pensando/ionic/ionic_ethtool.c | 18 ++++++++++--
drivers/net/ethernet/pensando/ionic/ionic_fw.c | 6 ++++
drivers/net/ethernet/pensando/ionic/ionic_lif.c | 3 +-
drivers/net/ethernet/pensando/ionic/ionic_lif.h | 2 +-
drivers/net/ethernet/pensando/ionic/ionic_phc.c | 20 +++++++++++--
9 files changed, 85 insertions(+), 23 deletions(-)
---
base-commit: e9d78fc6741ac06d438cf64e314c28e57014432a
change-id: 20261118-b4-pr60-5fd83c966e7a
Best regards,
--
Nikhil P. Rao <nikhil.rao@amd.com>
next reply other threads:[~2026-12-04 22:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 22:04 Nikhil P. Rao [this message]
2026-12-04 22:04 ` [PATCH net v2 1/5] ionic: fix devcmds racing the BAR unmap on PCI reset Nikhil P. Rao
2026-12-04 22:04 ` [PATCH net v2 2/5] ionic: fix device info register reads " Nikhil P. Rao
2026-12-04 22:04 ` [PATCH net v2 3/5] ionic: fix PHC " Nikhil P. Rao
2026-12-04 22:04 ` [PATCH net v2 4/5] ionic: fix ethtool coalesce updates racing a reset Nikhil P. Rao
2026-12-04 22:04 ` [PATCH net v2 5/5] ionic: fix DIM work racing the queue teardown Nikhil P. Rao
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=20261204-b4-pr60-v2-0-9e0b5408a68e@amd.com \
--to=nikhil.rao@amd.com \
--cc=abhijit.gangurde@amd.com \
--cc=allen.hubbe@amd.com \
--cc=andrew+netdev@lunn.ch \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=eric.joyner@amd.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=stable@vger.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