Re: [PATCH 2/4] virtio_net: pass well-formed sg to virtqueue_add_inbuf()

Michael S. Tsirkin
2014-05-29T11:07:07Z

On Thu, May 29, 2014 at 04:56:43PM +0930, Rusty Russell wrote:
> This is the only place which doesn't hand virtqueue_add_inbuf or
> virtqueue_add_outbuf a well-formed, well-terminated sg. Fix it,
> so we can make virtio_add_* simpler.
>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> ---
> drivers/net/virtio_net.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 8a852b5f215f..63299b04cdf2 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -590,6 +590,8 @@ static int add_recvbuf_big(struct receive_queue *rq, gfp_t gfp)
> offset = sizeof(struct padded_vnet_hdr);
> sg_set_buf(&rq->sg[1], p + offset, PAGE_SIZE - offset);
>
> + sg_mark_end(&rq->sg[MAX_SKB_FRAGS + 2 - 1]);
> +
> /* chain first in list head */
> first->private = (unsigned long)list;
> err = virtqueue_add_inbuf(rq->vq, rq->sg, MAX_SKB_FRAGS + 2,

Not that performance of add_recvbuf_big actually mattered anymore, but
in fact this can be done in virtnet_probe if we like.

Anyway

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> --
> 1.9.1