From: "Michael S. Tsirkin" <mst@redhat.com>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: netdev@vger.kernel.org, "Jason Wang" <jasowang@redhat.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
virtualization@lists.linux.dev
Subject: Re: [PATCH net] virtio-net: correct DMA unmap vq mismatch in virtnet_xsk_pool_enable()
Date: Fri, 20 Mar 2026 05:45:58 -0400 [thread overview]
Message-ID: <20260320054334-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20260320013531.36931-1-xuanzhuo@linux.alibaba.com>
Patch itself is fine, thanks!
Yet something to improve in the log:
On Fri, Mar 20, 2026 at 09:35:31AM +0800, Xuan Zhuo wrote:
> When enabling the XSK pool, the header DMA address is mapped against
> the send queue's virtqueue (sq->vq). However, the error handling path
> incorrectly attempts to unmap it against the receive queue's virtqueue
> (rq->vq).
>
> Ensure the unmap operation uses the same virtqueue used for mapping to
> maintain DMA API consistency.
DMA API is fine: we end up with:
void virtqueue_unmap_page_attrs(const struct virtqueue *_vq,
dma_addr_t map_handle,
size_t size, enum dma_data_direction dir,
unsigned long attrs)
{
const struct vring_virtqueue *vq = to_vvq(_vq);
struct virtio_device *vdev = _vq->vdev;
if (vdev->map)
vdev->map->unmap_page(vq->map,
map_handle, size, dir, attrs);
else
dma_unmap_page_attrs(vring_dma_dev(vq), map_handle,
size, dir, attrs);
}
EXPORT_SYMBOL_GPL(virtqueue_unmap_page_attrs);
So what matters is the device and it's the same for all vqs.
A better way to put it:
While harmless (both vqs share the same device for DMA) it is cleaner
to map and unmap using the same vq.
> Fixes: 21a4e3ce6dc7 ("virtio_net: xsk: bind/unbind xsk for tx")
And I'd drop the fixes tag.
> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
> ---
> drivers/net/virtio_net.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 72d6a9c6a5a2..7c6f304b7be5 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -5917,7 +5917,7 @@ static int virtnet_xsk_pool_enable(struct net_device *dev,
> err_rq:
> xsk_pool_dma_unmap(pool, 0);
> err_xsk_map:
> - virtqueue_unmap_single_attrs(rq->vq, hdr_dma, vi->hdr_len,
> + virtqueue_unmap_single_attrs(sq->vq, hdr_dma, vi->hdr_len,
> DMA_TO_DEVICE, 0);
> err_free_buffs:
> kvfree(rq->xsk_buffs);
> --
> 2.32.0.3.g01195cf9f
prev parent reply other threads:[~2026-03-20 9:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 1:35 [PATCH net] virtio-net: correct DMA unmap vq mismatch in virtnet_xsk_pool_enable() Xuan Zhuo
2026-03-20 9:45 ` Michael S. Tsirkin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260320054334-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.