Skip to content

Commit

Permalink
virtio_net: fix the missing of the dma cpu sync
Browse files Browse the repository at this point in the history
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 <[email protected]>
Closes: http://lore.kernel.org/all/[email protected]
Signed-off-by: Xuan Zhuo <[email protected]>
Acked-by: Jason Wang <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
fengidri authored and torvalds committed Oct 15, 2023
1 parent 11d3f72 commit 5720c43
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,16 +607,16 @@ static void virtnet_rq_unmap(struct receive_queue *rq, void *buf, u32 len)

--dma->ref;

if (dma->ref) {
if (dma->need_sync && len) {
offset = buf - (head + sizeof(*dma));
if (dma->need_sync && len) {
offset = buf - (head + sizeof(*dma));

virtqueue_dma_sync_single_range_for_cpu(rq->vq, dma->addr, offset,
len, DMA_FROM_DEVICE);
}
virtqueue_dma_sync_single_range_for_cpu(rq->vq, dma->addr,
offset, len,
DMA_FROM_DEVICE);
}

if (dma->ref)
return;
}

virtqueue_dma_unmap_single_attrs(rq->vq, dma->addr, dma->len,
DMA_FROM_DEVICE, DMA_ATTR_SKIP_CPU_SYNC);
Expand Down

0 comments on commit 5720c43

Please sign in to comment.