From patchwork Thu Mar 17 12:20:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 641361 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2HCL5Xd026533 for ; Thu, 17 Mar 2011 12:21:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753942Ab1CQMU5 (ORCPT ); Thu, 17 Mar 2011 08:20:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16146 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753257Ab1CQMU4 (ORCPT ); Thu, 17 Mar 2011 08:20:56 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2HCKn49014106 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 17 Mar 2011 08:20:49 -0400 Received: from redhat.com (vpn2-8-223.ams2.redhat.com [10.36.8.223]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id p2HCKjDr022027; Thu, 17 Mar 2011 08:20:46 -0400 Date: Thu, 17 Mar 2011 14:20:37 +0200 From: "Michael S. Tsirkin" To: Shirley Ma Cc: Rusty Russell , Tom Lendacky , Krishna Kumar2 , David Miller , kvm@vger.kernel.org, netdev@vger.kernel.org, steved@us.ibm.com, jasowang@redhat.com Subject: Re: [PATCH 1/2] virtio: put last seen used index into ring itself Message-ID: <20110317122035.GA15902@redhat.com> References: <1300148495.11514.1.camel@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1300148495.11514.1.camel@localhost.localdomain> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 17 Mar 2011 12:21:05 +0000 (UTC) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index a6fc537..a84b056 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -280,7 +280,7 @@ static void detach_buf(struct vring_virtqueue *vq, unsigned int head) static inline bool more_used(const struct vring_virtqueue *vq) { - return vring_last_used(vq) != vq->vring.used->idx; + return vring_last_used(&vq->vring) != vq->vring.used->idx; } void *virtqueue_get_buf(struct virtqueue *_vq, unsigned int *len) @@ -306,7 +306,7 @@ void *virtqueue_get_buf(struct virtqueue *_vq, unsigned int *len) /* Only get used array entries after they have been exposed by host. */ virtio_rmb(); - u = &vq->vring.used->ring[vring_last_used(vq) % vq->vring.num]; + u = &vq->vring.used->ring[vring_last_used(&vq->vring) % vq->vring.num]; i = u->id; *len = u->len; if (unlikely(i >= vq->vring.num)) { @@ -321,7 +321,7 @@ void *virtqueue_get_buf(struct virtqueue *_vq, unsigned int *len) /* detach_buf clears data, so grab it now. */ ret = vq->data[i]; detach_buf(vq, i); - (vring_last_used(vq))++; + (vring_last_used(&vq->vring))++; /* If we expect an interrupt for the next entry, flush out * last used index write. */ if (!(vq->vring.avail->flags & VRING_AVAIL_F_NO_INTERRUPT)) @@ -434,7 +434,7 @@ struct virtqueue *vring_new_virtqueue(unsigned int num, vq->vq.name = name; vq->notify = notify; vq->broken = false; - vring_last_used(vq) = 0; + vring_last_used(&vq->vring) = 0; vq->num_added = 0; list_add_tail(&vq->vq.list, &vdev->vqs); #ifdef DEBUG diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h index 4587ea2..462756d 100644 --- a/include/linux/virtio_ring.h +++ b/include/linux/virtio_ring.h @@ -100,7 +100,7 @@ struct vring { /* We publish the last-seen used index at the end of the available ring. * It is at the end for backwards compatibility. */ -#define vring_last_used(vr) ((vr)->avail->ring[num]) +#define vring_last_used(vr) ((vr)->avail->ring[(vr)->num]) static inline void vring_init(struct vring *vr, unsigned int num, void *p, unsigned long align) {