Skip to content

Commit

Permalink
PCI/MSI: Simplify pci_irq_get_affinity()
Browse files Browse the repository at this point in the history
Replace open coded MSI descriptor chasing and use the proper accessor
functions instead.

Signed-off-by: Thomas Gleixner <[email protected]>
Tested-by: Michael Kelley <[email protected]>
Tested-by: Nishanth Menon <[email protected]>
Reviewed-by: Greg Kroah-Hartman <[email protected]>
Reviewed-by: Jason Gunthorpe <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
KAGA-KOKO committed Dec 16, 2021
1 parent 82ff8e6 commit f482359
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions drivers/pci/msi/msi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1104,26 +1104,20 @@ EXPORT_SYMBOL(pci_irq_vector);
*/
const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr)
{
if (dev->msix_enabled) {
struct msi_desc *entry;
int irq = pci_irq_vector(dev, nr);
struct msi_desc *desc;

for_each_pci_msi_entry(entry, dev) {
if (entry->msi_index == nr)
return &entry->affinity->mask;
}
WARN_ON_ONCE(1);
if (WARN_ON_ONCE(irq <= 0))
return NULL;
} else if (dev->msi_enabled) {
struct msi_desc *entry = first_pci_msi_entry(dev);

if (WARN_ON_ONCE(!entry || !entry->affinity ||
nr >= entry->nvec_used))
return NULL;

return &entry->affinity[nr].mask;
} else {
desc = irq_get_msi_desc(irq);
/* Non-MSI does not have the information handy */
if (!desc)
return cpu_possible_mask;
}

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

Expand Down

0 comments on commit f482359

Please sign in to comment.