diff options
| author | Bjorn Helgaas <bhelgaas@google.com> | 2026-04-13 12:50:03 -0500 |
|---|---|---|
| committer | Bjorn Helgaas <bhelgaas@google.com> | 2026-04-13 12:50:03 -0500 |
| commit | 3ebccb123dfa8b475ee77b9c49bc775152e70205 (patch) | |
| tree | d3e178f6879d57ad2d65306cb6b84aa81a0d8382 /drivers | |
| parent | c9aad5598046f884d5164b5e5000fd0b32a90dd7 (diff) | |
| parent | 874b07eb0875729b9a47441e03b125d9fa735645 (diff) | |
| download | lwn-3ebccb123dfa8b475ee77b9c49bc775152e70205.tar.gz lwn-3ebccb123dfa8b475ee77b9c49bc775152e70205.zip | |
Merge branch 'pci/msi'
- Update documentation of pci_free_irq_vectors() and pcim_enable_device()
(Shawn Lin)
* pci/msi:
PCI/MSI: Add TODO comment about legacy pcim_enable_device() side-effect
PCI/MSI: Clarify pci_free_irq_vectors() usage for managed devices
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/pci/msi/api.c | 5 | ||||
| -rw-r--r-- | drivers/pci/msi/msi.c | 10 |
2 files changed, 15 insertions, 0 deletions
diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index 818d55fbad0d..c18559b6272c 100644 --- a/drivers/pci/msi/api.c +++ b/drivers/pci/msi/api.c @@ -370,6 +370,11 @@ EXPORT_SYMBOL(pci_irq_get_affinity); * Undo the interrupt vector allocations and possible device MSI/MSI-X * enablement earlier done through pci_alloc_irq_vectors_affinity() or * pci_alloc_irq_vectors(). + * + * WARNING: Do not call this function if the device has been enabled + * with pcim_enable_device(). In that case, IRQ vectors are automatically + * managed via pcim_msi_release() and calling pci_free_irq_vectors() can + * lead to double-free issues. */ void pci_free_irq_vectors(struct pci_dev *dev) { diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index e2412175d7af..81d24a270a79 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -77,6 +77,16 @@ static void pcim_msi_release(void *pcidev) /* * Needs to be separate from pcim_release to prevent an ordering problem * vs. msi_device_data_release() in the MSI core code. + * + * TODO: Remove the legacy side-effect of pcim_enable_device() that + * activates automatic IRQ vector management. This design is dangerous + * and confusing because it switches normally un-managed functions + * into managed mode. Drivers should explicitly manage their IRQ vectors + * without this implicit behavior. + * + * The current implementation uses both pdev->is_managed and + * pdev->is_msi_managed flags, which adds unnecessary complexity. + * This should be simplified in a future kernel version. */ static int pcim_setup_msi_release(struct pci_dev *dev) { |
