Skip to content

Commit 5720c43

Browse files
fengidritorvalds
authored andcommitted
virtio_net: fix the missing of the dma cpu sync
Commit 295525e ("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: 295525e ("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>
1 parent 11d3f72 commit 5720c43

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/net/virtio_net.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -607,16 +607,16 @@ static void virtnet_rq_unmap(struct receive_queue *rq, void *buf, u32 len)
607607

608608
--dma->ref;
609609

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));
613612

614-
virtqueue_dma_sync_single_range_for_cpu(rq->vq, dma->addr, offset,
615-
len, DMA_FROM_DEVICE);
616-
}
613+
virtqueue_dma_sync_single_range_for_cpu(rq->vq, dma->addr,
614+
offset, len,
615+
DMA_FROM_DEVICE);
616+
}
617617

618+
if (dma->ref)
618619
return;
619-
}
620620

621621
virtqueue_dma_unmap_single_attrs(rq->vq, dma->addr, dma->len,
622622
DMA_FROM_DEVICE, DMA_ATTR_SKIP_CPU_SYNC);

0 commit comments

Comments
 (0)