From: Wang Sheng-Hui Date: Mon, 29 Aug 2011 07:55:59 +0000 (+0800) Subject: virtio: modify vring_init and vring_size to take account of the layout containing... X-Git-Tag: next-20110831~45^2 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=5e7a6e8040d4fec2133df61647d8026ceb866fb9;p=karo-tx-linux.git 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 Signed-off-by: Rusty Russell --- 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; }