Subject: Re: [PATCH vhost 12/22] virtio_net: xsk: bind/unbind xsk

From: Simon Horman <[email-masked]>
Date: Sun, 15 Oct 2023 21:17:56 +0200

On Wed, Oct 11, 2023 at 05:27:18PM +0800, Xuan Zhuo wrote:

...

> +static int virtnet_xsk_pool_disable(struct net_device *dev, u16 qid)
> +{
> +	struct virtnet_info *vi = netdev_priv(dev);
> +	struct device *dma_dev;
> +	struct virtnet_rq *rq;
> +	struct virtnet_sq *sq;
> +	int err1, err2;
> +
> +	if (qid >= vi->curr_queue_pairs)
> +		return -EINVAL;
> +
> +	sq = &vi->sq[qid];
> +	rq = &vi->rq[qid];
> +
> +	dma_dev = virtqueue_dma_dev(rq->vq);
> +
> +	dma_unmap_single(dma_dev, sq->xsk.hdr_dma_address, vi->hdr_len, DMA_TO_DEVICE);
> +
> +	xsk_pool_dma_unmap(sq->xsk.pool, 0);

nit: the line above makes Sparse a bit unhappy:

 .../xsk.c:168:35: warning: incorrect type in argument 1 (different address spaces)
 .../xsk.c:168:35:    expected struct xsk_buff_pool *pool
 .../xsk.c:168:35:    got struct xsk_buff_pool [noderef] __rcu *pool

> +
> +	/* Sync with the XSK wakeup and with NAPI. */
> +	synchronize_net();
> +
> +	err1 = virtnet_sq_bind_xsk_pool(vi, sq, NULL);
> +	err2 = virtnet_rq_bind_xsk_pool(vi, rq, NULL);
> +
> +	return err1 | err2;
> +}

...