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 <[email protected]>





> ---
>  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


Reply via email to