aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/virtio
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-12-07 11:18:09 -0500
committerMichael S. Tsirkin <mst@redhat.com>2014-12-09 14:42:04 -0500
commit6f8f23d63d57c8d93d699fc015eba9bf144479e9 (patch)
treef4bdadbffb15731254fc2fa21d023509be8feb5c /drivers/virtio
parentb09f00bbfe8755c0de9e4950816f4b283ddbca16 (diff)
virtio_pci: setup config vector indirectly
config vector setup is version specific, do it indirectly. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers/virtio')
-rw-r--r--drivers/virtio/virtio_pci.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/virtio/virtio_pci.c b/drivers/virtio/virtio_pci.c
index 68023e509fcc..4de3cbc0746d 100644
--- a/drivers/virtio/virtio_pci.c
+++ b/drivers/virtio/virtio_pci.c
@@ -89,6 +89,7 @@ struct virtio_pci_device {
89 const char *name, 89 const char *name,
90 u16 msix_vec); 90 u16 msix_vec);
91 void (*del_vq)(struct virtio_pci_vq_info *info); 91 void (*del_vq)(struct virtio_pci_vq_info *info);
92 u16 (*config_vector)(struct virtio_pci_device *vp_dev, u16 vector);
92}; 93};
93 94
94/* Constants for MSI-X */ 95/* Constants for MSI-X */
@@ -271,6 +272,15 @@ static irqreturn_t vp_interrupt(int irq, void *opaque)
271 return vp_vring_interrupt(irq, opaque); 272 return vp_vring_interrupt(irq, opaque);
272} 273}
273 274
275static u16 vp_config_vector(struct virtio_pci_device *vp_dev, u16 vector)
276{
277 /* Setup the vector used for configuration events */
278 iowrite16(vector, vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR);
279 /* Verify we had enough resources to assign the vector */
280 /* Will also flush the write out to device */
281 return ioread16(vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR);
282}
283
274static void vp_free_vectors(struct virtio_device *vdev) 284static void vp_free_vectors(struct virtio_device *vdev)
275{ 285{
276 struct virtio_pci_device *vp_dev = to_vp_device(vdev); 286 struct virtio_pci_device *vp_dev = to_vp_device(vdev);
@@ -290,10 +300,7 @@ static void vp_free_vectors(struct virtio_device *vdev)
290 300
291 if (vp_dev->msix_enabled) { 301 if (vp_dev->msix_enabled) {
292 /* Disable the vector used for configuration */ 302 /* Disable the vector used for configuration */
293 iowrite16(VIRTIO_MSI_NO_VECTOR, 303 vp_dev->config_vector(vp_dev, VIRTIO_MSI_NO_VECTOR);
294 vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR);
295 /* Flush the write out to device */
296 ioread16(vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR);
297 304
298 pci_disable_msix(vp_dev->pci_dev); 305 pci_disable_msix(vp_dev->pci_dev);
299 vp_dev->msix_enabled = 0; 306 vp_dev->msix_enabled = 0;
@@ -357,9 +364,8 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
357 goto error; 364 goto error;
358 ++vp_dev->msix_used_vectors; 365 ++vp_dev->msix_used_vectors;
359 366
360 iowrite16(v, vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR); 367 v = vp_dev->config_vector(vp_dev, v);
361 /* Verify we had enough resources to assign the vector */ 368 /* Verify we had enough resources to assign the vector */
362 v = ioread16(vp_dev->ioaddr + VIRTIO_MSI_CONFIG_VECTOR);
363 if (v == VIRTIO_MSI_NO_VECTOR) { 369 if (v == VIRTIO_MSI_NO_VECTOR) {
364 err = -EBUSY; 370 err = -EBUSY;
365 goto error; 371 goto error;
@@ -770,6 +776,7 @@ static int virtio_pci_probe(struct pci_dev *pci_dev,
770 vp_dev->vdev.id.vendor = pci_dev->subsystem_vendor; 776 vp_dev->vdev.id.vendor = pci_dev->subsystem_vendor;
771 vp_dev->vdev.id.device = pci_dev->subsystem_device; 777 vp_dev->vdev.id.device = pci_dev->subsystem_device;
772 778
779 vp_dev->config_vector = vp_config_vector;
773 vp_dev->setup_vq = setup_vq; 780 vp_dev->setup_vq = setup_vq;
774 vp_dev->del_vq = del_vq; 781 vp_dev->del_vq = del_vq;
775 782