Netdev List
 help / color / mirror / Atom feed
From: Dragos Tatulea <dtatulea@nvidia.com>
To: Mina Almasry <almasrymina@google.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 20:13:41 +0200	[thread overview]
Message-ID: <c832127a-8a80-402d-8f0f-10960f10fc32@nvidia.com> (raw)
In-Reply-To: <CAHS8izNLCCcxQwH3oYL1ch+UDf0Ok_LF0KuyJtA_S+daFye1mQ@mail.gmail.com>



On 11.08.26 19:25, Mina Almasry wrote:
> On Mon, Aug 10, 2026 at 1:59 PM Dragos Tatulea <dtatulea@nvidia.com> wrote:
>>
>> Currently there is no way to check if there is a dmabuf bound on a TX
>> queue. RX side has netif_rxq_has_unreadable_mp() which gives a hint of
>> it.
>>
>> To help with that, this patch add a helper to check whether a devmem
>> dmabuf binding is active on a given netdev, optionally filtered by the
>> DMA device the dmabuf was mapped against.
>>
>> This API is necessary for the upcoming support of data direct in mlx5e
>> to allow blocking accidental swapping of DMA devices while devmem is active.
>>
>> Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
>> ---
>>  include/net/netmem.h | 19 +++++++++++++++++++
>>  net/core/devmem.c    | 20 ++++++++++++++++++++
>>  2 files changed, 39 insertions(+)
>>
>> diff --git a/include/net/netmem.h b/include/net/netmem.h
>> index bccacd21b6c3..0e332e04ea16 100644
>> --- a/include/net/netmem.h
>> +++ b/include/net/netmem.h
>> @@ -363,16 +363,35 @@ static inline unsigned long netmem_get_dma_addr(netmem_ref netmem)
>>         return netmem_to_nmdesc(netmem)->dma_addr;
>>  }
>>
>> +struct net_device;
>> +
>>  #if defined(CONFIG_NET_DEVMEM)
>>  static inline bool net_is_devmem_iov(const struct net_iov *niov)
>>  {
>>         return niov->type == NET_IOV_DMABUF;
>>  }
>> +
>> +/**
>> + * netdev_has_dmabuf_binding - is there a dmabuf binding for a
>> + * given @dev and @dma_dev
>> + *
>> + * @dev: netdev to check bindings
>> + * @dma_dev: dma device to check, when NULL it will not be checked
>> + *
>> + * Return: true if a binding is found under @dev and possibily @dma_dev
>> + */
>> +bool netdev_has_dmabuf_binding(struct net_device *dev, struct device *dma_dev);
>>  #else
>>  static inline bool net_is_devmem_iov(const struct net_iov *niov)
>>  {
>>         return false;
>>  }
>> +
>> +static inline bool netdev_has_dmabuf_binding(struct net_device *dev,
>> +                                            struct device *dma_dev)
>> +{
>> +       return false;
>> +}
>>  #endif
>>
>>  void __get_netmem(netmem_ref netmem);
>> diff --git a/net/core/devmem.c b/net/core/devmem.c
>> index 957d6b96216b..f13a0e343684 100644
>> --- a/net/core/devmem.c
>> +++ b/net/core/devmem.c
>> @@ -364,6 +364,26 @@ struct net_devmem_dmabuf_binding *net_devmem_lookup_dmabuf(u32 id)
>>         return binding;
>>  }
>>
>> +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();
> 
> Why do you need rcu locking? I thought xarrays handle concurrency
> inside their helpers.
> 

Not needed. Monkey see monkey do from net_devmem_lookup_dmabuf(). Will drop.

Thank,
Dragos


      reply	other threads:[~2026-08-11 18:13 UTC|newest]

Thread overview: 8+ 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
2026-08-11 10:47   ` Dragos Tatulea
     [not found] ` <anpN3vJUig93aSB8@devvm29614.prn0.facebook.com>
2026-08-11  7:24   ` Dragos Tatulea
2026-08-11 10:44     ` Dragos Tatulea
     [not found]       ` <anthYJ3RSVWnhVoE@devvm29614.prn0.facebook.com>
2026-08-11 18:46         ` Dragos Tatulea
2026-08-11 17:25 ` Mina Almasry
2026-08-11 18:13   ` 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=c832127a-8a80-402d-8f0f-10960f10fc32@nvidia.com \
    --to=dtatulea@nvidia.com \
    --cc=almasrymina@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox