PCI irq affinity fix for 4.12
Hi Bjorn,
Steve found a case where the !CONFIG_PCI_MSI stub for pci_alloc_irq_vectors did the wrong thing when used with the newly converted xhci driver. While the PCI code has been wrong since day 1 the fact that a newly converted drivers triggers it makes it a regression in this cycle.
PATCH 1/1 PCI/msi: fix the pci_alloc_irq_vectors_affinity stub
We need to return an error for any call that asks for MSI / MSI-X vectors only, so that non-trivial fallback logic can work properly.
--- include/linux/pci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/pci.h +1 -1
@@ -1342,7 +1342,7 @@ pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, unsigned int max_vecs, unsigned int flags, const struct irq_affinity *aff_desc) { - if (min_vecs > 1) + if (min_vecs > 1 || !(flags & PCI_IRQ_LEGACY)) return -EINVAL;return 1 ; }
Signature · 1 line
2.11.0
PATCH v2 1/1 PCI/msi: fix the pci_alloc_irq_vectors_affinity stub
We need to return an error for any call that asks for MSI / MSI-X vectors only, so that non-trivial fallback logic can work properly.
Also valid dev->irq and use the "correct" errno value based on feedback from Linus.
---
Changes from V1:
- use == comparism
- return -ENOSPC
- verify dev->irq
include/linux/pci.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/pci.h +3 -3
@@ -1342,9 +1342,9 @@ pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, unsigned int max_vecs, unsigned int flags, const struct irq_affinity *aff_desc) { - if (min_vecs > 1) - return -EINVAL; -return 1 ; + if ((flags & PCI_IRQ_LEGACY) && min_vecs == 1 && dev->irq) + return 1; +return -ENOSPC ; }static inline void pci_free_irq_vectors (struct pci_dev *dev)
Signature · 1 line
2.11.0
Re: [PATCH v2] PCI/msi: fix the pci_alloc_irq_vectors_affinity stub
Bjorn,
can you take this regression fix and sent it to Linux before -rc3? I had hope we could get it into -rc2 but already missed that, and I haven't heard a comment since..
Quoted 38 lines · Christoph Hellwig
We need to return an error for any call that asks for MSI / MSI-X vectors only, so that non-trivial fallback logic can work properly.
Also valid
dev->irqand use the "correct" errno value based on feedback from Linus.Signed-off-by Christoph Hellwig <[email protected]>Reported-by Steven Rostedt <[email protected]>Fixes aff17164 ("PCI: Provide sensible IRQ vector alloc/free routines")---
Changes from V1:
- use == comparism
- return-ENOSPC
- verifydev->irqinclude/linux/pci.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)include/linux/pci.h +3
-3@@ -1342,9 +1342,9 @@ pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, unsigned int max_vecs, unsigned int flags, const struct irq_affinity *aff_desc) { - if (min_vecs > 1) - return -EINVAL; -return 1 ; + if ((flags & PCI_IRQ_LEGACY) && min_vecs == 1 && dev->irq) + return 1; +return -ENOSPC ; }static inline void pci_free_irq_vectors (struct pci_dev *dev)Signature · 1 line
2.11.0
---end quoted text---
Re: [PATCH v2] PCI/msi: fix the pci_alloc_irq_vectors_affinity stub
Quoted 5 lines · Christoph Hellwig
Bjorn,
can you take this regression fix and sent it to Linux before -rc3? I had hope we could get it into -rc2 but already missed that, and I haven't heard a comment since..
I took it directly..
Linus