pci_irq_get_affinity(9)
π 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 β
nris the index in the MSI-X vector table π - MSI β
nris the index of the enabled MSI vectors β - INTx β
nrmust be0. 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
nris 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, orpci_alloc_irq_vectorswithout thePCI_IRQ_AFFINITYflag π
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 theNULLcases are the ones you actually need to remember, bestie. Check your flags before you come crying about aNULLreturn π
π SEE ALSO π
Kernel file ./drivers/pci/msi/api.c, plus this whole friend group of functions β go say hi to all of them:
pci_enable_msi(9)pci_disable_msi(9)pci_msix_vec_count(9)pci_enable_msix_range(9)pci_msix_can_alloc_dyn(9)pci_msix_alloc_irq_at(9)pci_msix_free_irq(9)pci_disable_msix(9)pci_alloc_irq_vectors(9)pci_alloc_irq_vectors_affinity(9)pci_irq_vector(9)pci_free_irq_vectors(9)pci_restore_msi_state(9)pci_msi_enabled(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms