Skip to content

Commit d558285

Browse files
committed
PCI/MSI: Unbreak pci_irq_get_affinity()
The recent cleanup of pci_irq_get_affinity() broke the function for PCI/MSI-X and indices > 0. Only the MSI descriptor for PCI/MSI has more than one affinity mask which can be retrieved via the MSI index. PCI/MSI-X has one descriptor per vector and each has a single affinity mask. Use index 0 when accessing the affinity mask in the MSI descriptor when MSI-X is enabled. Fixes: f482359 ("PCI/MSI: Simplify pci_irq_get_affinity()") Reported-by: Nathan Chancellor <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Nathan Chancellor <[email protected]> Link: https://lore.kernel.org/r/87v8zm9pmd.ffs@tglx
1 parent cd6cf06 commit d558285

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/pci/msi/msi.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ EXPORT_SYMBOL(pci_irq_vector);
11001100
*/
11011101
const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)
11021102
{
1103-
int irq = pci_irq_vector(dev, nr);
1103+
int idx, irq = pci_irq_vector(dev, nr);
11041104
struct msi_desc *desc;
11051105

11061106
if (WARN_ON_ONCE(irq <= 0))
@@ -1113,7 +1113,13 @@ const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)
11131113

11141114
if (WARN_ON_ONCE(!desc->affinity))
11151115
return NULL;
1116-
return &desc->affinity[nr].mask;
1116+
1117+
/*
1118+
* MSI has a mask array in the descriptor.
1119+
* MSI-X has a single mask.
1120+
*/
1121+
idx = dev->msi_enabled ? nr : 0;
1122+
return &desc->affinity[idx].mask;
11171123
}
11181124
EXPORT_SYMBOL(pci_irq_get_affinity);
11191125

0 commit comments

Comments
 (0)