qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrew James <andrew.james@hpe.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/3] virtio: introduce virtqueue_unmap_sg()
Date: Thu, 24 Sep 2015 08:51:45 -0600	[thread overview]
Message-ID: <56040E01.5000906@hpe.com> (raw)
In-Reply-To: <1442563270-11615-1-git-send-email-jasowang@redhat.com>

On 09/18/2015 02:01 AM, Jason Wang wrote:
> Factor out sg unmapping logic. This will be reused by the patch that
> can discard descriptor.
> 
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  hw/virtio/virtio.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 0832db9..eb8d5ca 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -243,15 +243,12 @@ int virtio_queue_empty(VirtQueue *vq)
>      return vring_avail_idx(vq) == vq->last_avail_idx;
>  }
>  
> -void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
> -                    unsigned int len, unsigned int idx)
> +static void virtqueue_unmap_sg(VirtQueue *vq, const VirtQueueElement *elem,
> +                               unsigned int len)
>  {
>      unsigned int offset;
>      int i;
>  
> -    trace_virtqueue_fill(vq, elem, len, idx);
> -
> -    offset = 0;
>      for (i = 0; i < elem->in_num; i++) {
>          size_t size = MIN(len - offset, elem->in_sg[i].iov_len);
>  

Should the "offset = 0" really be dropped here? Seems like it ends
up uninitialized. GCC thinks it might too.

> @@ -266,6 +263,14 @@ void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
>          cpu_physical_memory_unmap(elem->out_sg[i].iov_base,
>                                    elem->out_sg[i].iov_len,
>                                    0, elem->out_sg[i].iov_len);
> +}
> +
> +void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
> +                    unsigned int len, unsigned int idx)
> +{
> +    trace_virtqueue_fill(vq, elem, len, idx);
> +
> +    virtqueue_unmap_sg(vq, elem, len);
>  
>      idx = (idx + vring_used_idx(vq)) % vq->vring.num;
>  
> 

Thanks,
-- 
Andrew James

  parent reply	other threads:[~2015-09-24 14:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-18  8:01 [Qemu-devel] [PATCH 1/3] virtio: introduce virtqueue_unmap_sg() Jason Wang
2015-09-18  8:01 ` [Qemu-devel] [PATCH 2/3] virtio: introduce virtqueue_discard() Jason Wang
2015-09-18  8:01 ` [Qemu-devel] [PATCH 3/3] virtio-net: correctly drop truncated packets Jason Wang
2015-09-24 14:51 ` Andrew James [this message]
2015-09-24 16:19 ` [Qemu-devel] [PATCH 1/3] virtio: introduce virtqueue_unmap_sg() Andrew James
2015-09-25  3:27   ` Jason Wang

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=56040E01.5000906@hpe.com \
    --to=andrew.james@hpe.com \
    --cc=qemu-devel@nongnu.org \
    /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 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).