From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf7qk-0006N7-Uh for qemu-devel@nongnu.org; Thu, 24 Sep 2015 10:50:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zf7qf-0007gv-Td for qemu-devel@nongnu.org; Thu, 24 Sep 2015 10:50:18 -0400 Received: from g2t4621.austin.hp.com ([15.73.212.80]:40265) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf7qe-0007Ye-CH for qemu-devel@nongnu.org; Thu, 24 Sep 2015 10:50:12 -0400 Received: from g1t6217.austin.hpicorp.net (g1t6217.austin.hpicorp.net [15.67.1.144]) by g2t4621.austin.hp.com (Postfix) with ESMTP id 1E526138 for ; Thu, 24 Sep 2015 14:50:05 +0000 (UTC) Received: from [10.152.32.166] (ospra1.fc.hp.com [16.79.38.118]) by g1t6217.austin.hpicorp.net (Postfix) with ESMTP id 6C94697 for ; Thu, 24 Sep 2015 14:50:05 +0000 (UTC) References: <1442563270-11615-1-git-send-email-jasowang@redhat.com> From: Andrew James Message-ID: <56040E01.5000906@hpe.com> Date: Thu, 24 Sep 2015 08:51:45 -0600 MIME-Version: 1.0 In-Reply-To: <1442563270-11615-1-git-send-email-jasowang@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/3] virtio: introduce virtqueue_unmap_sg() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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. >=20 > Cc: Michael S. Tsirkin > Signed-off-by: Jason Wang > --- > hw/virtio/virtio.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) >=20 > 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) =3D=3D vq->last_avail_idx; > } > =20 > -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; > =20 > - trace_virtqueue_fill(vq, elem, len, idx); > - > - offset =3D 0; > for (i =3D 0; i < elem->in_num; i++) { > size_t size =3D MIN(len - offset, elem->in_sg[i].iov_len); > =20 Should the "offset =3D 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 VirtQueue= Element *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); > =20 > idx =3D (idx + vring_used_idx(vq)) % vq->vring.num; > =20 >=20 Thanks, --=20 Andrew James