diff options
author | Christoph Hellwig <hch@lst.de> | 2017-08-24 12:07:02 -0400 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2017-08-25 14:38:26 -0400 |
commit | ba74b6f7fcc07355d087af6939712eed4a454821 (patch) | |
tree | 2bf5ad11505220311429dc6f0403d5765b3ff624 | |
parent | 1046d304900cf9d4b2c730c6860b8e03cc704377 (diff) |
virtio_pci: fix cpu affinity support
Commit 0b0f9dc5 ("Revert "virtio_pci: use shared interrupts for
virtqueues"") removed the adjustment of the pre_vectors for the virtio
MSI-X vector allocation which was added in commit fb5e31d9 ("virtio:
allow drivers to request IRQ affinity when creating VQs"). This will
lead to an incorrect assignment of MSI-X vectors, and potential
deadlocks when offlining cpus.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Fixes: 0b0f9dc5 ("Revert "virtio_pci: use shared interrupts for virtqueues")
Reported-by: YASUAKI ISHIMATSU <yasu.isimatu@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r-- | drivers/virtio/virtio_pci_common.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c index 007a4f366086..1c4797e53f68 100644 --- a/drivers/virtio/virtio_pci_common.c +++ b/drivers/virtio/virtio_pci_common.c | |||
@@ -107,6 +107,7 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors, | |||
107 | { | 107 | { |
108 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); | 108 | struct virtio_pci_device *vp_dev = to_vp_device(vdev); |
109 | const char *name = dev_name(&vp_dev->vdev.dev); | 109 | const char *name = dev_name(&vp_dev->vdev.dev); |
110 | unsigned flags = PCI_IRQ_MSIX; | ||
110 | unsigned i, v; | 111 | unsigned i, v; |
111 | int err = -ENOMEM; | 112 | int err = -ENOMEM; |
112 | 113 | ||
@@ -126,10 +127,13 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors, | |||
126 | GFP_KERNEL)) | 127 | GFP_KERNEL)) |
127 | goto error; | 128 | goto error; |
128 | 129 | ||
130 | if (desc) { | ||
131 | flags |= PCI_IRQ_AFFINITY; | ||
132 | desc->pre_vectors++; /* virtio config vector */ | ||
133 | } | ||
134 | |||
129 | err = pci_alloc_irq_vectors_affinity(vp_dev->pci_dev, nvectors, | 135 | err = pci_alloc_irq_vectors_affinity(vp_dev->pci_dev, nvectors, |
130 | nvectors, PCI_IRQ_MSIX | | 136 | nvectors, flags, desc); |
131 | (desc ? PCI_IRQ_AFFINITY : 0), | ||
132 | desc); | ||
133 | if (err < 0) | 137 | if (err < 0) |
134 | goto error; | 138 | goto error; |
135 | vp_dev->msix_enabled = 1; | 139 | vp_dev->msix_enabled = 1; |