PCI/MSI: Let core code free MSI descriptors
authorThomas Gleixner <tglx@linutronix.de>
Mon, 6 Dec 2021 22:51:16 +0000 (23:51 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 16 Dec 2021 21:22:17 +0000 (22:22 +0100)
Set the domain info flag which tells the core code to free the MSI
descriptors from msi_domain_free_irqs() and add an explicit call to the
core function into the legacy code.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Michael Kelley <mikelley@microsoft.com>
Tested-by: Nishanth Menon <nm@ti.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://lore.kernel.org/r/20211206210748.089085131@linutronix.de
drivers/pci/msi/irqdomain.c
drivers/pci/msi/legacy.c
drivers/pci/msi/msi.c

index c81793a345c19659a64f11aa124c1736dcfe5b82..3aab61714abe5c51317b0bd687ebb4af24219274 100644 (file)
@@ -171,7 +171,8 @@ struct irq_domain *pci_msi_create_irq_domain(struct fwnode_handle *fwnode,
        if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS)
                pci_msi_domain_update_chip_ops(info);
 
-       info->flags |= MSI_FLAG_ACTIVATE_EARLY | MSI_FLAG_DEV_SYSFS;
+       info->flags |= MSI_FLAG_ACTIVATE_EARLY | MSI_FLAG_DEV_SYSFS |
+                      MSI_FLAG_FREE_MSI_DESCS;
        if (IS_ENABLED(CONFIG_GENERIC_IRQ_RESERVATION_MODE))
                info->flags |= MSI_FLAG_MUST_REACTIVATE;
 
index 773f35122bbb1f8a2a9a16d187a7793a6f7022dd..91c20a30a5df4caa87b2c14834de1fe8862697a2 100644 (file)
@@ -80,4 +80,5 @@ void pci_msi_legacy_teardown_msi_irqs(struct pci_dev *dev)
 {
        msi_device_destroy_sysfs(&dev->dev);
        arch_teardown_msi_irqs(dev);
+       msi_free_msi_descs(&dev->dev);
 }
index 4ee47ee955559e3aca8e79c23b1779c3749b036a..95db9c3d643eae7c794e3e27175ca2e363e2585e 100644 (file)
@@ -224,22 +224,8 @@ EXPORT_SYMBOL_GPL(pci_write_msi_msg);
 
 static void free_msi_irqs(struct pci_dev *dev)
 {
-       struct list_head *msi_list = dev_to_msi_list(&dev->dev);
-       struct msi_desc *entry, *tmp;
-       int i;
-
-       for_each_pci_msi_entry(entry, dev)
-               if (entry->irq)
-                       for (i = 0; i < entry->nvec_used; i++)
-                               BUG_ON(irq_has_action(entry->irq + i));
-
        pci_msi_teardown_msi_irqs(dev);
 
-       list_for_each_entry_safe(entry, tmp, msi_list, list) {
-               list_del(&entry->list);
-               free_msi_entry(entry);
-       }
-
        if (dev->msix_base) {
                iounmap(dev->msix_base);
                dev->msix_base = NULL;