From: Mina Almasry <almasrymina@google.com>
To: Tariq Toukan <tariqt@nvidia.com>
Cc: Mina Almasry <almasrymina@google.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
Bobby Eshleman <bobbyeshleman@meta.com>,
Byungchul Park <byungchul@sk.com>,
Carolina Jubran <cjubran@nvidia.com>,
Cosmin Ratiu <cratiu@nvidia.com>,
Dragos Tatulea <dtatulea@nvidia.com>,
Gal Pressman <gal@nvidia.com>,
Jacob Keller <Jacob.e.keller@intel.com>,
Kees Cook <kees@kernel.org>, Leon Romanovsky <leon@kernel.org>,
open list <linux-kernel@vger.kernel.org>,
linux-rdma@vger.kernel.org, Mark Bloch <mbloch@nvidia.com>,
Matt Fleming <mfleming@cloudflare.com>,
Nikolay Aleksandrov <razor@blackwall.org>,
Saeed Mahameed <saeedm@nvidia.com>,
Shivaji Kant <shivajikant@google.com>,
Simon Horman <horms@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>,
Stanislav Fomichev <sdf.kernel@gmail.com>,
William Tu <witu@nvidia.com>,
Yue Haibing <yuehaibing@huawei.com>,
Bobby Eshleman <bobbyeshleman@gmail.com>
Subject: Re: [PATCH net-next 09/10] net: devmem: add netdev_has_dmabuf_binding() helper
Date: Fri, 9 Oct 2026 23:56:19 +0000 [thread overview]
Message-ID: <20261009235619.3826575-1-almasrymina@google.com> (raw)
In-Reply-To: <20261008132815.654147-10-tariqt@nvidia.com>
On Thu, Oct 8, 2026 at 6:28 AM Tariq Toukan <tariqt@nvidia.com> wrote:
> From: Dragos Tatulea <dtatulea@nvidia.com>
>
> A binding can outlive its xarray slot: it can still be referenced by
> in-flight TX skbs, whose DMA mappings are only valid for the device the
> dmabuf was attached to. Reporting such a binding as gone would let a
> driver swap the DMA device out from under those skbs. For this reason,
> track bindings for their whole lifetime on a new list.
(Note: LLM-assisted review comment below.)
Two suggestions on the core design here:
1. Add a synchronous DMA detach helper (e.g. netdev_unbind_dmabuf_dma_dev(dev,
dma_dev)) alongside netdev_has_dmabuf_binding() so patch 08/10 can cleanly
tear down active bindings on MLX5_DATA_DIRECT_UNBIND:
- Separate DMA mapping lifetime (ends synchronously when queues stop and
dev/vdev/dma_dev goes away) from CPU net_iov lifetime (ends in
__net_devmem_dmabuf_binding_free() when binding->ref hits 0).
- For bindings matching (dev, binding->attachment->dev == dma_dev), close
bound RX queues (netif_mp_close_rxq()), erase binding->id from
net_devmem_dmabuf_bindings, clear WRITE_ONCE(binding->dev, NULL) /
WRITE_ONCE(binding->vdev, NULL), call synchronize_net(), and unmap/detach
binding->sgt and binding->attachment synchronously (setting them to NULL
so __net_devmem_dmabuf_binding_free() skips them later).
- Note: core devmem also has a pre-existing bug on physical/virtual
NETDEV_UNREGISTER where mp_dmabuf_devmem_uninstall() and TX bindings leave
dma_buf mapped past pci_driver->remove() and TX bindings leave
binding->dev / binding->vdev dangling; sharing a single core detach
helper solves both cleanly with zero new fields in
struct net_devmem_dmabuf_binding.
2. Once detach (and net_devmem_unbind_dmabuf() on TX unbind) clears
WRITE_ONCE(binding->dev, NULL), runs synchronize_net(), and unmaps
binding->sgt synchronously, any binding already erased from
net_devmem_dmabuf_bindings is already DMA-unmapped and rejected by
validate_xmit_unreadable_skb() (READ_ONCE(binding->dev) != dev). That
eliminates the need for net_devmem_live_bindings_lock / live_list —
iterating net_devmem_dmabuf_bindings under netdev_lock(dev) suffices for
both netdev_has_dmabuf_binding() and netdev_unbind_dmabuf_dma_dev().
--
Thanks,
Mina
next prev parent reply other threads:[~2026-10-09 23:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 13:28 [PATCH net-next 00/10] net/mlx5e: Add netdev support for data direct Tariq Toukan
2026-10-08 13:28 ` [PATCH net-next 01/10] net/mlx5: Log the data direct to PF device mapping Tariq Toukan
2026-10-08 13:28 ` [PATCH net-next 02/10] net/mlx5e: Register supported netdevs as data direct users Tariq Toukan
2026-10-08 13:28 ` [PATCH net-next 03/10] net/mlx5e: Pre-calculate UMR padding and entry size Tariq Toukan
2026-10-08 13:28 ` [PATCH net-next 04/10] net/mlx5e: Add data direct ethtool private flag Tariq Toukan
2026-10-08 13:28 ` [PATCH net-next 05/10] net/mlx5e: Add data direct RX infrastructure Tariq Toukan
2026-10-08 13:28 ` [PATCH net-next 06/10] net/mlx5e: Add data direct TX infrastructure Tariq Toukan
2026-10-08 13:28 ` [PATCH net-next 07/10] net/mlx5e: Use the correct DMA dev when data_direct pdev enabled Tariq Toukan
2026-10-08 13:28 ` [PATCH net-next 08/10] net/mlx5e: Recreate netdev channels on data direct device unbind Tariq Toukan
2026-10-09 23:56 ` Mina Almasry
2026-10-08 13:28 ` [PATCH net-next 09/10] net: devmem: add netdev_has_dmabuf_binding() helper Tariq Toukan
2026-10-09 23:56 ` Mina Almasry [this message]
2026-10-08 13:28 ` [PATCH net-next 10/10] net/mlx5e: Enable the data direct netdev feature Tariq Toukan
2026-10-09 23:56 ` Mina Almasry
2026-10-09 16:42 ` [PATCH net-next 00/10] net/mlx5e: Add netdev support for data direct Mina Almasry
2026-10-09 23:54 ` Mina Almasry
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=20261009235619.3826575-1-almasrymina@google.com \
--to=almasrymina@google.com \
--cc=Jacob.e.keller@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=bobbyeshleman@gmail.com \
--cc=bobbyeshleman@meta.com \
--cc=byungchul@sk.com \
--cc=cjubran@nvidia.com \
--cc=cratiu@nvidia.com \
--cc=davem@davemloft.net \
--cc=dtatulea@nvidia.com \
--cc=edumazet@kernel.org \
--cc=gal@nvidia.com \
--cc=horms@kernel.org \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=mfleming@cloudflare.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.org \
--cc=saeedm@nvidia.com \
--cc=sdf.kernel@gmail.com \
--cc=sdf@fomichev.me \
--cc=shivajikant@google.com \
--cc=tariqt@nvidia.com \
--cc=witu@nvidia.com \
--cc=yuehaibing@huawei.com \
/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
all inboxes | Powered by JetHome®