Netdev List
 help / color / mirror / Atom feed
* [PATCH net v2 0/5] ionic: fix register reads racing the BAR unmap on PCI reset
@ 2026-12-04 22:04 Nikhil P. Rao
  2026-12-04 22:04 ` [PATCH net v2 1/5] ionic: fix devcmds " Nikhil P. Rao
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Nikhil P. Rao @ 2026-12-04 22:04 UTC (permalink / raw)
  To: Brett Creeley, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Richard Cochran
  Cc: netdev, linux-kernel, Eric Joyner, Abhijit Gangurde, Allen Hubbe,
	Nikhil P. Rao, stable

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>


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-12-05 23:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 22:04 [PATCH net v2 0/5] ionic: fix register reads racing the BAR unmap on PCI reset Nikhil P. Rao
2026-12-04 22:04 ` [PATCH net v2 1/5] ionic: fix devcmds " Nikhil P. Rao
2026-12-05 23:06   ` netdev-bot+sashiko
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-05 23:06   ` netdev-bot+sashiko
2026-12-04 22:04 ` [PATCH net v2 5/5] ionic: fix DIM work racing the queue teardown Nikhil P. Rao
2026-12-05 23:06   ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox