diff --git a/lib/include/openamp/virtio.h b/lib/include/openamp/virtio.h index b5e40b182..1e37e4411 100644 --- a/lib/include/openamp/virtio.h +++ b/lib/include/openamp/virtio.h @@ -136,29 +136,7 @@ struct virtio_device_id { #define VIRTIO_ASSERT(_exp, _msg) metal_assert(_exp) #endif /* VIRTIO_DEBUG */ -#define VRING_ALIGNMENT 4096 - -#define VIRTIO_RING_SIZE(n, align) \ - (( \ - ( \ - sizeof(struct vring_desc) * n + \ - sizeof(struct vring_avail) + \ - sizeof(uint16_t) * (n + 1) + \ - align - 1 \ - ) \ - & ~(align - 1) \ - ) + \ - sizeof(struct vring_used) + \ - sizeof(struct vring_used_elem) * n + sizeof(uint16_t)) - -#define VRING_DECLARE(name, n, align) \ -static char __vrbuf_##name[VIRTIO_RING_SIZE(n, align)] __aligned(VRING_ALIGNMENT); \ -static struct vring __vring_##name = { \ - .desc = (void *)__vrbuf_##name, \ - .avail = (void *)((unsigned long)__vrbuf_##name + n * sizeof(struct vring_desc)), \ - .used = (void *)((unsigned long)__vrbuf_##name + ((n * sizeof(struct vring_desc) + \ - (n + 1) * sizeof(uint16_t) + align - 1) & ~(align - 1))), \ -} +#define VIRTIO_MMIO_VRING_ALIGNMENT 4096 typedef void (*virtio_dev_reset_cb)(struct virtio_device *vdev); diff --git a/lib/virtio_mmio/virtio_mmio_drv.c b/lib/virtio_mmio/virtio_mmio_drv.c index 606486606..5f42180a6 100644 --- a/lib/virtio_mmio/virtio_mmio_drv.c +++ b/lib/virtio_mmio/virtio_mmio_drv.c @@ -286,7 +286,7 @@ struct virtqueue *virtio_mmio_setup_virtqueue(struct virtio_device *vdev, vring_info->io = vmdev->shm_io; vring_info->info.num_descs = virtio_mmio_get_max_elem(vdev, idx); - vring_info->info.align = VRING_ALIGNMENT; + vring_info->info.align = VIRTIO_MMIO_VRING_ALIGNMENT; /* Check if vrings are already configured */ if (vq->vq_nentries != 0 && vq->vq_nentries == vq->vq_free_cnt &&