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>,
Saeed Mahameed <saeedm@nvidia.com>, <tariqt@nvidia.com>,
<cratiu@nvidia.com>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: [RFC net-next 3/4] net: devmem: Use the new netdev_get_dma_dev() API
Date: Wed, 2 Jul 2025 20:24:25 +0300 [thread overview]
Message-ID: <20250702172433.1738947-4-dtatulea@nvidia.com> (raw)
In-Reply-To: <20250702172433.1738947-1-dtatulea@nvidia.com>
Using the new DMA dev helper API, there will be an error on
buffer binding if the device does not support DMA.
Previously this went through and was returning success event if the
mappings were not done. Only a warning was printed.
Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
---
net/core/devmem.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/net/core/devmem.c b/net/core/devmem.c
index b3a62ca0df65..c6354b47257f 100644
--- a/net/core/devmem.c
+++ b/net/core/devmem.c
@@ -183,6 +183,7 @@ net_devmem_bind_dmabuf(struct net_device *dev,
{
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;
@@ -193,6 +194,13 @@ net_devmem_bind_dmabuf(struct net_device *dev,
if (IS_ERR(dmabuf))
return ERR_CAST(dmabuf);
+ dma_dev = netdev_get_dma_dev(dev);
+ if (!dma_dev) {
+ err = -EOPNOTSUPP;
+ NL_SET_ERR_MSG(extack, "Parent device can't do dma");
+ goto err_put_dmabuf;
+ }
+
binding = kzalloc_node(sizeof(*binding), GFP_KERNEL,
dev_to_node(&dev->dev));
if (!binding) {
@@ -209,7 +217,7 @@ net_devmem_bind_dmabuf(struct net_device *dev,
binding->dmabuf = dmabuf;
- binding->attachment = dma_buf_attach(binding->dmabuf, dev->dev.parent);
+ binding->attachment = dma_buf_attach(binding->dmabuf, dma_dev);
if (IS_ERR(binding->attachment)) {
err = PTR_ERR(binding->attachment);
NL_SET_ERR_MSG(extack, "Failed to bind dmabuf to device");
--
2.50.0
next prev parent reply other threads:[~2025-07-02 17:27 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-02 17:24 [RFC net-next 0/4] devmem/io_uring: Allow devices without parent PCI device Dragos Tatulea
2025-07-02 17:24 ` [RFC net-next 1/4] net: Allow non parent devices to be used for ZC DMA Dragos Tatulea
2025-07-02 18:32 ` Jakub Kicinski
2025-07-02 20:01 ` Dragos Tatulea
2025-07-02 20:53 ` Jakub Kicinski
2025-07-03 11:58 ` Parav Pandit
2025-07-04 13:11 ` Dragos Tatulea
2025-07-07 18:44 ` Mina Almasry
2025-07-07 21:35 ` Dragos Tatulea
2025-07-07 21:55 ` Mina Almasry
2025-07-08 8:52 ` Parav Pandit
2025-07-08 10:47 ` Pavel Begunkov
2025-07-08 14:23 ` Dragos Tatulea
2025-07-08 11:08 ` Pavel Begunkov
2025-07-08 14:26 ` Dragos Tatulea
2025-07-10 23:58 ` Jakub Kicinski
2025-07-11 2:52 ` Parav Pandit
2025-07-11 13:51 ` Jakub Kicinski
2025-07-08 11:06 ` Pavel Begunkov
2025-07-08 14:10 ` Mina Almasry
2025-07-08 15:25 ` Pavel Begunkov
2025-07-02 17:24 ` [RFC net-next 2/4] io_uring/zcrx: Use the new netdev_get_dma_dev() API Dragos Tatulea
2025-07-02 17:24 ` Dragos Tatulea [this message]
2025-07-02 17:24 ` [RFC net-next 4/4] net/mlx5e: Enable HDS zerocopy flows for SFs Dragos Tatulea
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=20250702172433.1738947-4-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=saeedm@nvidia.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
all inboxes | Powered by JetHome®