Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 284241
b: refs/heads/master
c: ee7cd89
h: refs/heads/master
i:
  284239: b8de77c
v: v3
  • Loading branch information
Rusty Russell committed Jan 12, 2012
1 parent 59bb092 commit a04fe85
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 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: 3b720b8c865098c49c1570b6b5c7832bcfa6e6c2
refs/heads/master: ee7cd8981e15bcb365fc762afe3fc47b8242f630
20 changes: 14 additions & 6 deletions trunk/drivers/virtio/virtio_ring.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,20 @@ int virtqueue_add_buf(struct virtqueue *_vq,

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

/* Descriptors and available array need to be set before we expose the
* new available array entries. */
virtio_wmb(vq);
vq->vring.avail->idx++;
vq->num_added++;

/* This is very unlikely, but theoretically possible. Kick
* just in case. */
if (unlikely(vq->num_added == (1 << 16) - 1))
virtqueue_kick(_vq);

pr_debug("Added buffer head %i to %p\n", head, vq);
END_USE(vq);

Expand Down Expand Up @@ -283,13 +294,10 @@ bool virtqueue_kick_prepare(struct virtqueue *_vq)
* new available array entries. */
virtio_wmb(vq);

old = vq->vring.avail->idx;
new = vq->vring.avail->idx = old + vq->num_added;
old = vq->vring.avail->idx - vq->num_added;
new = vq->vring.avail->idx;
vq->num_added = 0;

/* Need to update avail index before checking if we should notify */
virtio_mb(vq);

if (vq->event) {
needs_kick = vring_need_event(vring_avail_event(&vq->vring),
new, old);
Expand Down

0 comments on commit a04fe85

Please sign in to comment.