Skip to content

Commit

Permalink
PCI/MSI: Unbreak pci_irq_get_affinity()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
KAGA-KOKO committed Dec 18, 2021
1 parent cd6cf06 commit d558285
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/pci/msi/msi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ EXPORT_SYMBOL(pci_irq_vector);
*/
const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)
{
int irq = pci_irq_vector(dev, nr);
int idx, irq = pci_irq_vector(dev, nr);
struct msi_desc *desc;

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

if (WARN_ON_ONCE(!desc->affinity))
return NULL;
return &desc->affinity[nr].mask;

/*
* MSI has a mask array in the descriptor.
* MSI-X has a single mask.
*/
idx = dev->msi_enabled ? nr : 0;
return &desc->affinity[idx].mask;
}
EXPORT_SYMBOL(pci_irq_get_affinity);

Expand Down

0 comments on commit d558285

Please sign in to comment.