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: stab…@vger.kernel.org Signed-off-by: Pavel Begunkov <asml…@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