From: Dragos Tatulea <dtatulea@nvidia.com>
To: <almasrymina@google.com>, <asml.silence@gmail.com>,
"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>
Cc: Dragos Tatulea <dtatulea@nvidia.com>, <cratiu@nvidia.com>,
<parav@nvidia.com>, <netdev@vger.kernel.org>, <sdf@meta.com>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH net-next v4 5/7] net: devmem: pull out dma_dev out of net_devmem_bind_dmabuf
Date: Wed, 20 Aug 2025 20:11:56 +0300 [thread overview]
Message-ID: <20250820171214.3597901-7-dtatulea@nvidia.com> (raw)
In-Reply-To: <20250820171214.3597901-1-dtatulea@nvidia.com>
Fetch the DMA device before calling net_devmem_bind_dmabuf()
and pass it on as a parameter.
This is needed for an upcoming change which will read the
DMA device per queue.
This patch has no functional changes.
Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
Reviewed-by: Mina Almasry <almasrymina@google.com>
---
net/core/devmem.c | 14 ++++++--------
net/core/devmem.h | 2 ++
net/core/netdev-genl.c | 12 ++++++++----
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/net/core/devmem.c b/net/core/devmem.c
index d66cb0a63bd6..c7ca16c9fc04 100644
--- a/net/core/devmem.c
+++ b/net/core/devmem.c
@@ -176,30 +176,28 @@ int net_devmem_bind_dmabuf_to_queue(struct net_device *dev, u32 rxq_idx,
struct net_devmem_dmabuf_binding *
net_devmem_bind_dmabuf(struct net_device *dev,
+ struct device *dma_dev,
enum dma_data_direction direction,
unsigned int dmabuf_fd, struct netdev_nl_sock *priv,
struct netlink_ext_ack *extack)
{
struct net_devmem_dmabuf_binding *binding;
static u32 id_alloc_next;
- struct device *dma_dev;
struct scatterlist *sg;
struct dma_buf *dmabuf;
unsigned int sg_idx, i;
unsigned long virtual;
int err;
- dmabuf = dma_buf_get(dmabuf_fd);
- if (IS_ERR(dmabuf))
- return ERR_CAST(dmabuf);
-
- dma_dev = netdev_queue_get_dma_dev(dev, 0);
if (!dma_dev) {
- err = -EOPNOTSUPP;
NL_SET_ERR_MSG(extack, "Device doesn't support dma");
- goto err_put_dmabuf;
+ return ERR_PTR(-EOPNOTSUPP);
}
+ dmabuf = dma_buf_get(dmabuf_fd);
+ if (IS_ERR(dmabuf))
+ return ERR_CAST(dmabuf);
+
binding = kzalloc_node(sizeof(*binding), GFP_KERNEL,
dev_to_node(&dev->dev));
if (!binding) {
diff --git a/net/core/devmem.h b/net/core/devmem.h
index 41cd6e1c9141..101150d761af 100644
--- a/net/core/devmem.h
+++ b/net/core/devmem.h
@@ -85,6 +85,7 @@ struct dmabuf_genpool_chunk_owner {
void __net_devmem_dmabuf_binding_free(struct work_struct *wq);
struct net_devmem_dmabuf_binding *
net_devmem_bind_dmabuf(struct net_device *dev,
+ struct device *dma_dev,
enum dma_data_direction direction,
unsigned int dmabuf_fd, struct netdev_nl_sock *priv,
struct netlink_ext_ack *extack);
@@ -170,6 +171,7 @@ static inline void net_devmem_put_net_iov(struct net_iov *niov)
static inline struct net_devmem_dmabuf_binding *
net_devmem_bind_dmabuf(struct net_device *dev,
+ struct device *dma_dev,
enum dma_data_direction direction,
unsigned int dmabuf_fd,
struct netdev_nl_sock *priv,
diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c
index 6314eb7bdf69..3e2d6aa6e060 100644
--- a/net/core/netdev-genl.c
+++ b/net/core/netdev-genl.c
@@ -876,6 +876,7 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info)
u32 ifindex, dmabuf_fd, rxq_idx;
struct netdev_nl_sock *priv;
struct net_device *netdev;
+ struct device *dma_dev;
struct sk_buff *rsp;
struct nlattr *attr;
int rem, err = 0;
@@ -921,8 +922,9 @@ int netdev_nl_bind_rx_doit(struct sk_buff *skb, struct genl_info *info)
goto err_unlock;
}
- binding = net_devmem_bind_dmabuf(netdev, DMA_FROM_DEVICE, dmabuf_fd,
- priv, info->extack);
+ dma_dev = netdev_queue_get_dma_dev(netdev, 0);
+ binding = net_devmem_bind_dmabuf(netdev, dma_dev, DMA_FROM_DEVICE,
+ dmabuf_fd, priv, info->extack);
if (IS_ERR(binding)) {
err = PTR_ERR(binding);
goto err_unlock;
@@ -986,6 +988,7 @@ int netdev_nl_bind_tx_doit(struct sk_buff *skb, struct genl_info *info)
struct net_devmem_dmabuf_binding *binding;
struct netdev_nl_sock *priv;
struct net_device *netdev;
+ struct device *dma_dev;
u32 ifindex, dmabuf_fd;
struct sk_buff *rsp;
int err = 0;
@@ -1032,8 +1035,9 @@ int netdev_nl_bind_tx_doit(struct sk_buff *skb, struct genl_info *info)
goto err_unlock_netdev;
}
- binding = net_devmem_bind_dmabuf(netdev, DMA_TO_DEVICE, dmabuf_fd, priv,
- info->extack);
+ dma_dev = netdev_queue_get_dma_dev(netdev, 0);
+ binding = net_devmem_bind_dmabuf(netdev, dma_dev, DMA_TO_DEVICE,
+ dmabuf_fd, priv, info->extack);
if (IS_ERR(binding)) {
err = PTR_ERR(binding);
goto err_unlock_netdev;
--
2.50.1
next prev parent reply other threads:[~2025-08-20 17:13 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-20 17:11 [PATCH net-next v4 0/7] devmem/io_uring: allow more flexibility for ZC DMA devices Dragos Tatulea
2025-08-20 17:11 ` [PATCH net-next v4 1/7] queue_api: add support for fetching per queue DMA dev Dragos Tatulea
2025-08-20 22:48 ` Mina Almasry
2025-08-21 1:01 ` Jakub Kicinski
2025-08-21 11:06 ` Dragos Tatulea
2025-08-20 17:11 ` [PATCH net-next v4 2/7] io_uring/zcrx: add support for custom DMA devices Dragos Tatulea
2025-08-20 17:11 ` [PATCH net-next v4 3/7] net: devmem: get netdev DMA device via new API Dragos Tatulea
2025-08-21 1:04 ` Jakub Kicinski
2025-08-20 17:11 ` [PATCH net-next v4 4/7] net/mlx5e: add op for getting netdev DMA device Dragos Tatulea
2025-08-20 17:11 ` Dragos Tatulea [this message]
2025-08-20 17:11 ` [PATCH net-next v4 6/7] net: devmem: pre-read requested rx queues during bind Dragos Tatulea
2025-08-20 22:51 ` Mina Almasry
2025-08-21 1:09 ` Jakub Kicinski
2025-08-21 11:07 ` Dragos Tatulea
2025-08-20 17:11 ` [PATCH net-next v4 7/7] net: devmem: allow binding on rx queues with same DMA devices Dragos Tatulea
2025-08-20 22:57 ` Mina Almasry
2025-08-21 16:37 ` Dragos Tatulea
2025-08-21 1:16 ` Jakub Kicinski
2025-08-21 11:10 ` Dragos Tatulea
2025-08-21 14:32 ` Jakub Kicinski
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=20250820171214.3597901-7-dtatulea@nvidia.com \
--to=dtatulea@nvidia.com \
--cc=almasrymina@google.com \
--cc=asml.silence@gmail.com \
--cc=cratiu@nvidia.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=parav@nvidia.com \
--cc=sdf@meta.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®