Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 284240
b: refs/heads/master
c: 3b720b8
h: refs/heads/master
v: v3
  • Loading branch information
Rusty Russell committed Jan 12, 2012
1 parent b8de77c commit 59bb092
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 41f0377f73039ca6fe97a469d1941a89cd9757f1
refs/heads/master: 3b720b8c865098c49c1570b6b5c7832bcfa6e6c2
10 changes: 6 additions & 4 deletions trunk/drivers/virtio/virtio_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ int virtqueue_add_buf(struct virtqueue *_vq,
vq->data[head] = data;

/* Put entry in available array (but don't update avail->idx until they
* do sync). FIXME: avoid modulus here? */
avail = (vq->vring.avail->idx + vq->num_added++) % vq->vring.num;
* do sync). */
avail = ((vq->vring.avail->idx + vq->num_added++) & (vq->vring.num-1));
vq->vring.avail->ring[avail] = head;

pr_debug("Added buffer head %i to %p\n", head, vq);
Expand Down Expand Up @@ -384,6 +384,7 @@ void *virtqueue_get_buf(struct virtqueue *_vq, unsigned int *len)
struct vring_virtqueue *vq = to_vvq(_vq);
void *ret;
unsigned int i;
u16 last_used;

START_USE(vq);

Expand All @@ -401,8 +402,9 @@ void *virtqueue_get_buf(struct virtqueue *_vq, unsigned int *len)
/* Only get used array entries after they have been exposed by host. */
virtio_rmb(vq);

i = vq->vring.used->ring[vq->last_used_idx%vq->vring.num].id;
*len = vq->vring.used->ring[vq->last_used_idx%vq->vring.num].len;
last_used = (vq->last_used_idx & (vq->vring.num - 1));
i = vq->vring.used->ring[last_used].id;
*len = vq->vring.used->ring[last_used].len;

if (unlikely(i >= vq->vring.num)) {
BAD_RING(vq, "id %u out of range\n", i);
Expand Down

0 comments on commit 59bb092

Please sign in to comment.