Skip to contentSkip to conversation

virtio-pci: use possible fallback queue size

PATCH New Liang Chen 1 participant 1 message Mar 22, 2016

Subsystems (2)
lore
Share & tools
lore

Liang Chen

author
#0 lore raw

PATCH 1/1 virtio-pci: use possible fallback queue size

Virtio 1.0 spec allows driver to modify queue size to reduce momery requeirments. So the driver should write back the queue size actually allocated, instead of the original value read from the common config for the queue.

---
 drivers/virtio/virtio_pci_common.h | 2 +-
 drivers/virtio/virtio_pci_modern.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/virtio/virtio_pci_common.h +1 -1
index 2cc2522..32ee993 100644
@@ -36,7 +36,7 @@ struct virtio_pci_vq_info {
 	struct virtqueue *vq;
 
 	/* the number of entries in the queue */
-	int num;
+	u16 num;
 
 	/* the virtual address of the ring queue */
 	void *queue;
drivers/virtio/virtio_pci_modern.c +2 -2
index 7760fc1..7f9ccac 100644
@@ -293,7 +293,7 @@ static size_t vring_pci_size(u16 num)
 	return PAGE_ALIGN(vring_size(num, SMP_CACHE_BYTES));
 }
 
-static void *alloc_virtqueue_pages(int *num)
+static void *alloc_virtqueue_pages(u16 *num)
 {
 	void *pages;
 
@@ -360,7 +360,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
 	}
 
 	/* activate the queue */
-	vp_iowrite16(num, &cfg->queue_size);
+	vp_iowrite16(info->num, &cfg->queue_size);
 	vp_iowrite64_twopart(virt_to_phys(info->queue),
 			     &cfg->queue_desc_lo, &cfg->queue_desc_hi);
 	vp_iowrite64_twopart(virt_to_phys(virtqueue_get_avail(vq)),
Signature · 1 line
1.9.1