vp_request_msix_vectors() bumps desc->pre_vectors in place to reserve
the virtio config vector. vp_find_vqs() may call it more than once while
retrying MSI-X with different per-vq policies (EACH -> SHARED_SLOW ->
SHARED), so the caller's irq_affinity can accumulate and later attempts
get the wrong affinity layout.
This was not observed in production; it is inferred from that retry path.
Copy the descriptor to a local "affinity", adjust pre_vectors there,
assign desc = &affinity, and pass desc to pci_alloc_irq_vectors_affinity().
Fixes: ba74b6f7fcc0 ("virtio_pci: fix cpu affinity support")
Signed-off-by: Xiong Weimin <[email protected]>
---
Changes in v2:
- use local "affinity" and assign desc = &affinity (mst)
- drop comment arguing with previous code
- drop Cc: stable; state issue was not observed (theoretical)
drivers/virtio/virtio_pci_common.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/virtio/virtio_pci_common.c
b/drivers/virtio/virtio_pci_common.c
index 164f480b1..9415d160d 100644
--- a/drivers/virtio/virtio_pci_common.c
+++ b/drivers/virtio/virtio_pci_common.c
@@ -128,6 +128,7 @@ static int vp_request_msix_vectors(struct virtio_device
*vdev, int nvectors,
{
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
const char *name = dev_name(&vp_dev->vdev.dev);
+ struct irq_affinity affinity;
unsigned int flags = PCI_IRQ_MSIX;
unsigned int i, v;
int err = -ENOMEM;
@@ -150,8 +151,10 @@ static int vp_request_msix_vectors(struct virtio_device
*vdev, int nvectors,
desc = NULL;
if (desc) {
+ affinity = *desc;
+ affinity.pre_vectors++; /* virtio config vector */
+ desc = &affinity;
flags |= PCI_IRQ_AFFINITY;
- desc->pre_vectors++; /* virtio config vector */
}
err = pci_alloc_irq_vectors_affinity(vp_dev->pci_dev, nvectors,
--
2.43.0