aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-12-07 11:03:49 -0500
committerMichael S. Tsirkin <mst@redhat.com>2014-12-09 14:42:02 -0500
commit5386cef200ae0ac79cdcd160772989e8f5c47a4f (patch)
tree9eff248d3274fbf586a9221f10a28be8387ff3c1
parentf30eaf4a09482c8dad0f65c616de10a2321839c9 (diff)
virtio_pci: delete vqs indirectly
VQ deletion is mostly version-specific, add another level of indirection to split the version-independent code out. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--drivers/virtio/virtio_pci.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 7b82eb5c0c5a..133978c6bd85 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -81,6 +81,8 @@ struct virtio_pci_device {
81 81
82 /* Whether we have vector per vq */ 82 /* Whether we have vector per vq */
83 bool per_vq_vectors; 83 bool per_vq_vectors;
84
85 void (*del_vq)(struct virtio_pci_vq_info *info);
84}; 86};
85 87
86/* Constants for MSI-X */ 88/* Constants for MSI-X */
@@ -468,15 +470,11 @@ out_info:
468 return ERR_PTR(err); 470 return ERR_PTR(err);
469} 471}
470 472
471static void vp_del_vq(struct virtqueue *vq) 473static void del_vq(struct virtio_pci_vq_info *info)
472{ 474{
475 struct virtqueue *vq = info->vq;
473 struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev); 476 struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev);
474 struct virtio_pci_vq_info *info = vp_dev->vqs[vq->index]; 477 unsigned long size;
475 unsigned long flags, size;
476
477 spin_lock_irqsave(&vp_dev->lock, flags);
478 list_del(&info->node);
479 spin_unlock_irqrestore(&vp_dev->lock, flags);
480 478
481 iowrite16(vq->index, vp_dev->ioaddr + VIRTIO_PCI_QUEUE_SEL); 479 iowrite16(vq->index, vp_dev->ioaddr + VIRTIO_PCI_QUEUE_SEL);
482 480
@@ -494,6 +492,19 @@ static void vp_del_vq(struct virtqueue *vq)
494 492
495 size = PAGE_ALIGN(vring_size(info->num, VIRTIO_PCI_VRING_ALIGN)); 493 size = PAGE_ALIGN(vring_size(info->num, VIRTIO_PCI_VRING_ALIGN));
496 free_pages_exact(info->queue, size); 494 free_pages_exact(info->queue, size);
495}
496
497static void vp_del_vq(struct virtqueue *vq)
498{
499 struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev);
500 struct virtio_pci_vq_info *info = vp_dev->vqs[vq->index];
501 unsigned long flags;
502
503 spin_lock_irqsave(&vp_dev->lock, flags);
504 list_del(&info->node);
505 spin_unlock_irqrestore(&vp_dev->lock, flags);
506
507 vp_dev->del_vq(info);
497 kfree(info); 508 kfree(info);
498} 509}
499 510
@@ -737,6 +748,8 @@ static int virtio_pci_probe(struct pci_dev *pci_dev,
737 vp_dev->vdev.id.vendor = pci_dev->subsystem_vendor; 748 vp_dev->vdev.id.vendor = pci_dev->subsystem_vendor;
738 vp_dev->vdev.id.device = pci_dev->subsystem_device; 749 vp_dev->vdev.id.device = pci_dev->subsystem_device;
739 750
751 vp_dev->del_vq = del_vq;
752
740 /* finally register the virtio device */ 753 /* finally register the virtio device */
741 err = register_virtio_device(&vp_dev->vdev); 754 err = register_virtio_device(&vp_dev->vdev);
742 if (err) 755 if (err)