Commit e8762a41 authored by Dariusz Stojaczyk's avatar Dariusz Stojaczyk Committed by Ben Walker
Browse files

virtio/pci: make sure each queue is physically contiguous



The spdk_dma_zmalloc guarantee about physical memory contiguity
is about to be removed soon. For hardware rings that require
physical memory or IOVA contiguity we will now enforce hugepage
alignment and size restrictions to make sure they occupy only
a single hugepage.

Change-Id: I8f44ad6f33d60f01403cc3db693497e4f722e528
Signed-off-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/418612


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 9166bb3c
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -264,7 +264,15 @@ modern_setup_queue(struct virtio_dev *dev, struct virtqueue *vq)
	void *queue_mem;
	uint64_t queue_mem_phys_addr;

	queue_mem = spdk_dma_zmalloc(vq->vq_ring_size, VIRTIO_PCI_VRING_ALIGN, &queue_mem_phys_addr);
	/* To ensure physical address contiguity we make the queue occupy
	 * only a single hugepage (2MB). As of Virtio 1.0, the queue size
	 * always falls within this limit.
	 */
	if (vq->vq_ring_size > 0x200000) {
		return -ENOMEM;
	}

	queue_mem = spdk_dma_zmalloc(vq->vq_ring_size, 0x200000, &queue_mem_phys_addr);
	if (queue_mem == NULL) {
		return -ENOMEM;
	}