From: Dragos Tatulea <dtatulea@nvidia.com>
To: bobbyeshleman <bobbyeshleman@devvm29614.prn0.facebook.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
tariqt@nvidia.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: devmem: add netdev_has_dmabuf_binding() helper
Date: Tue, 11 Aug 2026 09:24:53 +0200 [thread overview]
Message-ID: <dab8a7cc-f202-4975-93a7-7e80a386e214@nvidia.com> (raw)
In-Reply-To: <anpN3vJUig93aSB8@devvm29614.prn0.facebook.com>
On 11.08.26 00:17, bobbyeshleman wrote:
> On Mon, Aug 10, 2026 at 08:54:45PM +0300, Dragos Tatulea wrote:> [...]
>> +bool netdev_has_dmabuf_binding(struct net_device *dev, struct device *dma_dev)
>> +{
>> + struct net_devmem_dmabuf_binding *binding;
>> + unsigned long id;
>> + bool found = false;
>> +
>> + rcu_read_lock();
>> + xa_for_each(&net_devmem_dmabuf_bindings, id, binding) {
>> + if (READ_ONCE(binding->dev) == dev &&
>> + (!dma_dev || binding->attachment->dev == dma_dev)) {
>> + found = true;
>> + break;
>> + }
>> + }
>> + rcu_read_unlock();
>> +
>> + return found;
>> +}
>> +EXPORT_SYMBOL_GPL(netdev_has_dmabuf_binding);
>> +
>> void net_devmem_get_net_iov(struct net_iov *niov)
>> {
>> net_devmem_dmabuf_binding_get(net_devmem_iov_binding(niov));
>> --
>> 2.54.0
>>
>
> I think netdev_has_dmabuf_binding() can return false even when there
> exists one or more in-flight skbs (e.g., in sk_write_queue) backed by
> the txq binding (won't technically be inactive until the final reference
> is dropped and the binding is freed)? If so, can this still detect when
> it is safe to swap the underlying dma dev?
>
Oh, good point! I didn't realize that the binding is refcounted and can
outlive its xarray slot.
Thanks,
Dragos
prev parent reply other threads:[~2026-08-11 7:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 17:54 [PATCH net-next] net: devmem: add netdev_has_dmabuf_binding() helper Dragos Tatulea
2026-08-11 0:25 ` Stanislav Fomichev
[not found] ` <anpN3vJUig93aSB8@devvm29614.prn0.facebook.com>
2026-08-11 7:24 ` Dragos Tatulea [this message]
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=dab8a7cc-f202-4975-93a7-7e80a386e214@nvidia.com \
--to=dtatulea@nvidia.com \
--cc=bobbyeshleman@devvm29614.prn0.facebook.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tariqt@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.