summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWang Sheng-Hui <shhuiw@gmail.com>2011-08-29 15:55:59 +0800
committerRusty Russell <rusty@rustcorp.com.au>2011-11-02 11:40:59 +1030
commit00b894e874581f6b388c5817d4d5546c22cf9640 (patch)
tree18cf5e1b2067986b36996dc75321cea7c9935ac2
parent5f41f8bfc95e84536207b2af8918f2e674164a42 (diff)
downloadlwn-00b894e874581f6b388c5817d4d5546c22cf9640.tar.gz
lwn-00b894e874581f6b388c5817d4d5546c22cf9640.zip
virtio: modify vring_init and vring_size to take account of the layout containing *_event_idx
Based on the layout description in the comments, take account of the *_event_idx in functions vring_init and vring_size. Signed-off-by: Wang Sheng-Hui <shhuiw@gmail.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r--include/linux/virtio_ring.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
index 4a32cb6da425..36be0f6e18a9 100644
--- a/include/linux/virtio_ring.h
+++ b/include/linux/virtio_ring.h
@@ -135,13 +135,13 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p,
vr->num = num;
vr->desc = p;
vr->avail = p + num*sizeof(struct vring_desc);
- vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + align-1)
- & ~(align - 1));
+ vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + sizeof(__u16)
+ + align-1) & ~(align - 1));
}
static inline unsigned vring_size(unsigned int num, unsigned long align)
{
- return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (2 + num)
+ return ((sizeof(struct vring_desc) * num + sizeof(__u16) * (3 + num)
+ align - 1) & ~(align - 1))
+ sizeof(__u16) * 3 + sizeof(struct vring_used_elem) * num;
}