Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

virtio_net: fix the missing of the dma cpu sync

Commit 295525e29a5b ("virtio_net: merge dma operations when filling
mergeable buffers") unmaps the buffer with DMA_ATTR_SKIP_CPU_SYNC when
the dma->ref is zero. We do that with DMA_ATTR_SKIP_CPU_SYNC, because we
do not want to do the sync for the entire page_frag. But that misses the
sync for the current area.

This patch does cpu sync regardless of whether the ref is zero or not.

Fixes: 295525e29a5b ("virtio_net: merge dma operations when filling mergeable buffers")
Reported-by: Michael Roth <michael.roth@amd.com>
Closes: http://lore.kernel.org/all/20230926130451.axgodaa6tvwqs3ut@amd.com
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Xuan Zhuo and committed by
Linus Torvalds
5720c43d 11d3f726

+8 -8
+8 -8
drivers/net/virtio_net.c
··· 607 607 608 608 --dma->ref; 609 609 610 - if (dma->ref) { 611 - if (dma->need_sync && len) { 612 - offset = buf - (head + sizeof(*dma)); 610 + if (dma->need_sync && len) { 611 + offset = buf - (head + sizeof(*dma)); 613 612 614 - virtqueue_dma_sync_single_range_for_cpu(rq->vq, dma->addr, offset, 615 - len, DMA_FROM_DEVICE); 616 - } 617 - 618 - return; 613 + virtqueue_dma_sync_single_range_for_cpu(rq->vq, dma->addr, 614 + offset, len, 615 + DMA_FROM_DEVICE); 619 616 } 617 + 618 + if (dma->ref) 619 + return; 620 620 621 621 virtqueue_dma_unmap_single_attrs(rq->vq, dma->addr, dma->len, 622 622 DMA_FROM_DEVICE, DMA_ATTR_SKIP_CPU_SYNC);