Skip to contentSkip to conversation

PCI irq affinity fix for 4.12

PATCH Superseded Christoph Hellwig 2 participants 5 messages May 20, 2017 – May 26, 2017 PCI

lore
Share & tools
lore
#0 lore raw

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.

#1 lore raw

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.

Fixes aff17164 ("PCI: Provide sensible IRQ vector alloc/free routines")
---
 include/linux/pci.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/pci.h +1 -1
index 33c2b0b77429..5a7fd3b6a7b9 100644
@@ -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
#2 lore raw

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.

Fixes aff17164 ("PCI: Provide sensible IRQ vector alloc/free routines")

---

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
index 33c2b0b77429..fc2e832d7b9c 100644
@@ -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
#3 lore raw

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->irq and use the "correct" errno value based on feedback from Linus.

Fixes aff17164 ("PCI: Provide sensible IRQ vector alloc/free routines")

---

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
index 33c2b0b77429..fc2e832d7b9c 100644
@@ -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---

#4 lore raw

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