* [PATCH vhost] virtio_net: fix the missing of the dma cpu sync
@ 2023-09-27 5:52 Xuan Zhuo
2023-10-08 4:53 ` Jason Wang
0 siblings, 1 reply; 2+ messages in thread
From: Xuan Zhuo @ 2023-09-27 5:52 UTC (permalink / raw)
To: virtualization
Cc: Michael S. Tsirkin, Jason Wang, Xuan Zhuo, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, Michael Roth
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>
---
drivers/net/virtio_net.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 98dc9b49d56b..9ece27dc5144 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -589,16 +589,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);
--
2.32.0.3.g01195cf9f
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH vhost] virtio_net: fix the missing of the dma cpu sync
2023-09-27 5:52 [PATCH vhost] virtio_net: fix the missing of the dma cpu sync Xuan Zhuo
@ 2023-10-08 4:53 ` Jason Wang
0 siblings, 0 replies; 2+ messages in thread
From: Jason Wang @ 2023-10-08 4:53 UTC (permalink / raw)
To: Xuan Zhuo
Cc: virtualization, Michael S. Tsirkin, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, Michael Roth
On Wed, Sep 27, 2023 at 1:53 PM Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
>
> 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>
Thanks
> ---
> drivers/net/virtio_net.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 98dc9b49d56b..9ece27dc5144 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -589,16 +589,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);
> --
> 2.32.0.3.g01195cf9f
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-08 4:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-27 5:52 [PATCH vhost] virtio_net: fix the missing of the dma cpu sync Xuan Zhuo
2023-10-08 4:53 ` Jason Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).