Netdev List
 help / color / mirror / Atom feed
From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com, axboe@kernel.dk, netdev@vger.kernel.org
Subject: [PATCH io_uring v2 1/1] io_uring/zcrx: don't sync dma-bufs
Date: Thu,  3 Dec 2026 12:38:24 +0000	[thread overview]
Message-ID: <8e93a756a3b8fea2be7935d34e1b833fd98e40ea.1796301395.git.asml.silence@gmail.com> (raw)

dma-bufs follow different synchronisation rules comparing to normal
memory, the user accessing it must use proper API like
DMA_BUF_IOCTL_SYNC. Don't sync dma-buf backed buffers with the
dma_sync_*() family of helpers.

Fixes: a5c98e9424573 ("io_uring/zcrx: dmabuf backed zerocopy receive")
Cc: stable@vger.kernel.org
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 io_uring/zcrx.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 21e042b3ccb9..ed5e81434bd9 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -354,7 +354,7 @@ static void zcrx_sync_for_device(struct page_pool *pp, struct io_zcrx_ifq *zcrx,
 	unsigned i, niov_size;
 	dma_addr_t dma_addr;
 
-	if (!dma_dev_need_sync(dev))
+	if (!zcrx->kern_readable || !dma_dev_need_sync(dev))
 		return;
 	niov_size = 1U << zcrx->niov_shift;
 
@@ -1425,6 +1425,10 @@ static int io_pp_zc_init(struct page_pool *pp)
 	if (pp->p.dma_dir != DMA_FROM_DEVICE)
 		return -EOPNOTSUPP;
 
+	if (!ifq->kern_readable) {
+		pp->dma_sync_for_cpu = false;
+		pp->dma_sync = false;
+	}
 	refcount_inc(&ifq->refs);
 	return 0;
 }
-- 
2.56.1


             reply	other threads:[~2026-12-03 12:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 12:38 Pavel Begunkov [this message]
2026-12-04 22:03 ` [PATCH io_uring v2 1/1] io_uring/zcrx: don't sync dma-bufs Mina Almasry
2026-12-04 22:17 ` Jens Axboe

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=8e93a756a3b8fea2be7935d34e1b833fd98e40ea.1796301395.git.asml.silence@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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