On 12.10.26 19:42, Mina Almasry wrote:
> Fix two device-unregistration lifecycle bugs in devmem TCP bindings and
> add netdevsim support plus selftests covering both RX and TX device
> unregistration:
>
> 1. net: devmem: unmap dma_buf synchronously on queue uninstall
> Synchronously unmap and detach binding->attachment under binding->lock
> when the last RX queue is uninstalled in mp_dmabuf_devmem_uninstall(),
> and unmap RX bindings that were already unbound on NETDEV_UNREGISTER,
> preventing slab-use-after-free in dma_unmap_sg_attrs() when the binding
> is freed after dma_dev.
>
> 2. net: devmem: detach TX bindings on NETDEV_UNREGISTER
> Extend net_devmem_dev_unregister() to fully detach and unmap TX
> bindings when binding->dev unregisters, or clear binding->vdev alone
> when only a virtual device unregisters while binding->dev lives.
>
> 3. netdevsim: support devmem RX and TX bindings
> Enable PP_FLAG_DMA_MAP | PP_FLAG_ALLOW_UNREADABLE_NETMEM, 64-bit DMA mask
> on nsim_bus_dev, and NETMEM_TX_DMA on netdevsim so devmem RX/TX bindings
> can be exercised in software selftests.
>
> 4. selftests: net: add devmem RX and TX netdev unregister tests
> Add devmem_bind_rx_unregister_check and devmem_bind_tx_unregister_check
> to tools/testing/selftests/net/nl_netdev.py.
>
> Cc: Tariq Toukan <[email protected]>
> Cc: Kaifeng Wang <[email protected]>
>
> ---
> v2:
> - 1/4: Don't unmap when a leased queue is unleased. Keep bindings in
> net_devmem_dmabuf_bindings until freed, hidden from TX lookups by an
> xarray mark, and unmap unbound RX bindings on NETDEV_UNREGISTER. Update
> the binding->lock and binding->ref comments. (Sashiko)
> - 2/4: Detach TX bindings from the same net_devmem_lock-protected walk,
> which now also covers unbound TX bindings, and clear the LIVE mark
> instead of erasing the ID. The walk no longer uses RCU or takes
> binding references (Stanislav).
> - Link to v1:
> https://lore.kernel.org/netdev/[email protected]/
>
> Mina Almasry (4):
> net: devmem: unmap dma_buf synchronously on queue uninstall
> net: devmem: detach TX bindings on NETDEV_UNREGISTER
> netdevsim: support devmem RX and TX bindings
> selftests: net: add devmem RX and TX netdev unregister tests
>
> drivers/net/netdevsim/bus.c | 1 +
> drivers/net/netdevsim/netdev.c | 21 ++--
> net/core/devmem.c | 121 ++++++++++++++++++++---
> net/core/devmem.h | 10 +-
> net/core/netdev-genl.c | 1 +
> tools/testing/selftests/net/nl_netdev.py | 108 +++++++++++++++++++-
> 6 files changed, 236 insertions(+), 26 deletions(-)
>
>
> base-commit: 4f6ac74fa594a918d41255c941256e1d51592d3b
Went through the series and it looks good to my feeble human brain:
Reviewed-by: Dragos Tatulea <[email protected]>
I am biased though because I need Mina's code to add support for
unbinding the dma device for data-direct.
Thanks,
Dragos