pci_irq_get_affinity(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… pci_irq_get_affinity β€” wait, bestie, come get your CPU affinity ✨

Okay so this is a page from the Kernel API Manual, and it's about pci_irq_get_affinity β€” literally the function that tells you which CPUs a device's interrupt vector is vibing with. Lowkey iconic. Let's get into it 🫢


✨ SYNOPSIS ✨

const struct cpumask * pci_irq_get_affinity (struct pci_dev *dev , int nr );

That's the whole signature, no cap. const struct cpumask * going in, your device and a number coming out β€” sorry, the other way around, you get the mask back πŸ’–


πŸŽ€ ARGUMENTS πŸŽ€

  • dev β€” the PCI device you're operating on. Like, the device in question. Your main character device, if you will πŸ‘‘
  • nr β€” the device-relative interrupt vector index, and bestie it is 0-based (yes, zero-indexed, we love that for us). Heads up though: it has different meanings depending on the interrupt mode. Keep reading, it's giving choose-your-own-adventure 🌈

πŸ¦‹ DESCRIPTION πŸ¦‹

So the meaning of nr depends entirely on which interrupt mode your device is in. Vibe check time:

  • MSI-X β€” nr is the index in the MSI-X vector table πŸ“‹
  • MSI β€” nr is the index of the enabled MSI vectors βœ…
  • INTx β€” nr must be 0. That's it. Zero. Nothing else. Periodt πŸ’…

🌸 RETURN 🌸

You get back the MSI/MSI-X vector affinity ✨

But listen, it can also be NULL β€” and here's exactly when, no guessing:

  • if nr is out of range 😭
  • if the MSI(-X) vector was allocated without explicit affinity requirements β€” like, for example, by pci_enable_msi, pci_enable_msix_range, or pci_alloc_irq_vectors without the PCI_IRQ_AFFINITY flag πŸ™ˆ

And one more little plot twist: if the device is in legacy INTx mode, you get back a generic set of CPU IDs representing all possible CPUs available during system boot πŸ–₯️✨

ngl the NULL cases are the ones you actually need to remember, bestie. Check your flags before you come crying about a NULL return πŸ“

πŸ’œ SEE ALSO πŸ’œ

Kernel file ./drivers/pci/msi/api.c, plus this whole friend group of functions β€” go say hi to all of them:


Okay that's the whole page! πŸŽ€ Sending you off with the cutest little sign-off: this one lives under ./drivers/pci/msi, and the manual was dated October 2026 β€” see you in the next release, bestie πŸ’–πŸ¦‹β­

πŸ“¦ where this page comes from