net: devmem: support leased RX and TX queues on netdev unregister
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest7 patches 3 repliesIn review
- v36 patches 2 repliesSuperseded
- v26 patches 2 repliesSuperseded
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 4 patches | 5 replies | Superseded |
Changes in v4 from the cover letter
- Rebase onto latest net-next/main.
- Fold net_devmem_lookup_dmabuf() into net_devmem_get_binding() under a single rcu_read_lock() (deferring net_devmem_dmabuf_binding_get() until after all checks pass) and update net_devmem_dev_unregister() to use a two-pass loop with a single synchronize_net() after clearing NET_DEVMEM_BINDING_LIVE and before unmapping bindings with
map_dev == dev (Paolo).
- Document issue discovery, validation, and testing in commit messages and the cover letter (netdev-bot+sinfo).
- v3: https://lore.kernel.org/netdev/[email protected]/
Patches in v4 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/7 | net: devmem: pass net_device pointer to net_devmem_lock_dev()net/ net/ net/ | +21 | 0 replies | |
| 2/7 | net: devmem: rename binding dev and vdev to map_dev and bind_devnet/ net/ net/ +1 more | +45 | 0 replies | |
| 3/7 | net: guard memory provider RX queue open and close on unregisternet/ net/ | +33 | 0 replies | |
| 4/7 | net: devmem: fold net_devmem_lookup_dmabuf() into net_devmem_get_binding()net/ net/ | +12 | 0 replies | |
| 5/7 | net: devmem: always populate bind_dev and detach both devices on unregisternet/ net/ net/ | +67 | 1 reply | |
| 6/7 | net: devmem: resolve physical map_dev for leased RX bindingsnet/ net/ | +25 | 0 replies | |
| 7/7 | selftests: net: add leased devmem RX and TX netdev unregister teststools/ | +155 | 0 replies |
Reviews trailers per patch
3 of 7 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Dragos Tatulea | Stanislav Fomichev | Nikolay Aleksandrov |
|---|---|---|---|
| Series | A-b | R-b | |
| 1/7 | R-b | ||
| 2/7 | R-b | ||
| 3/7 | |||
| 4/7 | |||
| 5/7 | |||
| 6/7 | |||
| 7/7 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH net-next v4 0/7] net: devmem: support leased RX and TX queues on netdev unregister
Support leased RX and TX devmem bindings when either the virtual device (e.g. netkit) or the physical backing net_device is unregistered:
1. Pass struct net_device **dev_ptr to net_devmem_lock_dev() so callers can lock either binding->map_dev or binding->bind_dev.
2. Rename binding->dev and binding->vdev to binding->map_dev (physical DMA device) and binding->bind_dev (device passed to bind-rx/bind-tx).
3. Introduce netif_lease_valid() and guard netif_mp_open_rxq(), netif_mp_close_rxq(), and netif_rxq_cleanup_unlease() against an unregistering physical device reached through a queue lease.
4. Fold net_devmem_lookup_dmabuf() into net_devmem_get_binding() so the xarray lookup, validation, device check, and reference acquisition run under a single rcu_read_lock() section.
5. Always populate bind_dev on RX and TX bindings and handle teardown and netdev unregistration of both bind_dev and map_dev, waiting for synchronize_net() after clearing NET_DEVMEM_BINDING_LIVE before unmapping bindings whose map_dev is unregistering.
6. Resolve the physical backing map_dev in netdev_nl_get_dma_dev() for leased RX bindings, lock map_dev around net_devmem_bind_dmabuf() on bind-rx when map_dev differs from netdev, assert both devices are locked, and check netif_lease_valid(map_dev).
7. Add kselftests in nl_netdev.py covering leased RX and TX devmem bindings across both virtual-first and physical-first netdev unregistration orders.
These issues were discovered during AI code review (Sashiko) of the earlier non-leased devmem unregister series (and subsequent mailing list review) and confirmed by code inspection (not observed in production or reproduced on real hardware). Tested with the nl_netdev.py selftest on netdevsim added in this series.
v4:
- Rebase onto latest net-next/main.
- Fold net_devmem_lookup_dmabuf() into net_devmem_get_binding() under a single rcu_read_lock() (deferring net_devmem_dmabuf_binding_get() until after all checks pass) and update net_devmem_dev_unregister() to use a two-pass loop with a single synchronize_net() after clearing NET_DEVMEM_BINDING_LIVE and before unmapping bindings with
map_dev == dev (Paolo).
- Document issue discovery, validation, and testing in commit messages and the cover letter (netdev-bot+sinfo).
- v3: https://lore.kernel.org/netdev/[email protected]/
v3:
- Rebase onto latest net-next/main.
- Add netif_lease_valid() helper and keep lease validity checks in the lease-aware callers (netif_mp_open_rxq(), netif_mp_close_rxq(), netif_rxq_cleanup_unlease(), and net_devmem_bind_dmabuf()) rather than inside __netif_mp_open_rxq() / __netif_mp_close_rxq(), and document why mp_params is cleared directly when !netif_lease_valid(dev) (Stanislav, Sashiko).
- Guard the bound_rxqs loop in net_devmem_unbind_dmabuf() with
if (binding->bind_dev), keep the !netif_is_queue_leasee(dev) guard in net_devmem_dev_unregister() in patch 4/6 until patch 5/6 resolves binding->map_dev to the physical device so the series is bisectable at every commit, and document the use-after-free in dma_unmap_sg_attrs() on physical netdev teardown in patch 5/6 (Sashiko).
- In nl_netdev.py, verify dmabuf and lease on the physical queue after binding, skip when queue_create returns EOPNOTSUPP, probe the physical device on EOPNOTSUPP so a broken lease lookup is not masked as SKIP, and clean up nk_ifname between loop iterations (Sashiko).
- v2: https://lore.kernel.org/netdev/[email protected]/
v2:
- Split patch 3/4 from v1 into 3 smaller commits (patches 3/6..5/6).
- Clear rxq->mp_params and return 0 in __netif_mp_close_rxq() whenever dev is already unregistering, avoiding queue reconfiguration on an already-shut-down map_dev during cascaded lease teardown (Sashiko).
- Drop unnecessary xa_erase() in net_devmem_unbind_dmabuf() and use a local map_dev variable in net_devmem_get_binding() (Stanislav).
- Restore ASSERT_EXCLUSIVE_WRITER(binding->bind_dev) in mp_dmabuf_devmem_uninstall(), drop redundant bind_dev->reg_state check in net_devmem_bind_dmabuf(), and expand commit message rationale (Dragos, Stanislav).
- v1: https://lore.kernel.org/netdev/[email protected]/
Mina Almasry (7):
net: devmem: pass net_device pointer to net_devmem_lock_dev()
net: devmem: rename binding dev and vdev to map_dev and bind_dev
net: guard memory provider RX queue open and close on unregister
net: devmem: fold net_devmem_lookup_dmabuf() into
net_devmem_get_binding()
net: devmem: always populate bind_dev and detach both devices on
unregister
net: devmem: resolve physical map_dev for leased RX bindings
selftests: net: add leased devmem RX and TX netdev unregister tests
net/core/dev.c | 2 +- net/core/dev.h | 7 + net/core/devmem.c | 178 ++++++++++++----------- net/core/devmem.h | 31 ++-- net/core/netdev-genl.c | 59 +++++--- net/core/netdev_rx_queue.c | 31 +++- tools/testing/selftests/net/nl_netdev.py | 159 +++++++++++++++++++- 7 files changed, 333 insertions(+), 134 deletions(-)
base-commit: 2208ab00f4f213ade91ab775e7f8c4dacdcc856e
Signature · 1 line
2.56.1.750.gf70dc682cf-goog